Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Load SWF in SWF Problem

    Hi,

    i have to make a strip application. Now I want a loader that show when you're page is loaded. This is of the code my first SWF (with the loader in it).

    Code:
    package 
    {
    	import flash.display.Sprite;
    	import flash.display.StageAlign;
    	import flash.display.StageScaleMode;
    	import flash.events.Event;
    	import flash.display.Loader;
    	import flash.net.URLRequest;
    	import flash.display.LoaderInfo;
    	import flash.events.ProgressEvent;
    	import flash.display.MovieClip;
    
    	public class FFAppDC extends Sprite
    	{
    		//CONNTECT TO INTERFACE
    		public var preloader_mc:MovieClip;
    		
    		public function FFAppDC()
    		{
    			super();
    			init();
    		}
    		
    		private function init():void
    		{
    			// STAGE
    			stage.align = StageAlign.TOP_LEFT;
    			stage.scaleMode = StageScaleMode.NO_SCALE;
    			stage.addEventListener(Event.RESIZE,handleResizeEvent);
    			//LOAD MAIN APP
    			var loader:Loader = new Loader();
    			 loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleProgressEvent);
    			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoadCompleteEvent);
    			loader.load(new URLRequest("FFMainApp.swf"));
    		}
    		
    		private function handleResizeEvent(e:Event):void
    		{
    			
    		}
    		private function handleProgressEvent(e:ProgressEvent):void
    		{
    			var perc:Number = Math.round((e.bytesLoaded/e.bytesTotal)*100);
    			preloader_mc.precentage_txt.text = perc + "%";
    			preloader_mc.progressbar_mc.gotoAndStop(perc);
    			
    		}
    		private function handleLoadCompleteEvent(e:Event):void
    		{
    			
    			var target:* = e.target;
    			var lInf:LoaderInfo = target as LoaderInfo;
    			addChild(lInf.content);
    		}
    		
    
    	}
    
    }
    As you can see, i have a MovieClip with a textbox and rectangle that shows how much bytes are loaded. And i load the MainApp.swf (where my strip pages are)

    Also i need to resize my strippage to fit in the browsers. Here is my code of mainapp:

    Code:
    package 
    {	
    	import flash.display.Sprite;
    	import flash.display.StageAlign;
    	import flash.display.StageScaleMode;
    	import flash.events.Event;
    	import flash.display.MovieClip;
    
    	public class FFMainAppDC extends Sprite
    	{
    		public var stripitpage_mc:MovieClip;
    
    		public function FFMainAppDC()
    		{
    			super();
    			init();
    		}
    
    		private function init():void
    		{
    			stage.align = StageAlign.TOP_LEFT;
    			stage.scaleMode = StageScaleMode.NO_SCALE;
    			stage.addEventListener(Event.RESIZE, handleResizeEvent);
    
    			//FORCE RESIZE ON STARTUP
    			handleResizeEvent();
    		}
    
    		private function handleResizeEvent(e:Event = null):void
    		{
    			var scale:Number = Math.max(2103/(stage.stageWidth-60), 3000/(stage.stageHeight-60));
    			stripitpage_mc.scaleX = 1/scale;
    			stripitpage_mc.scaleY = 1/scale;
    			stripitpage_mc.x = stage.stageWidth/2;
    			stripitpage_mc.y = stage.stageHeight/2;
    		}
    	}
    
    }
    When i want to run the first swf i get this:
    TypeError: Error #1009: Kan geen eigenschap of methode benaderen via een verwijzing naar een object dat null is.
    at FFMainAppDC/init()
    at FFMainAppDC()

  • #2
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Found it !

    Just add this to your constructor:

    this.addEventListener(Event.ADDED_TO_STAGE,init);


  •  

    Posting Permissions

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