aharui commented on issue #499: Uncaught TypeError: Cannot set property 'html' 
of undefined on j:Label on SDK 0.9.6
URL: https://github.com/apache/royale-asjs/issues/499#issuecomment-546181905
 
 
   This is a timing problem.  When added as a bead, the IStatesImpl relies on 
the initComplete to initialize, but if the application is also relying on a 
state change in initComplete, the application's handler will get called before 
the IStatesImpl gets initialized.
   
   The Containers are set up to initialize their IStatesImpls when the states 
property is assigned its states.  That gets them in early to be the first to 
get the initComplete event.  So, if folks are relying on state changes in 
initComplete, they should use CSS instead of beads to setup the IStatesImpl.  
The MXRoyale and SparkRoyale defaults.css setup a default IStatesImpl for all 
containers.  Jewel could do the same.
   
   This version uses CSS instead of beads and seems to work.
   
   ```
   <j:ScrollableSectionContent 
       xmlns:fx="http://ns.adobe.com/mxml/2009"; 
       xmlns:j="library://ns.apache.org/royale/jewel" 
       xmlns:js="library://ns.apache.org/royale/basic" 
       initComplete="ev_initComplete()">
       
       <js:states>
           <js:State name="login"/>
           <js:State name="loggued"/>
       </js:states>
   
       <j:Group includeIn="login">
           <j:Label id="lbl_ident"/>
       </j:Group>
   
       <fx:Style>
           global {
               IStatesImpl:            
ClassReference("org.apache.royale.core.SimpleStatesImpl");
           }
       </fx:Style>
       <fx:Script>
           <![CDATA[
   
               private function ev_initComplete():void {
                   this.currentState = "login";
                   var str:String = "<p style='color:#ff6600'>Veuillez vous 
identifier.</p>";
                   lbl_ident.html = str;
               }
   
           ]]>
       </fx:Script>
   
   
   </j:ScrollableSectionContent>
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to