Hi,
I am working on using LiquidStage with Gaia Framework. However I am having some problems with accessing the LiquidStage instance from nested within swf's.
I know this is probably a similar problem to this viewtopic.php?f=3&t=2892 however I couldn't find a solution there.
Trace of Stage
[object Main] root1
[object SiteView] [siteView]
[object Sprite] BOTTOM
[object Loader] index
[object IndexPage] instance12
[object Sprite] MIDDLE
[object Loader] index_nav_photography_female
[object GalleryPage] instance22
[object Sprite] TOP
[object Loader] index_nav
[object NavPage] instance16
[object Sprite] PRELOADER
[object Loader] instance7
[object Preloader] instance8
They load in this order IndexPage -> NavPage -> GalleryPage
IndexPage.as
This is where I am instantiating the LiquidStage so it can be accessed later
The important part is in the init function.
package com.photogallery.pages
{
import com.gaiaframework.templates.AbstractPage;
import com.gaiaframework.events.*;
import com.gaiaframework.debug.*;
import com.gaiaframework.api.*;
import flash.display.*;
import flash.events.*;
import com.greensock.TweenMax;
import com.greensock.layout.*;
public class IndexPage extends AbstractPage
{
public var lStage:LiquidStage;
public function IndexPage()
{
super();
alpha = 0;
}
override public function transitionIn():void
{
super.transitionIn();
init();
TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
}
override public function transitionOut():void
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
private function init():void {
//Gaia.api.getWidth() and Gaia.api.getHeight() refers to the very original width and height
lStage = new LiquidStage(this.stage, Gaia.api.getWidth(), Gaia.api.getHeight(), Gaia.api.getWidth(), Gaia.api.getHeight());
}
}
}
GalleryPage.as
This is where I am trying to access the LiquidStage instance.
The important part is in the init function.
package com.photogallery.pages
{
import com.gaiaframework.templates.AbstractPage;
import com.gaiaframework.events.*;
import com.gaiaframework.debug.*;
import com.gaiaframework.api.*;
import flash.display.*;
import flash.events.*;
import com.greensock.TweenMax;
import com.greensock.layout.*;
public class GalleryPage extends AbstractPage
{
public var testMc1:MovieClip;
public var testMc2:MovieClip;
public function GalleryPage()
{
super();
alpha = 0;
}
override public function transitionIn():void
{
super.transitionIn();
init();
TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
}
override public function transitionOut():void
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
function init():void {
trace(this.stage); //outputs: [object Stage]
trace(LiquidStage.getByStage(this.stage)); //outputs: null
var ls = Gaia.api.getPage("index").content.lStage; //gets a direct reference to the liquidstage instance through the index page.
trace(ls); //outputs: [object LiquidStage]
trace(ls.stage); //outputs: [object Stage]
trace(LiquidStage.getByStage(ls.stage)); //outputs: null
ls.attach(testMc1, ls.TOP_LEFT); //does work
var area:LiquidArea = new LiquidArea(this, 50, 50, 100, 100, 0x313f19);
//var area:LiquidArea = new LiquidArea(this, 50, 50, 100, 100, 0x313f19, 0x313f19, 0, 0, 99999, 99999, true, ls); //throws: TypeError: Error #1034: Type Coercion failed: cannot convert com.greensock.layout::LiquidStage@2604f581 to com.greensock.layout.LiquidStage.
area.attach(testMc2); //has no effect but doesn't throw any errors
}
}
}
So the output of this is
[object Stage]
null
[object LiquidStage]
[object Stage]
null
Also this.stage == ls.stage
Also using this code
var ls:LiquidStage = Gaia.api.getPage("index").content.lStage;
instead of
var ls = Gaia.api.getPage("index").content.lStage;
Causes the following error TypeError: Error #1034: Type Coercion failed: cannot convert com.greensock.layout::LiquidStage@15f04581 to com.greensock.layout.LiquidStage.
I can't work out why LiquidStage.getByStage always returns null.
I hope that is clear I can send an example through with all the other code if you want but I have pasted all the relevants parts already.