Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
dmschenk

Liquid Area, Gaia and multiple backgrounds

Recommended Posts

I have a Gaia flash file that I'm trying to change backgrounds for each page. The background itself changes nicely but I'm having a problem getting the background to scale to the stage size. I'm trying to use Liquid Area to try and handle it and it does well with a single background but as soon as I introduced more my code choked..

Thanks

 

 package com.picturesite.pages
   {
   	import com.gaiaframework.api.*;
   	import com.gaiaframework.events.*;
   	import com.gaiaframework.templates.AbstractPage;
   	import com.greensock.TweenMax;
   	import com.greensock.easing.*;
   	import com.greensock.layout.*;

   	import flash.display.*;
   	import flash.events.*;

   	public class IndexPage extends AbstractPage
   	{	
   		public var bg1:MovieClip;
   		public var bg2:MovieClip;
   		public var bg3:MovieClip;
   		public var bg4:MovieClip;
   		public var bg5:MovieClip;
   		public var bg6:MovieClip;
   		public var newBG:MovieClip;
   		public var bBar_mc:MovieClip;	


   		var releaseGaia:Function = Gaia.api.afterTransitionOut(onAfterTransitionOut, true);

   		public function IndexPage()
   		{
   			super();
   			alpha = 0;

   		}
   		override public function transitionIn():void 
   		{
   			super.transitionIn();
   			bg2.visible=bg3.visible=bg4.visible=bg5.visible=bg6.visible=false;
   			TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});		

   			var ls:LiquidStage = new LiquidStage(this.stage, 960, 760, 960, 760);
   			var area:LiquidArea = new LiquidArea(this, 0, 0, 960, 760);
   			area.attach(newBG, ScaleMode.PROPORTIONAL_OUTSIDE);
   			ls.update();
   		}

   		override public function transitionOut():void 
   		{
   			super.transitionOut();
   			TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
   			Gaia.api.removeAfterTransitionOut(onAfterTransitionOut);
   		}

   		private function onAfterTransitionOut(e:GaiaEvent):void
   		{
   			var newBG:MovieClip;

   			switch(Gaia.api.getCurrentBranch())
   			{
   				case Pages.HOME :
   					newBG = bg1;
   					break;

   				case Pages.PACKAGES :
   					newBG = bg2;
   					break;

   				case Pages.PHOTOS_SAMPLES :
   					newBG = bg3;
   					break;

   				case Pages.VIDEOS_SAMPLES :
   					newBG = bg4;
   					break;

   				case Pages.TESTIMONIES :
   					newBG = bg5;
   					break;

   				case Pages.CONTACT :
   					newBG = bg6;
   					break;

   			}

   			TweenMax.allTo([bg1,bg2,bg3,bg4,bg5,bg6], .5, {autoAlpha:0});
   			TweenMax.to(newBG, .5, {alpha:1, onComplete:releaseGaia});	

   		}

   	}
   }

Link to comment
Share on other sites

I'm not much of a Gaia guy, but I wonder if the problem just has to do with the fact that you keep creating LiquidArea (and LiquidStage) instances and attaching the same object to them, but you never release() or destroy() the old instances, so you end up with a bunch of LiquidAreas/LiquidStages that are attempting to control the same object. Maybe try calling destroy() on the LiquidArea when you don't need it anymore.

Link to comment
Share on other sites

I gave the extra time and releasing shot but I didn't get a difference in the background.

The background is not resizing and filling the stage like it should. Even the very first background doesn't re-size.

 

Dave

Link to comment
Share on other sites

Sorry, Dave, I'm not sure how Gaia plays with it. Can you post an example FLA that demonstrates the issue? Please make it as simple as possible - no need to post your production files. Include any necessary support files too of course, including any gaia ActionScript classes. I can't really troubleshoot Gaia, though - I can only work on the LiquidStage/Area stuff.

Link to comment
Share on other sites

I still don't know the fix but I have isolated the problem somewhat. Liquid Area does not like the variable "newBG" coming from the switch statement.

If I replace newBG in this line "area.attach(newBG, ScaleMode.PROPORTIONAL_OUTSIDE);" with one of the other variables bg1, bg2... then it works fine..

Of course this ignores the switch.

I'll see if I can put a single file together to simulate the problem .... doing it with Gaia will still require lots of files.

Link to comment
Share on other sites

Oh, that's because you made a newBG local variable that only exists inside onAfterTransitionOut(), which takes precedence over the class-level one you define. So when you set newBG = [whatever] inside onAfterTransitionOut(), it is setting the LOCAL variable, not the class-level one.

 

Remove that local variable instantiation and you should be fine.

var newBG:MovieClip;

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×