title: How to access parent or wrapper variables from an AS3 Worker Class
body: <p>I am using Flash Builder 4.7 and have created a Worker Class. Below is the code:</p>
  
  <pre><code>package co.fuix.mobile.system.model
  {
      import flash.display.DisplayObjectContainer;
      import flash.display.Sprite;
      import flash.events.Event;
      import flash.system.MessageChannel;
      import flash.system.Worker;
      import flash.utils.getDefinitionByName;
  
      import mx.managers.SystemManager;
  
      public class InstantMessengerWorker extends Sprite
      {
  
          private var bm:MessageChannel;
          private var mb:MessageChannel;
          public function InstantMessengerWorker()
          {
  
              super();
  
              bm = Worker.current.getSharedProperty("BACK_TO_MAIN_CHANNEL");
              mb = Worker.current.getSharedProperty("MAIN_TO_BACK_CHANNEL");
              mb.addEventListener(Event.CHANNEL_MESSAGE, onMainToBack);
  
          }
  
          protected function onMainToBack(event:Event):void
          {
              if(mb.messageAvailable){
                  var s:SystemManager;
                  trace('*'+mb.receive());
                  trace('**'+mb.receive());
                  trace('***'+mb.receive());
                  trace(mx.core.FlexGlobals.topLevelApplication.myVariable);
              }
          }
      }
  }
  </code></pre>
  
  <p>How do I reference a variable in the main mxml file. I know how to use message channels but I want to get that variable straight.</p>
  
  <p>When I run the above code, this part</p>
  
  <pre><code>trace(mx.core.FlexGlobals.topLevelApplication.myVariable);
  </code></pre>
  
  <p>is giving me an error. </p>
  
  <p>Any help will be regreatly appreciated</p>