Accessing the stage in Gaia Framework
Posted: June 14th, 2009 | Author: Liza | Filed under: As3, Flash, Uncategorized, cs3, cs4 | Tags: accessing stage, flash cs4, gaia framework, resizing stage |I have had alot of trouble trying to access the stage from Gaia Framework, but thanks to David, I’m finally getting the hang of it.
I needed to access the stage width (when resized) to create a a bar to sit behind the navigation on my site.
First I had to add this to the class constructor:
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
Then create the following 2 functions:
private function onAddedToStage(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stage.addEventListener(Event.RESIZE, onResize);
onResize();
}private function onResize(event:Event = null):void
{
navBackBar.width = stage.stageWidth;
navBackBar.x = 0 - ((stage.stageWidth - Gaia.api.getWidth()) / 2);
}
navBackBar is the name of the movieclip on the stage. You can see it behind the navigation on my site.
I just started learning Gaia myself (trying to remake my site with it) and ran into this same problem. I ended up just making a function to initialize everything then calling it from inside transitionIn().
private function init():void
{
stage.addEventListener(Event.RESIZE, onResize);
onResize();
}
override public function transitionIn():void
{
super.transitionIn();
init();
TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
}