ãã€ãã®ããã«ãèªçããå§ããŸããã
質åïŒ
ã¯ã©ã¹ã³ã³ã¹ãã©ã¯ã¿ãŒã§ã¯ããªãœãŒã¹ãéäžçã«äœ¿çšããªãã§ãã ããã éåžžãå€æ°ã®åæåãševentListenersã®è¿œå ã«ã®ã¿äœ¿çšãããŸãã
flexã§ãã¹ããããèŠçŽ ãäœæããããã«ãç¹å¥ãªé¢æ°createChildrenïŒïŒãæäŸãããŠããŸãã ã³ã³ããŒãã³ããdisplayList'yã«è¿œå ããããšãèªåçã«åŒã³åºãããŸãã ãããã£ãŠãå éšã«äœããå¿ èŠãªå Žåã¯ãcreateChildrenãåå®çŸ©ããå éšèŠçŽ ãäœæããã³ãŒããããã«é 眮ããå¿ èŠããããŸãã ããã«ã¯åŸ®åŠãªç¹ã1ã€ãããŸãã次ã®ãã¯ã¢ã³ãç»åããã§ã«äœæãããŠãããã©ããã確èªããŠãã ããã ããã«ã¯2ã€ã®çç±ããããŸãã 1ã€ç®ã¯ãã³ã³ããŒãã³ãã1ã€ã®displayListaããå¥ã®displayListaã«ç§»åããå ŽåãcreateChildrenãè€æ°ååŒã³åºãããšãã§ããããšã§ãã ããšãã°ãé »ç¹ã«åé€ããã³åè¿œå ãããitemRendererã ãããã£ãŠãç§ãã¡ã¯åã裞ã®å¥³æ§ã®ã³ããŒãããããæã«å ¥ããããšãã§ããŸãããããã¯ãåãã®ããã«é¢çœããããŸããã 2çªç®ã®çç±ã¯ã掟çã¯ã©ã¹ã®åäœãå€æŽããå¯èœæ§ã§ãã åŸç¶ã¯ã©ã¹ããã¢ã³ãžã§ãªãŒããžã§ãªãŒããã¡ã©ã¢ã³ããŒãœã³ã§ã¯ãªãå·Šäžé ã«ãããšå€æããå Žåãå¿ èŠãªåœ¢åŒã§ãã®å éšèŠçŽ ãäœæããsuper.createChildrenïŒïŒãåŒã³åºããŸãã 芪ã³ã³ããŒãã³ãã¯ãèŠçŽ ããã§ã«äœæãããŠããããšã確èªããäœæ¥ã«ç ©ããããŸããã
äŸïŒ
ä¿è·ããã é¢æ° createChildren ïŒïŒã ãªãŒããŒã©ã€ãããŸã ïŒ void
{
//ã³ã³ããŒãã³ããæ¢ã«ååšãããã©ããã確èªããŸã
If ïŒïŒ OurNestedComponent ïŒ
{
//ããã§ãªãå Žåã¯ãäœæããŸã
ourNestedComponent = new NestedComponent ïŒïŒ;
addChild ïŒ ourNestedComponent ïŒ;
}
// createChildrenãéå±€ã§åŒã³åºãããšãå¿ããªãã§ãã ãã
ã¹ãŒã㌠ã createChildren ïŒïŒ;
}
ä»ã楜ããéšåã¯äººçãšãŠãŒã¶ãŒã®çžäºäœçšã§ã
質åïŒããã€ãã®ããããã£ãå€æŽãããã®ã§ãããããã«ãéæ³ã¯ãããŸããïŒ
ã¯ããéåžžã«äŸ¿å©ã§ãã é 延æ€èšŒãšåŒã°ããŸãã ãæ€èšŒããšããèšèã«é©ããªãã§ãã ããããã®ã³ã³ããã¹ãã§ã¯ãããããã£ã®é©çšãèæ¯ã®åæç»ãå éšèŠçŽ ã®äœçœ®ã®å€æŽãªã©ãã³ã³ããŒãã³ãã®ç¶æ ã®å€åãæå³ããŸãã ã©ã®ããã«æ©èœããŸããïŒ ããããã£ã»ãã¿ãŒã§ããããã£ãçŽæ¥å€æŽããããšã¯ãå§ãã§ããŸããã 第äžã«ãããã¯ãŠãŒã¶ãŒã®æäœäžã«ã€ã³ã¿ãŒãã§ã€ã¹ã®èŠèŠçãªæ»ãããã«æªåœ±é¿ãäžããå¯èœæ§ããããŸãã ç¹ã«ãå€æŽããªãœãŒã¹ãéäžçã«äœ¿çšããå Žåã 第äºã«ãããããããã£ãå¥ã®ããããã£ã«äŸåããŠããå ŽåããŸãã¯ããããã£ãç¹å®ã®é åºã§é©çšããå¿ èŠãããå Žåã¯ãäœããã®åŸ æ©ããã³åæã¡ã«ããºã ã«ã€ããŠèããå¿ èŠããããŸãã é 延æ€èšŒã¯ããã®ãã¹ãŠãåé¿ããæ¹æ³ã§ãã ããããã£ãããã«é©çšããã®ã§ã¯ãªãã延æãããç»é¢ãã¬ã³ããªã³ã°ããçŽåã«å€æŽãæå¹ã«ãªããŸãã
å€æŽã®æ€èšŒã¯ã次ã®3段éã§è¡ãããŸãã
- ããããã£ãå€æŽãããïŒcommitPropertiesé¢æ°ïŒ
- åªå 寞æ³ãèšç®ãããŸãïŒæž¬å®æ©èœïŒ
- å
éšèŠçŽ ã®å®éã®ãµã€ãºããµã€ãºãããã³åº§æšãèšç®ãããæç»ããå¿
èŠããããã¹ãŠã®ãã®ãæç»ãããŸãã ïŒé¢æ°updateDisplayListïŒ
ãããã®åé¢æ°ã¯ãä¿çäžã®ãã¹ãŠã®ã³ã³ããŒãã³ãã®ã¬ã³ããªã³ã°ã€ãã³ãäžã«èªåçã«åŒã³åºãããŸãã ã³ã³ããŒãã³ããæ€èšŒåŸ ã¡ãšããŠããŒã¯ããã«ã¯ãcommitPropertiesã®invalidatePropertiesïŒïŒãmeasureã®invalidateSizeïŒïŒãupdateDisplayListã®invalidateDisplayListïŒïŒã®ã³ã³ããŒãã³ãã®ç¹å¥ãªé¢æ°ãåŒã³åºãå¿ èŠããããŸãã
次ã«ãå®è·µã«ç§»ããæ€èšŒã®åãã€ã³ãã«ã€ããŠè©³ãã説æããŸãã
ã¹ããŒãž1-commitPropertiesé¢æ°
ããšãã°ããæå人ãã®ã®ã£ã©ãªãŒã§ã¯ãåçèªäœã«å ããŠãããã€ãã®ã³ã³ãããŒã«ããããŸãã ãŠãŒã¶ãŒã¯ããããããŠã³ã¡ãã¥ãŒã䜿çšããŠã»ã¯ã·ã§ã³ãå€æŽããã¹ã©ã€ããŒã§ããŒãã®åºŠåãã調æŽã§ããŸãããŸããããã€ãã®ããã§ã€ããªããããéããŠãããã®ãã©ã¡ãŒã¿ãŒãåæã«å€æŽã§ããŸãã ãããã£ãŠããã»ã¯ã·ã§ã³ããšãè±è¡£ã®çšåºŠããšãã2ã€ã®ããããã£ãããããããã¯åå¥ã«ãåæã«ãå€æŽã§ããŸãã ã»ãã¿ãŒã§å€æŽãçŽæ¥åŠçããå Žåãè¿œå ã®äœæ¥ãå¿ èŠã«ãªãå ŽåããããŸãã å®éããŠãŒã¶ãŒããæ°ã«å ¥ãããã極端ã«æ¥ç¥ãããã®ããŒãã®ãããªã¹ãã«ãã³ãã»ã¯ã·ã§ã³ããåçãéžæããå Žåãæåã«ããã©ã«ãã®ããŒãã®ãããªã¹ãã«ãã³ãããŒãã£ã·ã§ã³ãããŠã³ããŒããããã®åŸã極端ã«æ¥ç¥ããããé©çšããŠæ°ããåçãããŒãããå¿ èŠããããŸãã ãããåé¿ããããã«ãã»ãã¿ãŒã§ã¯æ°ããç¶æ ã®ã¿ãä¿åããå€æŽèªäœã¯commitPropertiesé¢æ°ã§å®è¡ãããŸãã
äŸïŒ
ãããªã㯠é¢æ° ã»ããã»ã¯ã·ã§ã³ïŒ value ïŒ String ïŒïŒ void
{
_section = value ; //æ°ããå€ããã©ã€ããŒãå€æ°ã«ä¿åããŸã
_sectionChanged = true ; //äœãå€æŽãããããæ£ç¢ºã«èŠããŠãã ãã
invalidateProperties ïŒïŒ; //次ã®å埩ã§commitPropertiesåŒã³åºãã«ã³ã³ããŒãã³ãã«çœ²åããŸã
}
ãããªã㯠é¢æ° ã»ãã nudeDegree ïŒ value ïŒ String ïŒïŒ void
{
_nudeDegree = value ;
_nudeDegreeChanged = true ;
invalidateProperties ïŒïŒ;
}
ä¿è·ããã é¢æ°ã® ãªãŒããŒã©ã€ã commitProperties ïŒïŒïŒ void
{
If ïŒ _sectoinChanged || _nudeDegreeChanged ïŒ
{
//ããã§å¿ èŠãªåçãããŒããããã¹ãŠã®äœæ¥ãè¡ããŸã
...
//å€æŽã«é¢ãããã©ã°ãåé€ããŸã
_sectionChanged = false ;
_nudeDegreeChanged = false ;
}
//ä»ã®ããããã£ãé©çšããŸã
...
// commitPropertiesãéå±€ã§åŒã³åºãããšãå¿ããªãã§ãã ãã
ã¹ãŒããŒã commitProperties ïŒïŒ;
}
commitPropertiesã䜿çšãããšããã¹ãŠã®ããããã£ãå¿ èŠãªé åºã§äžåºŠé©çšãããŸãã
次ã®æ€èšŒæé ã¯ãã¡ãžã£ãŒïŒïŒé¢æ°ã§ã
ãã®é¢æ°ã¯ãåªå ã³ã³ããŒãã³ããµã€ãºïŒmeasuredWidthããã³measuredHeightïŒããã³æå°ã³ã³ããŒãã³ãïŒmeasuredMinWidthããã³measuredMinHeightïŒã®èšç®ã«äœ¿çšãããŸãã 芪ã³ã³ããŒãã³ãã¯ãæ瀺çã«æå®ãããŠããªãå Žåããããã®å€ã䜿çšããŠå¯žæ³ã決å®ããŸãã ããšãã°ãã®ã£ã©ãªãŒå ã®åçã®æ°ã«å¿ããŠã®ã£ã©ãªãŒã®ãµã€ãºãèªåçã«å€æŽããå Žåãåªå ãµã€ãºãèšç®ããå¿ èŠããããŸãã ãããè¡ãã«ã¯ããã¹ãŠã®ç»åã®ãµã€ãºãå ç®ããã³ãŒãã枬å®é¢æ°ã«è¿œå ããã³ã³ãããŒã«ã®ãµã€ãºãèæ ®ããŠãååŸããå€ãmeasuredWidthããã³measuredHeightã«å²ãåœãŠãŸãã
ã³ã³ããŒãã³ãã枬å®é¢æ°ã«ãµãã¹ã¯ã©ã€ãããã«ã¯ãinvalidateSizeïŒïŒé¢æ°ãåŒã³åºãå¿ èŠããããŸãã 枬å®æ©èœã¯ãã³ã³ããŒãã³ãã®å¯žæ³ãæå®ãããŠããªãå Žåã«ã®ã¿å®è¡ãããããã©ã«ãå€ãèšç®ãããŸã;ããã§ãªãå Žåã¯ãæå®ããããµã€ãºã䜿çšãããŸãã
ãããŠæåŸã«ãæ€èšŒã®æçµæ®µéïŒé¢æ°updateDisplayList
å éšèŠçŽ ã®ãµã€ãºå€æŽãŸãã¯åº§æšã«é¢é£ãããã¹ãŠã®ãã®ã¯ãããã«é 眮ããå¿ èŠããããŸãã updateDisplayListã¯ãunscaledWidthãšunscaledHeightã®2ã€ã®ãã©ã¡ãŒã¿ãŒãåãå ¥ããŸãã ãããã¯èŠªã³ã³ããŒãã³ãã«ãã£ãŠæ±ºå®ãããå éšã³ã³ããŒãã³ãã®åº§æšãšãµã€ãºã®èšç®ã«ã¯ïŒå¹ ãšé«ãã§ã¯ãªãïŒäœ¿çšããå¿ èŠããããŸãã
ãŸããå éšã³ã³ããŒãã³ãã®ããããã£ãå€æŽããããã®èŠåã«åŸãå¿ èŠããããŸãã
- ç¹å®ã®å€ãèšå®ããã®ã§ã¯ãªããsetActualSizeïŒå¹ ãé«ãïŒé¢æ°ã䜿çšããŠãµã€ãºãå€æŽããŸãã
- ç¹å®ã®xå€ãšyå€ãæå®ããŠãçŽç·ã§ã¯ãªãmoveïŒxãyïŒé¢æ°ã䜿çšããŠåº§æšãå€æŽããŸã
- ã»ãšãã©ã®å Žåããããã®ã«ãŒã«ã¯ãã³ã³ããŒãã³ãã®äžé©åãªåäœã«é¢ããåé¡ãæé€ããŸãã
ã³ã³ããŒãã³ã寞æ³
質åïŒãã¬ãã¯ã¹ã«ã¯ã寞æ³ã瀺ãéåžžã«å€ãã®ç°ãªãããããã£ããããŸãã ãªã圌ãã¯ãã¹ãŠã§ããïŒ
寞æ³ã¯ããã€ãã®æ¹æ³ã§èšå®ãããŸãã
- æšå¥šãµã€ãºïŒmeasuredWidthãmeasuredHeightïŒã ãããã¯ã³ã³ããŒãã³ãèªäœã«ãã£ãŠæ±ºå®ãããŸãã ãããã®ãµã€ãºã¯ãç¹ã«æå®ããªãéããã³ã³ããŒãã³ãããã®å Žæã«ååã§ããå Žåã«äœ¿çšãããŸãã ããšãã°ãMXMLãä»ããŠãã¿ã³ãé
眮ãã寞æ³ãæå®ããªãå Žåãã¡ãžã£ãŒé¢æ°ã䜿çšããŠæ±ºå®ãããµã€ãºãšãŸã£ããåããµã€ãºã«ãªããŸã
- æå°å¯žæ³ïŒmeasuredMinWidthããã³measuredMinHeightïŒã ãŸããã³ã³ããŒãã³ãèªäœã«ãã£ãŠã決å®ãããŸãã 寞æ³ãæå®ãããŠããªãå ŽåïŒmeasuredWidthããã³measuredHeightã䜿çšãããŠããå ŽåïŒãåªå
ãµã€ãºã芪ã³ã³ããŒãã³ãã®å¯žæ³ããã倧ããå Žåãã³ã³ããŒãã³ããããèªäœã«åããããã«ãµã€ãºãçž®å°ããããšããŸãã æå°ãµã€ãºã¯ããããã®è©Šè¡ã®äžéãèšå®ããã ãã§ã
- ããŒã»ã³ã寞æ³ïŒpercentageWidthããã³percentageHeightïŒã¯ã芪ã³ã³ããŒãã³ãã®å¯žæ³ã®ããŒã»ã³ããŒãžã§ã
- æ瀺çã«æå®ããã寞æ³ïŒexplicitWidthããã³explicitHeightïŒã¯ããã¯ã»ã«åäœã®ã³ã³ããŒãã³ãã®å¯žæ³ã§ãã ãŸããå¹
ãšé«ããçŽæ¥èšå®ããŸã
ããŒã»ã³ãåäœã®ãµã€ãºãšãã¯ã»ã«åäœã®ãµã€ãºã¯ãåªå ããã³æå°ã«äŸåãããä»»æã®å€ãåãããšãã§ããŸãã
ãããã¯ãèªãïŒ
www.slideshare.net/Constantiner/flex-component-lifecycle-overview-æ®å¿µãªããé³å£°ãªãã§ãPavel Kozhinã«ããçŽ æŽããããã¬ãŒã³ããŒã·ã§ã³ã®ã¹ã©ã€ãã ããã¯ç§ããã·ã¢ã®ã€ã³ã¿ãŒãããã®ãããã¯ã§èŠã€ããã»ãšãã©ãã¹ãŠã§ãã
ã³ã³ããŒãã³ã [ENG]ã®å®è£ -Adobeèªäœã®livedoxã 詳现ã§ãããå°ããã©ã€ã§è±èªã§ãã ãã ããèªãå¿ èŠããããŸãã