0 Replies Latest reply on Nov 3, 2011 5:15 AM by zeroin

    "access of undefined property" warning in Actionscript mobile project

    zeroin

      Hi,

       

      I am trying to build a simple Actionscript mobile project with two "pages": one main class adds another class (which also extends Sprite) to the stage. Everything works as expected, except that when the secondary class tries to access public properties of main class, builder displays "access of undefined property" warning (it compiles ans runs as expected). If I move all the code to simple, not mobile project, this warning is not displayed. Not a big deal (except that autocompleat doesn't work), however maybe I am doing something wrong here? Below is the code:

       

      Main class:

       

       

       

      package
      {
                import flash.display.Sprite;
                import flash.events.MouseEvent;
      
                public class testProject extends Sprite
                {
      
                          private var _something:Number = 100;
      
                          public function testProject()
                          {
                                    init();
                          }
      
                          private function init():void
                          {
                                    // add big button
                                    var _nextButton:Sprite = new Sprite();
                                    _nextButton.graphics.beginFill(0x00CC00);
                                    _nextButton.graphics.drawCircle(0, 0, 100);
                                    this.addChild(_nextButton);
      
                                    _nextButton.addEventListener(MouseEvent.MOUSE_UP, goToNavigation);
                          }
      
                          private function goToNavigation(event:MouseEvent):void
                          {
                                    var nav:NavigationScene = new NavigationScene();
                                    this.addChild(nav);
                                    nav.mainApplication = this;
                                    nav.init();
                          }
      
                          public function get something():Number
                          {
                                    return _something;
                          }
                }
      }
      
      

       

      Secondary class:

       

       

      package
      {
                import flash.display.Sprite;
      
                public class NavigationScene extends Sprite
                {
                          private var _mainApplication:testProject;
                          private var _bigTempButton:Sprite;
      
                          public function NavigationScene()
                          {
                                    super();
                          }
      
                          public function init():void
                          {
                                    _bigTempButton = new Sprite();
                                    _bigTempButton.graphics.beginFill(0xCC0000);
                                    _bigTempButton.graphics.drawRect(200, 200, 100, 100);
                                    this.addChild(_bigTempButton);
                          }
      
                          public function set mainApplication(value:testProject):void
                          {
                                    _mainApplication = value;
                                    _mainApplication.something;  /// mobile project displays warning here
                          }
                }
      }