The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 14 of 14

Thread: swfaddress question

  1. #1
    132
    posts
    Registered User

    swfaddress question

    so, I'm being asked to incorporate swfaddress into a website.

    i'm worried I might have to change the entire way the website works.

    for example. the site is set up with a document class that loads a header footer and content class. then the content class loads an intro. when the intro is done it automatically loads in the home page. then when any buttons in the header or footer are clicked, they dispatch a custom event, it unloads the current content and loads in a new class (usually including some content from the flash ide library.. pretty standard really.. just using some simple tweens for animation.

    so my question is, how will swfaddress know what to load when someone puts the specific adress in.. ie: www.whatever.com/about.. how is it going to know how to get to that point in the code without going through all of it? is it possible? do i have to set up the site a specific way? it almost seems as if i'd have to make separate swfs for each page or something. if anyone could give me like a quick breakdown of what i'd need to keep in mind to use swfaddress i'd really appreciate it..

    thanks a lot

  2. #2
    Your event handlers shouldn't be doing anything but amending the SWFAddress value.

    For example:

    Code:
    		private function doMenuDown (e:MouseEvent):void
    		{
    			SWFAddress.setValue (UserObject.ConfigData.SECTION.@DEEP_LINK_TITLE[e.currentTarget.id]);
    		}
    e.currentTarget.id is an array position that I grab from my XML doc.

    In this case I pretty much have an XML doc that looks like

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
    		<SECTION ID = "0" COLOR = "0x37C4EF" DEEP_LINK_TITLE = "home" IMAGE = "../images/home.jpg" DATA_FILE = "../xml/home.xml" />
    		<SECTION ID = "1" COLOR = "0xED1568" DEEP_LINK_TITLE = "about" IMAGE = "../images/about.jpg" DATA_FILE = "../xml/about.xml" />
    		
    </ROOT>
    I then have a listener registered to any changes of the SWFAddress value. If zero is returned I know the user clicked home, if 1 is returned I know they clicked about.

    My handler looks something like

    Code:
    private function setSection (e:Event):void
    		{
    			var urlValue = SWFAddress.getValue().toLowerCase();
    			if (urlValue != "/")
    			{
    				for (var i:int = 0; i < UserObject.ConfigData.SECTION.@ID.length(); i++)
    				{
    					if ("/" +  UserObject.ConfigData.SECTION.@DEEP_LINK_TITLE[i].toLowerCase() + "/" == urlValue)
    					{
    
    						TweenMax.to (_menuContainer.getChildByName("menuitem" + i), menuSpeed, {width:menuExpandedWidth, ease:Sine.easeOut});
    						TweenMax.to (_menuContainer.getChildByName("menuitemText" + i), menuSpeed, {x:-220, ease:Sine.easeOut});
    						TweenMax.to (_sectionContainer, 1.85, {y:-275*i ,ease:Elastic.easeInOut});
    					}
    					else
    					{
    						TweenMax.to (_menuContainer.getChildByName("menuitem" + i), menuSpeed, {width:menuContractedWidth, ease:Sine.easeOut});
    						TweenMax.to (_menuContainer.getChildByName("menuitemText" + i), menuSpeed, {x:0, ease:Sine.easeOut});
    					}
    				}
    			}
    		}
    So that will scroll my sections to the right x and y positions as well as handle my menu transitions. My section data is already initted so I don't have to worry that. In your case it seems like you will be adding and removing children but that same concept should apply to you.

    Does that make sense? I wrote this quickly so I can explain further if needed.

  3. #3
    132
    posts
    Registered User
    yeah.. i mean that makes sense.. i'm going to be looking into it further all day today.. i guess what I don't get, is how someone could just open a fresh browser window and type in a specific address.. "mysite.com/about" for example.. and swfaddress knows how to get to that page in my actionscript without going through the rest of the code. like the intro.

    i'll update you once i've began trying to implement it.. but for now, maybe so you can get an idea of how I'm accomplishing page changes.. here is some code.. but i warn you.. i've been teaching myself anything i know about actionscript, so go easy.. i'm sure i'm making a lot of mistakes, only because i don't know the proper way. so any tips are appreciated really.

    this is the document class
    Code:
    package
    {
    	import com.Pages.Pages;
    	import com.parts.Footer;
    	import com.parts.Header;
    	
    	import flash.display.MovieClip;
    	import flash.display.StageAlign;
    	import flash.display.StageScaleMode;
    	import flash.events.Event;
    
    	public class SisuMarcom extends MovieClip
    	{
    		private var _header:Header;
    		private var _footer:Footer;
    		private var _contentBox:ContentBox;
    		
    		public var _sWidth:Number;
    		public var _sHeight:Number;
    		
    		public function SisuMarcom(){
    			trace("DC");
    			addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 0, true);	
    		}
    		
    		private function addedToStage(e:Event):void{
    			
    			_sWidth = stage.stageWidth;
    			_sHeight = stage.stageHeight;
    			stage.scaleMode = StageScaleMode.NO_SCALE;
    			stage.align = StageAlign.TOP_LEFT;
    			init();
    			
    		}
    		
    		private function init():void{
    
    			_header = new Header();
    			addChild(_header);
    			
    			_footer = new Footer();
    			addChild(_footer);
    			
    			_contentBox = new ContentBox();
    			addChild(_contentBox);
    				
    		}
    	
    	}
    	
    }
    and then the content class which does the page changing.. i know it's rough..
    Code:
    package com.Pages
    {
    	import com.rSavage.Events.PageEvent;
    	
    	
    	import flash.display.Sprite;
    	import flash.events.*;
    	
    	import gs.*;
    	import gs.easing.*;
    	import gs.events.*;
    	import gs.utils.*;
    
    	public class ContentBox extends Sprite{
    		
    		
    		private var _sWidth:Number;
    		private var _sHeight:Number;
    		
    		private var _page:String;
    		private var _activePage:String;
    		private var _lastActive:String;
    		//private var _pages:Array;
    		
    		private var _intro:IntroPage;
    		private var _contactPage:cp;
    		private var _homePage:hp;
    		private var _premiumPage:pp;
    		private var _reelPage:rp;
    		private var _schoolPage:sp;
    		private var _yesPage:yp;
    		private var _progPage:prp;
    		private var _sisuPage:ssp;
    		private var _createPage:crp;
    		private var _textPage:it;
    		private var _itActive:Boolean;
    		
    		
    		public function ContentBox(){
    			
    			addEventListener(Event.ADDED_TO_STAGE, added, false, 0, true);
    			//_pages = new Array();
    			super();
    		}
    		
    		private function added(e:Event):void{
    			stage.addEventListener(Event.RESIZE, resize, false, 0, true);
    			stage.addEventListener(PageEvent.PAGE_CHANGE, pageChange);
    			_sWidth = stage.stageWidth;
    			_sHeight = stage.stageHeight;
    			//this.x = _sWidth>>1;
    			//this.y = _sHeight>>1;	
    			resize(null);
    			
    			
    			_lastActive = "start";
    			
    			_activePage = "start";
    			
    			_intro = new IntroPage();
    			addChild(_intro);
    			
    		}
    		
    		private function resize(e:Event):void{
    			
    			_sWidth = stage.stageWidth;
    			_sHeight = stage.stageHeight;
    			//TweenMax.to(this, 1, {x:_sWidth>>1, y:_sHeight>>1, ease:Strong.easeInOut});
    
    		}
    		
    		private function pageChange(e:PageEvent):void{
    			_page = e.page;
    			trace("pageChange " +_page);
    			loadPage();
    		}
    		
    		private function loadPage():void{
    			
    			
    			
    			switch (_page){
    				case "home_btn":
    				case "timerComplete":
    				if(_activePage!="logo_btn" &&_activePage!="home_btn"){
    					pageAway();
    					makeHome();
    				}
    				
    				break;
    				case "SeeSoo_btn":
    				
    				if(_activePage!="SeeSoo_btn"){
    					pageAway();
    					makeSisu();
    				}
    				
    				break;
    				case "yesWeCan_btn":
    				if(_activePage!="yesWeCan_btn"){
    					pageAway();
    					makeYes();
    				}
    				
    				break;
    				case "progress_btn":
    				if(_activePage!="progress_btn"){
    					pageAway();
    					makeProgress();
    				}
    				
    				break;
    				case "schooled_btn":
    				if(_activePage!="schooled_btn"){
    					pageAway();
    					makeSchool();
    				}
    				
    				break;
    				case "premium_btn":
    				if(_activePage!="premium_btn"){
    					pageAway();
    					makePremium();
    				}
    				
    				break;
    				case "ftp_btn":
    				
    					
    				
    				
    				break;
    				case "contact_btn":
    				case "brand_btn":
    				if(_activePage!="contact_btn"){
    					pageAway();
    					makeContact();
    				
    				}
    				
    				break;
    				case "logo_btn":
    				if(_activePage!="logo_btn" && _activePage!="home_btn"){
    					pageAway();
    					makeHome();
    					
    				}
    				
    				break;
    				case "reel_btn":
    				case "creativity_btn":
    				case "school_reel":
    				if(_activePage!="reel_btn"){
    					pageAway();
    					makeReel();
    					
    					
    					
    				}	
    				break;
    				case "think_btn":
    					
    				
    				
    				break;
    			}
    			
    				
    		}
    
    
    
    		private function pageAway():void{
    			
    				switch (_activePage){
    					case "home_btn":
    						TweenMax.to(_homePage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "SeeSoo_btn":
    						TweenMax.to(_sisuPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "yesWeCan_btn":
    						TweenMax.to(_yesPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "progress_btn":
    						TweenMax.to(_progPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "schooled_btn":
    						TweenMax.to(_schoolPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "premium_btn":
    						TweenMax.to(_premiumPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "creativity_btn":
    						TweenMax.to(_createPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "contact_btn":
    						TweenMax.to(_contactPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "logo_btn":
    						TweenMax.to(_homePage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "reel_btn":
    						
    						TweenMax.to(_reelPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "start":
    						TweenMax.to(_intro, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    						//_intro.tweenOut();
    					break;
    				}
    			
    		}
    
    		
    		private function makeHome():void{
    			_homePage = new hp();
    			addChild(_homePage);
    			_lastActive = _activePage;
    			_activePage = "home_btn";
    			makeText();	
    		}
    		
    		private function makeLogo():void{
    			_homePage = new hp();
    			addChild(_homePage);
    			_lastActive = _activePage;
    			_activePage = "logo_btn";
    			makeText();	
    		}
    		
    		private function makeContact():void{
    			_contactPage = new cp();
    			addChild(_contactPage);
    			_lastActive = _activePage;
    			_activePage = "contact_btn";
    			makeText();	
    		}
    		
    		private function makeSisu():void{
    			_sisuPage = new ssp();
    			addChild(_sisuPage);
    			_lastActive = _activePage;
    			_activePage = "SeeSoo_btn";
    			makeText();	
    		}
    		
    		private function makeYes():void{
    			_yesPage = new yp();
    			addChild(_yesPage);
    			_lastActive = _activePage;
    			_activePage = "yesWeCan_btn";
    			makeText();	
    		}
    		
    		private function makePremium():void{
    			_premiumPage = new pp();
    			addChild(_premiumPage);
    			_lastActive = _activePage;
    			_activePage = "premium_btn";
    			makeText();	
    		}
    		
    		private function makeProgress():void{
    			_progPage = new prp();
    			addChild(_progPage);
    			_lastActive = _activePage;
    			_activePage = "progress_btn";
    			makeText();	
    		}
    		
    		private function makeSchool():void{
    			_schoolPage = new sp();
    			addChild(_schoolPage);
    			_lastActive = _activePage;
    			_activePage = "schooled_btn";
    			makeText();	
    		}
    		
    		
    		private function makeCreate():void{
    			_createPage = new crp();
    			addChild(_createPage);
    			
    		}
    		
    		private function makeReel():void{
    			_reelPage = new rp();
    			addChild(_reelPage);
    			_lastActive = _activePage;
    			_activePage = "reel_btn";
    			makeText();	
    		}
    		
    		private function makeText():void{
    			trace("last active = "+_lastActive);
    			trace("page going to = "+_activePage);
    			switch (_lastActive){
    				case "premium_btn":
    				case "creativity_btn":
    				case "contact_btn":
    				case "reel_btn":
    				case "start":
    					switch (_activePage){
    					case "home_btn":
    					case "SeeSoo_btn":
    					case "yesWeCan_btn":
    					case "progress_btn":
    					case "schooled_btn":
    					case "logo_btn":
    						_textPage = new it();
    						addChild(_textPage);
    						_itActive = true;
    						trace("texxxxxxt = " +_textPage);
    					break;
    					}
    				break;
    				case "home_btn":
    				case "SeeSoo_btn":
    				case "yesWeCan_btn":
    				case "progress_btn":
    				case "schooled_btn":
    				case "logo_btn":
    					switch (_activePage){
    					case "premium_btn":
    					case "creativity_btn":
    					case "contact_btn":
    					case "reel_btn":
    						TweenMax.to(_textPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:itremove});
    					break;
    					}
    				break;
    			}
    		}
    		
    		
    		public function removeIt():void{
    			switch (_lastActive){
    				case "home_btn":
    					_homePage.remove();
    					removeChild(_homePage);
    					_homePage = null;
    				break;
    				case "SeeSoo_btn":
    					_sisuPage.remove();
    					removeChild(_sisuPage);
    					_sisuPage = null;
    				break;
    				case "yesWeCan_btn":
    					_yesPage.remove();
    					removeChild(_yesPage);
    					_yesPage = null;
    				break;
    				case "progress_btn":
    					_progPage.remove();
    					removeChild(_progPage);
    					_progPage = null;
    				break;
    				case "schooled_btn":
    					_schoolPage.remove();
    					removeChild(_schoolPage);
    					_schoolPage = null;
    				break;
    				case "premium_btn":
    					_premiumPage.remove();
    					removeChild(_premiumPage);
    					_premiumPage = null;
    				break;
    				case "creativity_btn":
    					_createPage.remove();
    					removeChild(_createPage);
    					_createPage = null;
    				break;
    				case "contact_btn":
    					_contactPage.remove();
    					removeChild(_contactPage);
    					_contactPage = null;
    				
    				break;
    				case "logo_btn":
    					_homePage.remove();
    					removeChild(_homePage);
    					_homePage = null;
    				break;
    				case "reel_btn":
    					_reelPage.remove();
    					removeChild(_reelPage);
    					_reelPage = null;
    				break;
    				case "start":
    					_intro.remove();
    					removeChild(_intro);
    					_intro = null;
    				break;
    				
    			}
    			
    			
    			
    		}
    		
    		private function itremove():void{
    			_textPage.remove();
    			removeChild(_textPage);
    			_textPage = null;
    		}
    	}
    }

  4. #4
    The key to swfaddress is that listener
    Code:
    SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleSWFAddress);
    There you check what current deeplink value is and run what needed.

    The swfaddress syntax is somesite.com/#/deep/link
    the # (hash) is essential, because it prevents reloading of page.
    You have only one movie and navigating in it changes the address in browser, but do not navigate away. You can even use back/forward buttons, which do won't reload the page too.
    The address also can be used to go directly to some place, ex. a picture.

    You can see it here: http://jevansmedia.com/
    people category: http://jevansmedia.com/#/People/
    a man with a guitar: http://jevansmedia.com/#/People/2/
    some cloves: http://jevansmedia.com/#/Things/12/
    contact page: http://jevansmedia.com/#/Contact/

  5. #5
    132
    posts
    Registered User
    thanks.. i just thought for some reason it wouldn't work with my layout.. i'm trying now

  6. #6
    There's no reason for your removeIt function to have all those cases. You can easily have an array of movies clips then using something like the above method I posted it doesn't matter what was clicked your function will know what to do.

    Sorry I forgot to add the event listener for swfaddress, but when that happens that's when you call your removeIt function.

  7. #7
    132
    posts
    Registered User
    ok.. so... I've got the swfaddress handler controlling all my navigation, and it's working right when I compile in flash.. but it seems i can't get it to work in browser.. as in.. I don't think it's even "connecting" with the swfaddress in javascript.. i know it's a problem with my html.. i'm horrible at java.. is there some kind of id tag i'm missing or something? thanks again..


    HTML Code:
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    	<head>
    		<title>Test</title>
            <style type="text/css">
    		body 
    		{
    			margin-left: 0px;
    			margin-top: 0px;
    			margin-right: 0px;
    			margin-bottom: 0px;
    		}
    		
    		html 
    		{
    			height: 100%;
    			overflow: auto;
    		}
    		
    		/*#flashDiv {
    			position: absolute;
    			top: 0px;
    			left: 0px;
    			height: 100%;
    			width: 100%;
    		}*/
            </style></head>
            
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<script type="text/javascript" src="swfobject.js"></script>
            <script type="text/javascript" src="SWFAddress.js"></script>
            <script type="text/javascript" src="SWFAddressEvent.js"></script>
    		<script type="text/javascript">
    		
    			
    			var so = new SWFObject('sisuMain.swf', 'main', '1024', '768', '9');
                so.useExpressInstall('expressinstall.swf');
                so.addParam('menu', 'false');            
    			so.addParam('salign', 'tl');
    			so.addParam("allowFullScreen", "true");
    			so.addParam("wmode", "window");
    			so.addParam("scale", "noscale")
                so.write('main');
    			
    		</script>
    	</head>
    	<body>
    		<div id="flashDiv">
    			<a href="http://www.adobe.com/go/getflashplayer">
    				<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    			</a>
    		</div>
    	</body>
    </html>
    i'm just getting the "upgrade to flash" badge..

  8. #8
    yes, you're missing something, the script access:
    var params = { allowFullScreen:'true', allowNetworking:'all', allowScriptAccess:'always' };

    but i have a question, why are you not using the latest swfobject?
    also, are you shure is SWFAddress.js and not swfaddress.js?

  9. #9
    132
    posts
    Registered User
    when i download swfaddress I'm getting the files SWFAddress and not swfaddress.. so i just used it how they spelt it. and how can you tell i'm not using the latest swfobject? anyhow I just went and got the newest version.. and the generator.. I'll try that.. but I was under the impression I'd need to somehow pass the id of the flash movie to swfaddress somehow.

  10. #10
    132
    posts
    Registered User
    ok.. so.. yeah.. I was making a foolish mistake and using the improper swfaddress file. you were right.. thanks.. i am a moron. it's working now and i just have to tweak it into shape..

  11. #11
    also, i don't see any swfaddressevent.js in version 2.1 or 2.2, maybe you're using again an older version?
    i think that swfaddress knows about the id from swfobject

  12. #12
    132
    posts
    Registered User
    yeah.. i didn't see any swfaddressevent.js files in all the samples.. so scrapped it when I got the newest versions.. and it's working properly now.. I'm currently incorporating my check initial page function.,. and then i'll post my entire thing, just incase anyone wants a simple, flawed example..

  13. #13
    132
    posts
    Registered User
    ok.. wait.. one more question.. whenever i try to go directly to a certain page, i'm getting the sounds of the intro page.. but I have it so that the intro page is only created if SWFAddress.getValue() is "/".. so.. my question is.. when going directly to a specific page on the site, the swf is ran, and, i have a check page function to see where it should go... but the thing is.. it doesn't do it the first time, for example.. i type in whatever.com/#/home and it comes up.. on the homepage.. with no intro animation.. or intro animation sounds... but now that the swf is already loaded, if i type in whatever.com/#/premiums, it goes to the premiums page, but also plays the sounds of the intro animation, which it created for some reason... sheet..

    Code:
    package com.Pages
    {
    	import com.asual.swfaddress.SWFAddress;
    	import com.asual.swfaddress.SWFAddressEvent;
    	
    	
    	import flash.display.Sprite;
    	import flash.events.*;
    	
    	import gs.*;
    	import gs.easing.*;
    	import gs.events.*;
    	import gs.utils.*;			
    
    	public class ContentBox extends Sprite{
    		
    		private var _sWidth:Number;
    		private var _sHeight:Number;
    		
    		private var _page:String = "/";
    		private var _activePage:String;
    		private var _lastActive:String;
    		//private var _pages:Array;
    		
    		private var _intro:IntroPage;
    		private var _contactPage:cp;
    		private var _homePage:hp;
    		private var _premiumPage:pp;
    		private var _reelPage:rp;
    		private var _schoolPage:sp;
    		private var _yesPage:yp;
    		private var _progPage:prp;
    		private var _sisuPage:ssp;
    		private var _createPage:crp;
    		private var _textPage:it;
    		private var _itActive:Boolean;
    		private var initial:String;
    		
    		public function ContentBox(){
    			
    			addEventListener(Event.ADDED_TO_STAGE, added, false, 0, true);
    			//_pages = new Array();
    			super();
    		}
    		
    		private function added(e:Event):void{
    			
    			stage.addEventListener(Event.RESIZE, resize, false, 0, true);
    			stage.addEventListener(PageEvent.PAGE_CHANGE, pageChange);
    			SWFAddress.addEventListener(SWFAddressEvent.CHANGE, SWFAddressChange);
    			_sWidth = stage.stageWidth;
    			_sHeight = stage.stageHeight;
    			resize(null);
    			
    		//	_lastActive = "start";
    		//	_activePage = "start";
    			
    			initial = SWFAddress.getValue();
    			checkPage(initial);
    			
    			
    			
    			
    		}
    		
    		private function checkPage(page:String):void{
    			trace("initial = "+page);
    			if(page == "/"){ 
    				_intro = new IntroPage();
    				addChild(_intro);
    				
    				_activePage = "start";
    				_lastActive = "start";
    			}
    			
    			switch (page){
    				case "/home":
    				case "/logo_btn":
    					SWFAddress.setValue("home");
    				break;
    				case "/seesoo":
    					SWFAddress.setValue("seesoo");
    				break;
    				case "/yeswecan":
    					SWFAddress.setValue("yeswecan");
    				break;
    				case "/progress":
    					SWFAddress.setValue("progress");
    				break;
    				case "/yandf":
    					SWFAddress.setValue("yandf");
    				break;
    				case "/premiums":
    					SWFAddress.setValue("premiums");
    				break;
    				case "/contact":
    					SWFAddress.setValue("contact");
    				break;
    				case "/reel":
    					SWFAddress.setValue("reel");
    				break;
    				case "/":
    					
    				break;
    			}
    			
    		}
    		
    		
    		private function resize(e:Event):void{
    			
    			_sWidth = stage.stageWidth;
    			_sHeight = stage.stageHeight;
    			//TweenMax.to(this, 1, {x:_sWidth>>1, y:_sHeight>>1, ease:Strong.easeInOut});
    
    		}
    		
    		private function pageChange(e:PageEvent):void{
    			_page = e.page;
    			//trace("pageChange " +_page);
    			switch (_page){
    				case "home_btn":
    				case "logo_btn":
    				case "timerComplete":
    					if(_activePage!="logo_btn" && _activePage!="home_btn"){
    					SWFAddress.setValue("home");
    					trace("swf address = "+SWFAddress.getValue());
    					}
    				break;
    				case "SeeSoo_btn":
    					if(_activePage!="SeeSoo_btn"){
    					SWFAddress.setValue("seesoo");
    					}
    				
    				break;
    				case "yesWeCan_btn":
    					if(_activePage!="yesWeCan_btn"){
    					SWFAddress.setValue("yeswecan");
    					}
    			
    				break;
    				case "progress_btn":
    					if(_activePage!="progress_btn"){
    					SWFAddress.setValue("progress");
    					}
    				
    				break;
    				case "schooled_btn":
    					if(_activePage!="schooled_btn"){
    					SWFAddress.setValue("yandf");
    					}
    				
    				break;
    				case "premium_btn":
    					if(_activePage!="premium_btn"){
    					SWFAddress.setValue("premiums");
    					}
    				
    				break;
    				case "ftp_btn":
    					
    			
    				break;
    				case "contact_btn":
    				case "brand_btn":
    					if(_activePage!="contact_btn" && _activePage!="brand_btn"){
    					SWFAddress.setValue("contact");
    					}
    				break;
    				case "reel_btn":
    				case "creativity_btn":
    				case "school_reel":
    					if(_activePage!="reel_btn"){
    					SWFAddress.setValue("reel");
    					}
    					
    				break;
    				case "think_btn":
    					
    				
    				break;
    			}
    			
    			//loadPage();
    		}
    		
    		private function SWFAddressChange(e:SWFAddressEvent):void{
    			trace("value = "+e.value);
    			
    			switch (SWFAddress.getValue()){
    				case "/home":
    				case "/logo_btn":
    					pageAway();
    					makeHome();
    					//SWFAddress.setTitle("");
    				
    				break;
    				case "/seesoo":
    					pageAway();
    					makeSisu();
    				
    				
    				
    				break;
    				case "/yeswecan":
    					pageAway();
    					makeYes();
    					
    				break;
    				case "/progress":
    				
    					pageAway();
    					makeProgress();
    				
    				
    				break;
    				case "/yandf":
    				
    					pageAway();
    					makeSchool();
    				
    				
    				break;
    				case "/premiums":
    					pageAway();
    					makePremium();
    				
    				
    				break;
    				case "/contact":
    					pageAway();
    					makeContact();
    				
    				break;
    				case "/reel":
    				
    					pageAway();
    					makeReel();
    				break;
    				
    			}
    		}
    		
    		private function loadPage():void{
    			
    		}
    
    		private function pageAway():void{
    			
    				switch (_activePage){
    					case "home_btn":
    						TweenMax.to(_homePage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "SeeSoo_btn":
    						TweenMax.to(_sisuPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "yesWeCan_btn":
    						TweenMax.to(_yesPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "progress_btn":
    						TweenMax.to(_progPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "schooled_btn":
    						TweenMax.to(_schoolPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "premium_btn":
    						TweenMax.to(_premiumPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "creativity_btn":
    						TweenMax.to(_createPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "contact_btn":
    						TweenMax.to(_contactPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "logo_btn":
    						TweenMax.to(_homePage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "reel_btn":
    						
    						TweenMax.to(_reelPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    					break;
    					case "start":
    						TweenMax.to(_intro, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:removeIt});
    						//_intro.tweenOut();
    					break;
    				}
    		}
    		
    		private function makeHome():void{
    			_homePage = new hp();
    			addChild(_homePage);
    			_lastActive = _activePage;
    			_activePage = "home_btn";
    			makeText();	
    		}
    		
    		private function makeLogo():void{
    			_homePage = new hp();
    			addChild(_homePage);
    			_lastActive = _activePage;
    			_activePage = "logo_btn";
    			makeText();	
    		}
    		
    		private function makeContact():void{
    			_contactPage = new cp();
    			addChild(_contactPage);
    			_lastActive = _activePage;
    			_activePage = "contact_btn";
    			makeText();	
    		}
    		
    		private function makeSisu():void{
    			_sisuPage = new ssp();
    			addChild(_sisuPage);
    			_lastActive = _activePage;
    			_activePage = "SeeSoo_btn";
    			makeText();	
    		}
    		
    		private function makeYes():void{
    			_yesPage = new yp();
    			addChild(_yesPage);
    			_lastActive = _activePage;
    			_activePage = "yesWeCan_btn";
    			makeText();	
    		}
    		
    		private function makePremium():void{
    			_premiumPage = new pp();
    			addChild(_premiumPage);
    			_lastActive = _activePage;
    			_activePage = "premium_btn";
    			makeText();	
    		}
    		
    		private function makeProgress():void{
    			_progPage = new prp();
    			addChild(_progPage);
    			_lastActive = _activePage;
    			_activePage = "progress_btn";
    			makeText();	
    		}
    		
    		private function makeSchool():void{
    			_schoolPage = new sp();
    			addChild(_schoolPage);
    			_lastActive = _activePage;
    			_activePage = "schooled_btn";
    			makeText();	
    		}
    		
    		private function makeReel():void{
    			_reelPage = new rp();
    			addChild(_reelPage);
    			_lastActive = _activePage;
    			_activePage = "reel_btn";
    			makeText();	
    		}
    		
    		private function makeText():void{
    			trace("last active = "+_lastActive);
    			trace("page going to = "+_activePage);
    			switch (_lastActive){
    				case "premium_btn":
    				case "creativity_btn":
    				case "contact_btn":
    				case "reel_btn":
    				case "start":
    					switch (_activePage){
    					case "home_btn":
    					case "SeeSoo_btn":
    					case "yesWeCan_btn":
    					case "progress_btn":
    					case "schooled_btn":
    					case "logo_btn":
    						_textPage = new it();
    						addChild(_textPage);
    						_itActive = true;
    						trace("texxxxxxt = " +_textPage);
    					break;
    					}
    				break;
    				case "home_btn":
    				case "SeeSoo_btn":
    				case "yesWeCan_btn":
    				case "progress_btn":
    				case "schooled_btn":
    				case "logo_btn":
    					switch (_activePage){
    					case "premium_btn":
    					case "creativity_btn":
    					case "contact_btn":
    					case "reel_btn":
    						TweenMax.to(_textPage, .5, {blurFilter:{blurX:10, blurY:10, quality:3}, scaleX:.25, scaleY:.25, alpha:0, ease:Quad.easeOut, overwrite:2, onComplete:itremove});
    					break;
    					}
    				break;
    			}
    		}
    		
    		
    		public function removeIt():void{
    			switch (_lastActive){
    				case "home_btn":
    					_homePage.remove();
    					removeChild(_homePage);
    					_homePage = null;
    				break;
    				case "SeeSoo_btn":
    					_sisuPage.remove();
    					removeChild(_sisuPage);
    					_sisuPage = null;
    				break;
    				case "yesWeCan_btn":
    					_yesPage.remove();
    					removeChild(_yesPage);
    					_yesPage = null;
    				break;
    				case "progress_btn":
    					_progPage.remove();
    					removeChild(_progPage);
    					_progPage = null;
    				break;
    				case "schooled_btn":
    					_schoolPage.remove();
    					removeChild(_schoolPage);
    					_schoolPage = null;
    				break;
    				case "premium_btn":
    					_premiumPage.remove();
    					removeChild(_premiumPage);
    					_premiumPage = null;
    				break;
    				case "creativity_btn":
    					_createPage.remove();
    					removeChild(_createPage);
    					_createPage = null;
    				break;
    				case "contact_btn":
    					_contactPage.remove();
    					removeChild(_contactPage);
    					_contactPage = null;
    				
    				break;
    				case "logo_btn":
    					_homePage.remove();
    					removeChild(_homePage);
    					_homePage = null;
    				break;
    				case "reel_btn":
    					_reelPage.remove();
    					removeChild(_reelPage);
    					_reelPage = null;
    				break;
    				case "start":
    					_intro.remove();
    					removeChild(_intro);
    					_intro = null;
    				break;
    				
    			}
    			
    		}
    		
    		private function itremove():void{
    			_textPage.remove();
    			removeChild(_textPage);
    			_textPage = null;
    		}
    	}
    }

  14. #14
    maybe my explanation to this guy will help you to make a cleaner code: http://www.kirupa.com/forum/showthre...wfaddress+haxe

    btw, you don't have to wory about setting a page that is already set because nothing will happen. at this line i'm refering: if(_activePage!="yesWeCan_btn")

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012