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: AS3 Structure help  (Read 8869 times)
kharr1027
Newbie
*
Posts: 3


View Profile Email
« on: July 10, 2008, 02:07:09 »

I am new to PureMVC and am having a hard time grasping how it all ties together. I have a view created but how does the view get placed onto the stage? Is this handled in PureMVC or do you create the object (new component()) and then add it to the stage yourself? Where should this be done at? I have been looking through the forum and at examples for 3 days now and still am not quite understanding it. Any help would be greatly appreciated.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: July 11, 2008, 03:57:05 »

You'll probably want to have an ApplicationMeditor that holds the reference to the top level app. You'll send a Notification from the Mediator or Command that created the new component, with that component as the body of the note.

The ApplicationMediator will be interested in this note and will take the component and do an addChild on the Application. This assumes Flex. If you're talking about Flash that might be a StageMediator instead.

-=Cliff>
Logged
kharr1027
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: July 23, 2008, 07:00:06 »

thanks for the reply cliff. you probably don't remember me but we worked together a little bit while you were at ntara. You attempted to help us with a php project that was way over my head at the time. yeah, i am no longer there either. looks like things are going well for you though. thanks again i think i am starting to understand the PureMVC framework now.
Logged
kharr1027
Newbie
*
Posts: 3


View Profile Email
« Reply #3 on: July 23, 2008, 10:51:46 »

finally got views on the stage and have a starting application going. my question is though through all the examples i have looked at i never see any of the doing

:
var com = new Component();
is there a better way to go about this? below is the constructor of my mediator class in which it creates an instance of the view it is communicating with and sends it to the stagemediator to add onto the stage.

:
public function StudentSearchMediator( viewComponent:Object )
        {

            // pass the viewComponent to the superclass where
            // it will be stored in the inherited viewComponent property
var stusearch = new StudentSearch();
stusearch.y = 20;
stusearch.x = 20;

            super( NAME, stusearch );
   
sendNotification( ApplicationFacade.ADD_TO_STAGE, stusearch );

            // Listen for events from the view component
            stusearch.addEventListener( StudentSearch.STUDENT_SELECTED, onStudentSelected );
           
        }

also on the super call what needs to be passed into the second parameter, the object the mediator is controlling or the object that is passed into the constructor, which in this case is the stage or root.

Thanks
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: July 24, 2008, 05:00:09 »

That's fine but you should wait until onRegister to send the notification.

Some Standard Version demos still do Facade access in the constructor, but this should be deferred until onRegister. The reason being if it starts a 'conversation', it can't respond until it is registered. This isn't yet covered in Best Practices but will be next edit.

-=Cliff>
Logged
Pages: [1]
Print