Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

access load swf outside of loader function

Avatar of Alex500
Alex500 asked on
Adobe Flash
12 Comments1 Solution383 ViewsLast Modified:
hi all i am making an image gallery on a website and there are 5 different galleries in five separate swf files. What i would like to do is tween between the different swfs once they are loaded. So far I have loaded the swfs and can add tweener effects from within the onCompleteHandler load event function but when i try to remove child or tween outside of the load event function  i get


1120: Access of undefined property loadEvent.
package {
	
	//Import relevant ActionScript Libs
	import flash.events.*;
	import flash.display.*;
	import flash.filters.BlurFilter;
	import flash.net.URLRequest;
	import flash.display.Loader;
	import flash.events.ProgressEvent;
	import flash.display.Sprite;
	
	
	//Tweener Lib
	import caurina.transitions.*;
	import caurina.transitions.properties.FilterShortcuts;
	FilterShortcuts.init();

	
	
	public class goodTimesAS3 extends MovieClip {
		
		
					//Load in MovieClips and instantiate (BACKGROUNDS)
					private var entrance:entranceBg_mc = new entranceBg_mc();
					private var desk:deskBg_mc = new deskBg_mc();
					private var studio:studioBg_mc = new studioBg_mc();
					private var drawing:drawingBg_mc = new drawingBg_mc();
					private var shrine:shrineBg_mc = new shrineBg_mc();
					
					
					//Load in MovieClips and instantiate (LOGO & CONTENT)
					private var logo:goodLogo_mc = new goodLogo_mc();
					private var deskInfo:deskInfo_mc =  new deskInfo_mc();
					private var rightArrow:rightArrow_mc = new rightArrow_mc();
					private var rightArrow2:rightArrow_mc = new rightArrow_mc();
					private var leftArrow:leftArrow_mc = new leftArrow_mc();
					private var leftArrow2:leftArrow_mc = new leftArrow_mc();
					private var merchDoor:studioDoorCutout_mc = new studioDoorCutout_mc();
					
					private var mercText:mercText_mc = new mercText_mc();
					
					//Load in people MovieClips
					private var saira:saira_mc = new saira_mc();
					private var nick:nick_mc = new nick_mc();
					private var jamie:jamie_mc = new jamie_mc();
					private var nikole:nikole_mc = new nikole_mc();
					private var danny:danny_mc = new danny_mc();
					
					private var saira2:saira_mc = new saira_mc();
					private var nick2:nick_mc = new nick_mc();
					private var jamie2:jamie_mc = new jamie_mc();
					private var nikole2:nikole_mc = new nikole_mc();
					private var danny2:danny_mc = new danny_mc();
					
					
					private var maskWindow:mask_mc = new mask_mc();
					private var maskWindow2:mask_mc = new mask_mc();
					
					private var sairaContent:sairaContent_mc = new sairaContent_mc();
					private var nickContent:nickContent_mc = new nickContent_mc();
					private var jamieContent:jamieContent_mc = new jamieContent_mc();
					private var nikoleContent:nikoleContent_mc = new nikoleContent_mc();
					private var dannyContent:dannyContent_mc = new dannyContent_mc();
					
					
					
					
					//Start blur settings for desk
					private var myBlurFilter = new BlurFilter (10,10,3);
					
					
					//Set string var for people tween
					private var currentPage:String = "nikoleContent";
	
					
					public function goodTimesAS3() {
						
						//Position and add elements to the stage
						stage.addChild(desk);
						desk.x = 606.15;
						desk.y = 390.10;
						desk.width = 1720;
						desk.height = 1150.80

						stage.addChild(entrance);
						entrance.x = 597;
						entrance.y = 398;
						
						stage.addChild(logo);
						logo.x = 580;
						logo.y = 274;
						//Add event listener for entrance animation to begin (Runs function goInside)
						logo.addEventListener(MouseEvent.MOUSE_OVER, goInside);
						
						
						//Add studio bg to stage
						stage.addChild(studio);
						studio.x = 1200;
						studio.y = 0;
						
						
						stage.addChild(rightArrow);
						rightArrow. x = 1161.3;
						rightArrow. y = 349.10;
						rightArrow.addEventListener(MouseEvent.CLICK, moveRight);
						
						
						
						
						
				}
				
				public function goInside(e): void {
					
						//Remove Logo
						stage.removeChild(logo);
						logo.removeEventListener(MouseEvent.MOUSE_OVER, goInside);
						
						
						//Scale entrance and drop alpha
						Tweener.addTween (entrance, {_Blur_blurX: 10, _Blur_blurY: 10, _Blur_quality:2, time:0.4, transition:"easeOutSine"});
						Tweener.addTween (entrance, {width:1660 , height:1110, time:0.4, transition:"easeOutSine"});
						Tweener.addTween (entrance, {alpha:0, time:0.6, transition:"easeOutSine"});
						
						//Fade desk in and scale oncomplete run enter content funtion
						Tweener.addTween (desk, {width:1260, height:843, time:0.4, delay: 0.1, transition:"easeOutSine", onComplete: enterContent});
						
					
					
					}
					
					
				//Display Content	
				public function enterContent() {
					
						stage.addChild(deskInfo);
						deskInfo.x = 241.30;
						deskInfo.y = 74.20;
						deskInfo.filters = [myBlurFilter];
						Tweener.addTween (deskInfo, {_Blur_blurX: 0, _Blur_blurY: 0, _Blur_quality:2, time:0.8, transition:"easeOutSine"});
						Tweener.addTween (deskInfo, {x:190.30, time:0.8, transition:"easeOutSine"});
						
						//Add arrow to stage and attach event listener
						stage.addChild(leftArrow);
						leftArrow. x = 40;
						leftArrow. y = 349.10;
						leftArrow.addEventListener(MouseEvent.CLICK, moveLeft);
						
				}
				
				
			public function moveLeft(e): void {
				
				stage.removeChild(deskInfo);
				
				
				stage.addChild(shrine);
				shrine.x = -1292.40;
				shrine.y = -28.35;
				Tweener.addTween(desk, {x:1828, time:0.6, transition:"easeOutSine"});
				Tweener.addTween(deskInfo, {x:1828, time:0.6, transition:"easeOutSine"});
				Tweener.addTween(shrine, {x:-50.10, time:0.6, transition:"easeOutSine", onComplete: addGallery});
				Tweener.addTween (shrine, {_Blur_blurX: 10, _Blur_blurY: 10, _Blur_quality:2, time:0, transition:"easeOutSine"});
				Tweener.addTween (shrine, {_Blur_blurX: 0, _Blur_blurY: 0, _Blur_quality:2, time:0.6, transition:"easeOutSine"});
				
				
				
				
			}
			
			
			
		public function addGallery() {
					
					stage.addChild(rightArrow2);
					rightArrow2. x = 1161.3;
					rightArrow2. y = 349.10;
					
					
					
					stage.addChild(danny2);
						danny2.x = 160;
						danny2.y = 300;
						danny2.addEventListener(MouseEvent.CLICK, clickHandlerOne2);
							function clickHandlerOne2(e:MouseEvent):void {
									
								}
						
						stage.addChild(jamie2);
						jamie2.x = 160;
						jamie2.y = 400;
						jamie2.addEventListener(MouseEvent.CLICK, clickHandlerTwo2);
							function clickHandlerTwo2(e:MouseEvent):void {
								
								
								//////////////////////////
							
									
								}
						
						
						stage.addChild(saira2);
						saira2.x = 230;
						saira2.y = 290;
							saira2.addEventListener(MouseEvent.CLICK, clickHandlerThree2);
								function clickHandlerThree2(e:MouseEvent):void {
										
									}
						
						
						stage.addChild(nick2);
						nick2.x = 230;
						nick2.y = 390;
						nick2.addEventListener(MouseEvent.CLICK, clickHandlerFour2);
								function clickHandlerFour2(e:MouseEvent):void {
										
									}
						
						stage.addChild(nikole2);
						nikole2.x = 160;
						nikole2.y = 220;
						nikole2.addEventListener(MouseEvent.CLICK, clickHandlerFive2);
								function clickHandlerFive2(e:MouseEvent):void {
										
									}
					
					
					
					/*Load in external swf */
				var loadSwf:Loader = new Loader();
				var requestSwf:URLRequest = new URLRequest("photo_gallery.swf");
				loadSwf.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
				loadSwf.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
				

				loadSwf.load(requestSwf);
				
				
				
				var loadSwfNick:Loader = new Loader();
				var requestSwfNick:URLRequest = new URLRequest("photo_galleryNick.swf");
				loadSwfNick.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandlerNick);
				//loadSwfNick.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandlerNick);
				

				loadSwfNick.load(requestSwfNick);
				
				
				
				/* Add swf to stage */
				function onCompleteHandler (loadEvent:Event) {
					
					
					
					stage.addChild(loadEvent.currentTarget.content);
					loadEvent.currentTarget.content.mask = maskWindow;
					loadEvent.currentTarget.content.x = 400;
					loadEvent.currentTarget.content.y = 200;
					loadEvent.currentTarget.content.alpha = 0;
					Tweener.addTween(loadEvent.currentTarget.content, {alpha:1, time:0.6, transition:"easeOutSine"});
					
					
					
					
					maskWindow.x = 400;
					maskWindow.y = 200;
					
					rightArrow2.addEventListener(MouseEvent.CLICK, backRight)
					
					//stage.removeChild(loadEvent.currentTarget.content);
				}
				
				/* Progress tracking*/
				function onProgressHandler(mProgress:ProgressEvent) {
					var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
					trace (percent);
				}
				
				
				
				function onCompleteHandlerNick (loadEvent:Event) { 
				
				stage.addChild(loadEvent.currentTarget.content);
				loadEvent.currentTarget.content.mask = maskWindow2;
				maskWindow2.x = 400;
				maskWindow2.y = -250;
				
				
				loadEvent.currentTarget.content.x = 400;
				loadEvent.currentTarget.content.y = -250;
				
				
				
				}
				
				}	
			
			
			
			
			
			public function backRight(e): void {
				
				stage.removeChild(rightArrow2);
				rightArrow2.removeEventListener(MouseEvent.CLICK, backRight)
				
				
				stage.addChild(deskInfo);
				deskInfo.x = 241.30;
				deskInfo.y = 74.20;
				deskInfo.alpha = 0;
				deskInfo.filters = [myBlurFilter];
				Tweener.addTween (deskInfo, {_Blur_blurX: 0, _Blur_blurY: 0, _Blur_quality:2, time:0.8, delay:0.6, transition:"easeOutSine"});
				Tweener.addTween (deskInfo, {x:190.30, alpha:1, time:0.8, delay:0.6, transition:"easeOutSine"});
				
				
				//loadEvent.parent.removeChild(loadEvent.currentTarget.content);
				
				
				Tweener.addTween(shrine, {x:-1292.40, time:0.6, transition:"easeOutSine", onComplete: function() { stage.removeChild(shrine); }});
				Tweener.addTween(desk, {x:606.15, time:0.6, transition:"easeOutSine"});
				
				
				
				
				
				
				
			}
				
				
			public function moveRight(e): void {
				
						//Remove Desk Content
						stage.removeChild(deskInfo);
						stage.removeChild(rightArrow);
						stage.removeChild(leftArrow);
						
						
						//Blur studio
						studio.filters = [myBlurFilter];
						//Animate between backgrounds		
						Tweener.addTween(studio, {x:0, time:0.6, transition:"easeOutSine"});
						Tweener.addTween(studio, {_Blur_blurX: 0, _Blur_blurY: 0, _Blur_quality:2, time:0.6, delay:0.3, transition:"easeOutSine"});
						Tweener.addTween(desk, {x:-632.15, _Blur_blurX: 10, _Blur_blurY: 10, _Blur_quality:2, time:0.6, transition:"easeOutSine", onComplete: studioContent  });

				
			}
			
			
			
			public function studioContent() {
				
								
						stage.addChild(leftArrow);
						leftArrow. x = 40;
						leftArrow. y = 349.10;
						leftArrow.addEventListener(MouseEvent.CLICK, backDesk);
						rightArrow.removeEventListener(MouseEvent.MOUSE_OVER, moveRight);
						leftArrow.removeEventListener(MouseEvent.CLICK, moveLeft);
						
						
						
				
				
				
							stage.addChild(dannyContent);
							dannyContent.alpha = 0;
							dannyContent.x = 330;
							dannyContent.y = 20;
							
							stage.addChild(jamieContent);
							jamieContent.alpha = 0;
							jamieContent.x = 330;
							jamieContent.y = 20;
							
							stage.addChild(sairaContent);
							sairaContent.alpha = 0;
							sairaContent.x = 330;
							sairaContent.y = 20;
							
							stage.addChild(nickContent);
							nickContent.alpha = 0;
							nickContent.x = 330;
							nickContent.y = 20;
							
							stage.addChild(nikoleContent);
							nikoleContent.alpha = 1;
							nikoleContent.x = 330;
							nikoleContent.y = 20;
							
							
							
				
						stage.addChild(danny);
						danny.x = 160;
						danny.y = 300;
						danny.addEventListener(MouseEvent.CLICK, clickHandlerOne);
							function clickHandlerOne(e:MouseEvent):void {
									moveOut("dannyContent");
								}
						
						stage.addChild(jamie);
						jamie.x = 160;
						jamie.y = 400;
						jamie.addEventListener(MouseEvent.CLICK, clickHandlerTwo);
							function clickHandlerTwo(e:MouseEvent):void {
									moveOut("jamieContent");
								}
						
						
						stage.addChild(saira);
						saira.x = 230;
						saira.y = 290;
							saira.addEventListener(MouseEvent.CLICK, clickHandlerThree);
								function clickHandlerThree(e:MouseEvent):void {
										moveOut("sairaContent");
									}
						
						
						stage.addChild(nick);
						nick.x = 230;
						nick.y = 390;
						nick.addEventListener(MouseEvent.CLICK, clickHandlerFour);
								function clickHandlerFour(e:MouseEvent):void {
										moveOut("nickContent");
									}
						
						stage.addChild(nikole);
						nikole.x = 160;
						nikole.y = 220;
						nikole.addEventListener(MouseEvent.CLICK, clickHandlerFive);
								function clickHandlerFive(e:MouseEvent):void {
										moveOut("nikoleContent");
									}
									
									
						stage.addChild(merchDoor);
						merchDoor.x = 855.45;
						merchDoor.y = 375;
						merchDoor.addEventListener(MouseEvent.CLICK, merchLoad);
						
				
			}
			
			
				public function merchLoad (e): void {
				
						stage.addChild(drawing);
						drawing.x = 17.30;
						drawing.y = 10.65;
						drawing.alpha = 0;
						
						Tweener.addTween(drawing, {alpha:1, time:0.6, transition:"easeOutSine"});
						
						stage.addChild(mercText);
						mercText.x = 477;
						mercText.y = 264;
						mercText.alpha = 0;
						
						Tweener.addTween(mercText, {alpha:1, time:0.6, delay:0.6, transition:"easeOutSine"});
						
						
						
						leftArrow.removeEventListener(MouseEvent.CLICK, backDesk);
						
						stage.addChild(leftArrow2);
						leftArrow2. x = 40;
						leftArrow2. y = 349.10;
						leftArrow2.addEventListener(MouseEvent.CLICK, backStudio)
						
						
				
				}
				
				
					public function backStudio(e): void {
						
						stage.removeChild(mercText);
						stage.removeChild(leftArrow2);
						
						Tweener.addTween(drawing, {alpha:0, time:0.6, transition:"easeOutSine", onComplete: function() { stage.removeChild(drawing); }});
						leftArrow2.removeEventListener(MouseEvent.CLICK, backStudio)
						leftArrow.addEventListener(MouseEvent.CLICK, backDesk);
						
					}
			
		
			function moveOut (page:String) {
											
				if (page!=currentPage) {
												
					if (currentPage== "nikoleContent") { 
					
					Tweener.addTween(nikoleContent, { onComplete:function() { this.alpha = 0; moveIn(page);}});
					
				}
														
														
					if (currentPage== "sairaContent") { 
					
					Tweener.addTween(sairaContent, { onComplete:function() { this.alpha = 0; moveIn(page);}});
					
				}
														
					if (currentPage== "nickContent") { 
					
					Tweener.addTween(nickContent, { onComplete:function() { this.alpha = 0; moveIn(page);}});
					
				}
				
					if (currentPage== "jamieContent") { 
					
					Tweener.addTween(jamieContent, { onComplete:function() { this.alpha = 0; moveIn(page);}});
					
				}
				
					if (currentPage== "dannyContent") { 
					
					Tweener.addTween(dannyContent, { onComplete:function() {  this.alpha = 0; moveIn(page);}});
					
					
							}
											
					}
										
				}
				
				function moveIn (next:String) {
									
					if (next=="nikoleContent") {
						Tweener.addTween(nikoleContent, {x:330, time:0.6, transition:"easeOutSine"});
						Tweener.addTween(nikoleContent, {alpha:1, time:0.3, delay:0.3, transition:"easeOutSine"});
					}
					if (next=="sairaContent") {
						Tweener.addTween(sairaContent, {x:330, time:0.6, transition:"easeOutSine"});
						Tweener.addTween(sairaContent, {alpha:1, time:0.3, delay:0.3, transition:"easeOutSine"});
					}
					if (next=="nickContent") {
						Tweener.addTween(nickContent, {x:330, time:0.6, transition:"easeOutSine"});
						Tweener.addTween(nickContent, {alpha:1, time:0.3, delay:0.3, transition:"easeOutSine"});
					}
					
					if (next=="jamieContent") {
						Tweener.addTween(jamieContent, {x:330, time:0.6, transition:"easeOutSine"});
						Tweener.addTween(jamieContent, {alpha:1, time:0.3, delay:0.3, transition:"easeOutSine"});
					}
					
					if (next=="dannyContent") {
						Tweener.addTween(dannyContent, {x:330, time:0.6, transition:"easeOutSine"});
						Tweener.addTween(dannyContent, {alpha:1, time:0.3, delay:0.3, transition:"easeOutSine"});
					}
									
					
					currentPage=next;
									
									
			}
			
			public function backDesk(e): void {
				
					currentPage = "nikoleContent";
					
					stage.removeChild(merchDoor);
					merchDoor.removeEventListener(MouseEvent.CLICK, merchLoad);
				
					stage.removeChild(dannyContent);
					stage.removeChild(nikoleContent);
					stage.removeChild(nickContent);
					stage.removeChild(sairaContent);
					stage.removeChild(jamieContent);
					
					stage.removeChild(danny);
					stage.removeChild(nikole);
					stage.removeChild(nick);
					stage.removeChild(saira);
					stage.removeChild(jamie);
					
					
					
					
					
					
					leftArrow.removeEventListener(MouseEvent.CLICK, backDesk);
					leftArrow.addEventListener(MouseEvent.CLICK, moveLeft);
					
					//Blur studio
					desk.filters = [myBlurFilter];
					//Animate between backgrounds		
					Tweener.addTween(desk, {x:606.15, time:0.6, transition:"easeOutSine"});
					Tweener.addTween(desk, {_Blur_blurX: 0, _Blur_blurY: 0, _Blur_quality:2, time:0.6, delay:0.3, transition:"easeOutSine"});
					Tweener.addTween(studio, {x:1200, _Blur_blurX: 10, _Blur_blurY: 10, _Blur_quality:2, time:0.6, transition:"easeOutSine", onComplete: contentAdd});
					
					stage.addChild(rightArrow);
					rightArrow. x = 1161.3;
					rightArrow. y = 349.10;
					
					function contentAdd () {
					
					stage.addChild(deskInfo);
					deskInfo.x = 241.30;
					deskInfo.y = 74.20;
					deskInfo.filters = [myBlurFilter];
					Tweener.addTween (deskInfo, {_Blur_blurX: 0, _Blur_blurY: 0, _Blur_quality:2, time:0.8, transition:"easeOutSine"});
					Tweener.addTween (deskInfo, {x:190.30, time:0.8, transition:"easeOutSine"});
					
					
					}
				
				}
				
			
		
		}

}
ASKER CERTIFIED SOLUTION
Avatar of Randy Poole
Randy PooleFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers