A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Loader works locally, but not on website...

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    1

    Loader works locally, but not on website...

    I'm building a website to host educational-based flash games for children. Due to the fact that the swfs are +2mb, I decided to write a loader swf to display a downloaded percentage so my users are not staring at a white screen while the actual game is downloading. The loader calls and loads the game correctly when I run it from Flashdevelop on my pc, but not from the site itself. It will fully download the game, but never display it. Here's the link to my on site loader: http://www.roomrecess.com/loaders/Loader.swf

    And here's my script for the loader itself (Loader.swf):

    Code:
    package 
    {
    	import flash.display.Bitmap;
    	import flash.display.Sprite;
    	import flash.events.Event;
    	import flash.net.URLRequest;
    	import flash.display.Loader;
    	import flash.events.ProgressEvent;
    	import flash.text.TextField;
    	import flash.text.TextFormat;
    	import flash.system.Security;
    	import flash.system.SecurityDomain;
    
    	
    		public class Main extends Sprite 
    	{
    		[Embed(source = "../lib/title.png")]
    		public var sharkTitle:Class;
    		
    		public function Main():void 
    		{
    			if (stage) init();
    			else addEventListener(Event.ADDED_TO_STAGE, init);
    		}
    		
    		private function init(e:Event = null):void 
    		{
    			removeEventListener(Event.ADDED_TO_STAGE, init);
    			// entry point
    			
    			Security.allowDomain("*");
    			Security.allowInsecureDomain("*");
    			
    			var sharkTitle:Bitmap = new sharkTitle();
    				sharkTitle.x = 250;
    				sharkTitle.y = 70;
    				sharkTitle.height = 150;
    				sharkTitle.width = 310;
    			var format:TextFormat = new TextFormat();
    					format.size = 50;
    				var percTxt:TextField = new TextField();
    					percTxt.width = 500;
    					percTxt.text = " ";
    					percTxt.setTextFormat(format);
    					percTxt.x = 300;
    					percTxt.y = 250;
    			
    			addChild(sharkTitle);
    			addChild(percTxt);
    			
    			function startLoad():void 
    			{
    				var mLoader:Loader = new Loader();
    				var mRequest:URLRequest = new URLRequest("http://www.roomrecess.com/games/WordShark.swf");
    				mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    				mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
    				mLoader.load(mRequest);
    			}
    			
    			function onCompleteHandler(loadEvent:Event):void 
    			{
    				addChild(loadEvent.currentTarget.content);
    			}
    			
    			function onProgressHandler(mProgress:ProgressEvent):void 
    			{
    				var percent:Number = mProgress.bytesLoaded / mProgress.bytesTotal;
    				percent = percent * 100;
    				Math.ceil(percent);
    				format.size = 50;
    				percTxt.setTextFormat(format);
    				percTxt.text = String(Math.ceil(percent)) + "% loaded";
    				percTxt.setTextFormat(format);
    				if (percent > 99) { percTxt.visible = false;}
    				
    			}
    			
    			startLoad();
    
    			
    		}
    		
    		
    	}
    	
    }
    Thank you.

  2. #2
    Junior Member
    Join Date
    Mar 2013
    Posts
    5
    That's strange...perhaps try casting it as a Movieclip.

    Code:
    			function onCompleteHandler(loadEvent:Event):void 
    			{
    				addChild(loadEvent.currentTarget.content as MovieClip);
    			}
    Also, if you try tracing it out after its loaded, what does it say:

    Code:
    			function onCompleteHandler(loadEvent:Event):void 
    			{
                                   var loadedGame:MovieClip;
    				loadedGame = loadEvent.currentTarget.content as MovieClip;
                                   addChild(loadedGame);
                                   trace(loadedGame.visible, loadedGame.y, loadedGame.x, loadedGame.width, loadedGame.height);
    			}

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center