2 Replies Latest reply on Apr 15, 2008 8:25 AM by alex-party

    Varialbe Scope in Components

    alex-party
      Hello,

      I'm having troubles with global variables scope. Basically I set a global variable 'tags' to some value and then I call a component, which on button click changes the 'tag' variable, but somehow 'tag' var is not defined in component, could someone tell me why?

      Thank you,
      Alex
      ##############################################
      ..................... Main.mxml application .......................
      ##############################################
      <mx:Application import='...importing components here ....'>

      <mx:Script><![CDATA[
      [Bindable] public var tags:ArrayCollection;
      public function srv_handle(event:ResultEvent):void{
      tags = ... -----------------> 1. SET VARIABLE HERE
      }
      ]]></mx:Script>

      <v:GTags _data2="{tags}"/> -----------------> 2. CALL COMPONENT HERE

      </mx:Application>

      ##############################################
      ..................... GTags.mxml component .......................
      ##############################################
      <mx:Script><![CDATA[

      function clickButton():void{
      trace( tags); 3. -----------------> WE WANT TO CHANGE IT HERE
      // tags = NOT DEFINED, WHY?
      }

      ]]></mx:Script>