Share Posted May 23, 2010 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. Link to comment Share on other sites More sharing options...
Share Posted May 23, 2010 Are you subloading from another domain? Have you used a LoaderContext to ensure that the ApplicationDomain is currentDomain and same with SecurityDomain? If not, I believe Flash won't let ActionScript mix between the parent and child. Link to comment Share on other sites More sharing options...
Share Posted May 23, 2010 having the same "issue" with similar "scenario" Liquidstage works great, Liquidarea not. Link to comment Share on other sites More sharing options...
Author Share Posted May 24, 2010 Wow thank you so much I didn't even think to check for the application domain. I think it is fixed now. The output is now [object Stage] [object LiquidStage] [object LiquidStage] [object Stage] [object LiquidStage] The problem was the domain attribute (http://www.gaiaflashframework.com/wiki/ ... S3_Only.29) in the site.xml it is set to null by default. So I changed it to current. Example for future reference: Link to comment Share on other sites More sharing options...
Author Share Posted May 24, 2010 Also I forgot to mention changing the domain attribute fixed the problem I had with LiquidArea not doing anything. So bebber this should fix your problem too. Link to comment Share on other sites More sharing options...
Share Posted May 24, 2010 wow love this forum thank you so much people Link to comment Share on other sites More sharing options...
Share Posted May 25, 2010 I would advise against using the "current" application domain unless needed. This issue (as many application domain issues in Gaia or similar swf component bases sites) is easily solved by compiling the class definitions in the main.swf, doing something like new LiquidStage or similar within the Main class. Link to comment Share on other sites More sharing options...
Author Share Posted May 25, 2010 Ok thanks for the info uramis instantiating LiquidStage in the onAddedToStage function of main.as also worked. Thanks. Link to comment Share on other sites More sharing options...
Share Posted August 3, 2010 HI all I'm tryng to make something similar istantiate the liquidstage in main.swf in GAIA (i put all the code but just look at two lines) package { import com.gaiaframework.core.GaiaMain; import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.events.Event; import com.greensock.layout.*; public class Main extends GaiaMain { public var myLiquidStage:LiquidStage; public function Main() { super(); siteXML = "xml/site.xml"; } override protected function onAddedToStage(event:Event):void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; super.onAddedToStage(event); // HERE i ISTANTIATE THE LIQUIDSTAGE CLASS myLiquidStage= new LiquidStage(this.stage, 960, 500, 960, 500); } } } but then when i try to acces it on nav.swf i get an error (impossible to find the property myliquidStage on pages.IndexPage .. (why indexpage gaia??) code on nav.swf private function initAktivo():void { var ls = Gaia.api.getPage("main").content.myLiquidStage; trace(ls); } Link to comment Share on other sites More sharing options...
Share Posted August 4, 2010 Sounds like a Gaia question - have you tried their forums? Unfortunately I'm not a Gaia expert. Link to comment Share on other sites More sharing options...
Share Posted November 25, 2010 Sorry to dig up an old thread. But since asking starting this thread I have made a few sites with Gaia and Liquidstage. This is how I have been using it without any problems. Main.as ... import com.greensock.layout.*; public class Main extends GaiaMain { public function Main() { super(); siteXML = "xml/site.xml"; } override protected function onAddedToStage(event:Event):void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; super.onAddedToStage(event); var ls:LiquidStage = new LiquidStage(this.stage, 1024, 768); } } Then when you need to get a reference to liquidstage just use: HomePage.as ... import com.greensock.layout.*; public class HomePage extends AbstractPage { private var ls:LiquidStage; public function HomePage() { super(); alpha = 0; } override public function transitionIn():void { super.transitionIn(); ls = LiquidStage.getByStage(stage); TweenMax.to(this, 0.3, {alpha:1, delay:1, onComplete:transitionInComplete}); } ... Also note for any gaia users I had some strange problems with liquidstage with one project and having indexFirst="true" but I didn't get around to finding out why. So if you have any problems you might want to try seeing if you have indexFirst set to true. Link to comment Share on other sites More sharing options...
Share Posted January 19, 2011 Galbraith, Thanks for your code - it worked perfectly... I'd like to add one point that might save others hours of troubleshooting (unless I'm the only one who would miss this) UNCHECK THE FOLLOWING: "Center X" "Center Y" in the Gaia Project Panel Not doing so resulted in my pinned liquidstage objects flying off the screen when I resized. Like Galbraith shows there is no need for global static variables so you can use his code verbatim. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now