FranTagliani

as3
Load SWF in other loaded SWF?

  • 2 posts in this topic

2 posts in this topic

Hello,

I'm on a project created in Flash Builder 4.7 and Flash Professional CS6, nice.

I need the project load's a SWF in the "preloaded SWF", the first SWF, loads a second SWF, and this second would be the "Home" of the project.

At this point, work's perfectly. but when the home try to load secondaries SWF sends me

Quote

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2124"]

 

 

The code of the first SWF:

package
{
   import flash.display.DisplayObject;
   import flash.display.Loader;
   import flash.display.MovieClip;
   import flash.events.Event;
   import flash.events.IOErrorEvent;
   import flash.events.ProgressEvent;
   import flash.net.URLRequest;
   
   public class InitialSWF extends MovieClip
   {
      
      private var _loader_:Loader;
      
      private var _applicationContent_:DisplayObject;
      
      private var _loaderContent_:MovieClip;
      
      private var _loaderIcon_:MovieClip;
      
      public function InitialSWF()
      {
         super();
         _loader_ = new Loader();
		 _loader_.contentLoaderInfo.addEventListener(Event.COMPLETE,_onComplete_,false,0,true);
		 _loader_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,_onIoError_,false,0,true);
		 _loader_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,_onProgress_,false,0,true);
		 _loader_.load(new URLRequest("Home.swf"));
      }
      
      private function _onComplete_(param1:Event) : void
      {
         _applicationContent_ = _loader_.content;
         _applicationContent_.visible = true;
         stage.addChild(_applicationContent_);
         _applicationContent_.addEventListener("onApplicationComplete",_onApplicationComplete_,false,0,true);
		 _loader_.contentLoaderInfo.removeEventListener(Event.COMPLETE,_onComplete_);
		 _loader_.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,_onIoError_);
		 _loader_.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,_onProgress_);
		 _loader_.unload();
		 _loader_ = null;
      }
      
      private function _onApplicationComplete_(tmpEvt:Event) : void
      {
         _applicationContent_.removeEventListener("onApplicationComplete",_onApplicationComplete_);
         _loaderContent_.addEventListener("loaderOut",_onLoaderOut_,false,0,true);
         // do something
      }
      
      private function _onLoaderOut_(param1:Event) : void
      {
         _loaderContent_.removeEventListener("loaderOut",_onLoaderOut_);
         _applicationContent_.visible = true;
         stage.removeChild(this);
      }
      
      private function _onIoError_(tmpError:IOErrorEvent) : void
      {
		  trace(tmpError);
      }
      
      private function _onProgress_(param1:ProgressEvent) : void
      {
         var _progress_:Number = Math.round(param1.bytesLoaded / param1.bytesTotal * 100);
         //Do animation loading
      }
   }
}

 And the HomeSWF:

package
{
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.DataEvent;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.HTTPStatusEvent;
	import flash.net.URLRequest;
	
	public class SecondarySWF extends Sprite
	{
		
		private var _loader_:Loader;
		
		private var _loaderContent_:MovieClip;
		
		private var _loaderIcon_:MovieClip;
		
		private var _applicationContent_:DisplayObject;
		
		public function SecondarySWF()
		{
			this.addEventListener(Event.ADDED_TO_STAGE,this._GoLogin_,false,0,true);
		}
		
		public function _GoLogin_(tmpEvent:Event)
		{
			_loader_ = new Loader();
			_loader_.contentLoaderInfo.addEventListener(Event.COMPLETE,_onComplete_,false,0,true);
			_loader_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,_onIoError_,false,0,true);
			_loader_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,_onProgress_,false,0,true);
			_loader_.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
			_loader_.load(new URLRequest("SecondarySWF.swf"));
		}
		
		private function httpStatusHandler(event:HTTPStatusEvent):void {
			trace(event);
		}
		
		private function _onComplete_(param1:Event) : *
		{
			_applicationContent_ = _loader_.content;
			_applicationContent_.visible = true;
			stage.addChild(_applicationContent_);
			_applicationContent_.addEventListener("onApplicationComplete",_onApplicationComplete_,false,0,true);
			_loader_.contentLoaderInfo.removeEventListener(Event.COMPLETE,_onComplete_);
			_loader_.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,_onIoError_);
			_loader_.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,_onProgress_);
			_loader_.unload();
			_loader_ = null;
			this.removeEventListener(Event.ADDED_TO_STAGE,this._GoLogin_);
		}
		
		private function _onApplicationComplete_(param1:Event) : void
		{
			_applicationContent_.removeEventListener("onApplicationComplete",_onApplicationComplete_);
			_loaderContent_.addEventListener("loaderOut",_onLoaderOut_,false,0,true);
			// ..
		}
		
		private function _onLoaderOut_(param1:Event) : void
		{
			_loaderContent_.removeEventListener("loaderOut",_onLoaderOut_);
			//_applicationContent_.visible = true;
			//stage.removeChild(this);
        }
		
		private function _onIoError_(tmpError:IOErrorEvent) : void
		{
			trace(tmpError);
		}
		
		private function _onProgress_(param1:ProgressEvent) : void
		{
			var _progress_:Number = Math.round(param1.bytesLoaded / param1.bytesTotal * 100);
			// ..
		}
	}
}

 

597ac391c493b_ScreenShot2017-07-28at01_48_35.thumb.png.3a83bf8553a71501e3c8602f884fac39.png

 

This is an image of the Google console.log, and catch this:

-start InitialSWF

-Load HomeSWF

-Complete loaded of HomeSWF

-Start HomeSWF

-The link of the Secondary SWF, I deleted the link in the image because contains data of me...

-Load SecondarySWF

- ERROR

 

I don't know why the SecondarySWF is 100% loaded but return an error... Regards!

Share this post


Link to post
Share on other sites

Hi and welcome to the GreenSock forums,

 

I'm not sure what sort of help you are looking for, but our support is very focused on GreenSock products  and it doesn't seem like you are using any.

Yes, our LoaderMax and SWFLoader tools could likely make what you are doing much easier, but we stopped development on them years ago. Our support for them is extremely limited. If you have a problem with them and provide a very clear and reduced demo, we will certainly take a peek and try to help. With the industry clearly moving so far away from Flash we just don't have the resources to support these tools anymore.

 

You are free to download and use LoaderMax. Documentation is still available.


Its worth noting that Adobe has announced that 2020 will be the End Of Life for Flash player. No longer supported or distributed by Adobe.

https://blogs.adobe.com/conversations/2017/07/adobe-flash-update.html

Microsoft has announced aggressive plans to phase it out in its browsers as well: https://blogs.windows.com/msedgedev/2017/07/25/flash-on-windows-timeline/amp/?utm_content=buffer0c322&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer

 

 

Best of luck with your project.

 

Share this post


Link to post
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.