5 Replies Latest reply on May 12, 2009 6:59 PM by GordonSmith

    How can he update a non-existent string?

    hsfrey

      I suppose 40 years of imperative programming has rendered me unable to comprehend this new-fangled style of Declarative programming! :-(


      Here's a short program from a Flex book which I can't understand.

       

      At Initialization of the mx:Panel, which is supposed to be triggered BEFORE the panel is created, he writes into a text string, "event_txt.text", which is defined WITHIN mx:Panel, ie: AFTER the panel has been created.

       

      And it Works! ??

       

      How can event_txt be updated before it has been created?

       

      OK, I must be confused about when 'initialize' is triggered.

       

      Can anyone straighten me out?

       

      Is there a preliminary compiler scan BEFORE 'initialization" to pick up all the variable names?

      If so, what else happens before "initialization"?

       

      Thanks!

       

      <?xml version="1.0" encoding="utf-8"?>
      <!--
      ////////////////////////////////////////////////////////////////////////////////
      // Flex Solutions: Essential Techniques for Flex 2 and Flex 3 Developers
      // Author: Marco Casario // All Rights Reserved.
      // Solution 1-5: Understanding the Flex event model
      // @author Marco Casario// @date 26 November 2007// @version 1.0// @site flexsolutions.comtaste.com
      ////////////////////////////////////////////////////////////////////////////////
      -->
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
          initialize="event_txt.text += '\n Application initialize fired'"
          creationComplete="event_txt.text += '\n Application creationComplete fired'" >
       
          <mx:Panel title="Handling System Events"
                 initialize="event_txt.text += ('\n Panel initialize fired')" width="372" height="234"  <!-- here's the Initialize statement -->
              creationComplete="event_txt.text += ('\n Panel creationComplete fired')" >

              <mx:TextArea editable="false" height="100%" width="100%" 
                  id="event_txt" />                                                                 <!-- this string isn't defined till AFTER initialization, right? -->

          </mx:Panel>

      </mx:Application>

       

      <!--

      ///////////// OUTPUT  ///////////////////
      //Panel initialize fired
      // Application initialize fired
      // Panel creationComplete fired
      // Application creationComplete fired
      ////////////////////////////////////////

      -->