Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Inacessible method through a static type reference  (Read 9050 times)
saad
Sr. Member
****
Posts: 65


View Profile Email
« on: January 24, 2011, 07:27:11 »

Inside DragRaceMediator.as (it's basically my stageMediator or applicationMediator)

      override public function handleNotification(notification:INotification):void {
         switch(notification.getName()){
            case ApplicationFacade.SHOW_MENU:
               dragRace.showMenu(); //works fine here
               //viewComponent.showModal(); //works fine, method exists and gets called
               dragRace.showModal(); //throws inaccessible method error,
               break;
            
            default:
               break;
         }
      }

      
      private function get dragRace():DragRace {
         return viewComponent as DragRace;
      }


Inside DragRace.as (which is actually my main document file)

   public class DragRace extends MovieClip {

      private var _menu:Menu;   
      private var _modal:Modal;

      public function DragRace() {
         
         menu = new Menu();
         modal = new Modal();
         
         ApplicationFacade.getInstance().startup(this);
      }
      
      public function showMenu():void {
         addChild(menu);
         trace('show menu');
      }
      
      public function hideMenu():void {
         removeChild(menu);
      }
      
      public function showModal():void {
         trace('show modal');
         addChild(modal);
      }
      
      public function hideModal():void {
         removeChild(modal);
      }

      public function get menu():Menu {
         return _menu;
      }

      public function set menu(value:Menu):void {
         _menu = value;
      }

      public function get modal():Modal {
         return _modal;
      }

      public function set modal(value:Modal):void {
         _modal = value;
      }
         }
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: January 24, 2011, 11:04:12 »

This is a strange one. Are you sure that your import for DragRace is correct?

I can say this is a pure ActionScript problem and not a PureMVC problem, though.

-=Cliff>
Logged
saad
Sr. Member
****
Posts: 65


View Profile Email
« Reply #2 on: January 25, 2011, 03:40:37 »

Hi Cliff:

You are right, it's some kind of ActionScript error but really a weird one, the import is right as it works with the first statement but fails on the second attempt, and only work around is to call the function through viewComponent without using the get method.

I have uploaded the project for you to have a look at http://www.filefactory.com/file/b524h9b/n/DragRace.zip

It's a small project at this stage, nothing complex, just a StartupCommand with mediator initializations and a notification, kindly have a look.

My working environment is Flash CS5/Flash Builder 4
« Last Edit: January 25, 2011, 03:43:09 by saad » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: January 26, 2011, 12:13:48 »

It's a small project at this stage, nothing complex, just a StartupCommand with mediator initializations and a notification, kindly have a look.

That site (filefactory.com) is awful! 500 ads per page, pops up videos in separate windows and then makes you wait to download the file while telling you that you could download it right away if you paid for their premium service. Ugh! Highly NOT recommended.

But I waited and I downloaded the file. It has your entire SVN tree inside it.

Here's a really handy tip for everyone: When you share an SVN project from Eclipse/FlashBuilder, do it by right clicking on the project, and selecting Team->Export. Direct it to a folder on your desktop, and you have just your files, with all the .svn folders stripped.

And: If you're on a Mac, *please* remove the _MACOSX folder tree that can nearly double the number of files the the zip file by including a separate copy of every folder.

nothing complex, just a StartupCommand with mediator initializations and a notification
As a result of the SVN and _MACOSX cruft, your zip file containing a project that you describe as has 641 files in it.

I'm disinclined to go further into trying to make use of this file. But I don't need to, really.

We're looking at an ActionScript problem here, not a PureMVC problem.

I suggest you reproduce the problem in a petri-dish. This is AS3 troubleshooting 101. Make a simple class, not a PureMVC class at all, just a class that instantiates DragRace.as (comment out the ApplicationFacade import and reference in DragRace.as first). Then in your simple class, do:

:
public class TestClass {
               public var viewComponent:Object = new DragRace();
         
               private function get dragRace():DragRace {
                              return viewComponent as DragRace;
               }

               public function TestClass {
                              dragRace.showMenu(); //works fine here
                              //viewComponent.showModal(); //works fine, method exists and gets called ???
                              dragRace.showModal(); //throws inaccessible method error ???
               }
}

In a new MXML application, create a button that the click event triggers a the creation of a TestClass instance. Set a debugger breakpoint on the first line of the TestClass constructor and hit debug. Step through the code and see what happens.

-=Cliff>
Logged
Pages: [1]
Print