Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-11-2007, 08:49 PM   #1
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 837
Default accessing the stage from a uicomponent

So I'm building a UIComponent that I want to be able to access the stage with. Only problem though, is due to the asynchronous approach to initializing ui components in flex, accessing the stage results in a null value in many of the different places I've checked.

Can anyone tell me at which point in the process can I actually access the stage? It's for setting up an event listener, so I'd want it to be part of initialization.
Assertnfailure is offline   Reply With Quote
Old 03-11-2007, 08:51 PM   #2
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

Event.ON_ADDED_TO_STAGE
Tink is offline   Reply With Quote
Old 03-11-2007, 09:05 PM   #3
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 837
Default

I don't see that as a constant for event. I see Event.ADDED, but that still gets me null. I'm thinking its because its added to its parent before its parent is added to the display list.

EDIT: Ok, I did find a solution.....not sure if it's the best solution though:
PHP Code:
public function MyComponent(){
    
this.addEventListener(FlexEvent.CREATION_COMPLETEcreationCompleteHandler);
}
    
private function 
init():void{
    
trace(this.stage);
}

private function 
creationCompleteHandler(evt:FlexEvent):void{
    
this.callLater(init);


Last edited by Assertnfailure; 03-11-2007 at 09:12 PM.
Assertnfailure is offline   Reply With Quote
Old 03-11-2007, 09:35 PM   #4
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

Event.ON_ADDED_TO_STAGE was added in player 9.0.28.0 and Flex 2.0.1.
Tink is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing the stage inside a constructor Daedalus ActionScript 3.0 8 01-09-2007 08:50 PM
Creation-time Application Event: Stage Object Available astgtciv Flex 2, 3 & 4 6 07-29-2006 04:01 PM
Need help with timeline code! GaJl ActionScript 2.0 2 02-28-2006 02:09 PM
dynamically resizing the stage for a .flv player? ykol20 ActionScript 2.0 2 01-03-2005 02:38 PM
Stage Language in Strings Panel flashch ActionScript 2.0 0 08-23-2004 11:35 AM


All times are GMT. The time now is 07:52 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.