Be a Supporter!

Loading issues.

  • 251 Views
  • 3 Replies
New Topic Respond to this Topic
dercheezle
dercheezle
  • Member since: Sep. 8, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Loading issues. 2009-03-05 17:27:59 Reply

I have this mxml application (THE GLITCHES ARE ONLY IN THE ACTIONSCRIPT PART) that loads external swfs into itself based on a query string in its embed url. I use it to keep my blog's pages from taking forever to load, while allowing for multiple flash files to be seen on the page. This much works fine. But for some reason, when loading certain flashes, it loads them just fine, but they're not added to the display list or something, because they do not show up.

Here's the code:

Please only pay attention to the actionscript, not the mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

	<mx:Script>
		<![CDATA[
			
			import mx.controls.*;
			import flash.net.URLRequest;
			import flash.display.Loader;
			import flash.events.Event;
			import flash.events.ProgressEvent;
			
			[Bindable] var loadUrl:URLRequest = new URLRequest("");
			[Bindable] var loader2:Loader = new Loader();
			
			[Bindable] var loaded:Boolean = false;
			
			init();
			function init():void{
				//stage.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
				
				//var flashVars = this.loaderInfo.parameters;
				//var loadUrlString:String = flashVars.UrlString;
				//loadUrl.url = loadUrlString;
				
				//====
				tracer.text += loadUrl.url;
				//tracer.text += "yay2";
				//====
			}
			
			function loaderComplete(e:Event):void{
				tracer.text += "poop";
			}
			
			function startLoad():void{
				
				var flashVars = this.loaderInfo.parameters;
				var loadUrlString:String = flashVars.UrlString;
				loadUrl.url = loadUrlString;
				
				loader2.load(loadUrl);
				
				//====
				//addChild(loader2);
				//====
				
				loader2.contentLoaderInfo.addEventListener(Event.COMPLETE, onSwfLoaded);
				
				stage.addEventListener(Event.ENTER_FRAME, onFrame);
				
				prgrssBar.mode = "manual";
				
				//====
				tracer.text += "\n" + loadUrl.url ;
				//tracer.text += "\n" + loader2.content;
				//====
			}
			
			function onFrame(e:Event):void{
				prgrssBar.setProgress(loader2.contentLoaderInfo.bytesLoaded, loader2.contentLoaderInfo.bytesTotal);
				
				var percentLoad:Number = loader2.contentLoaderInfo.bytesLoaded / loader2.contentLoaderInfo.bytesTotal *100;
				if(percentLoad == 100 && loaded == false){
					
					tracer.text +="\nBEFORE I FARTED"
					
					stage.addChild(loader2);
					
					tracer.text += "\nAFTER I FARTED";
					loaded = true;
				}
				
				//====
				tracer.text += "\n" + loader2.contentLoaderInfo.bytesLoaded + " / " + loader2.contentLoaderInfo.bytesTotal;
				tracer.text += " --> " + percentLoad + "%";
				//====
			}
			
			function onSwfLoaded(e:Event):void{
				if(loaded == false) stage.addChild(loader2);
				
				removeChild(loadBttn);
				removeChild(prgrssBar);
				
				//loaded = true;
				//====
				tracer.text += "\n" + "yay and poop for all joy.";
				//tracer.text += "\n" + e.target.content.name;
				//====
			}
		]]>
	</mx:Script>

	<mx:Button x="10" y="10" label="Load Flash File" id="loadBttn" click="startLoad()"/>
	<mx:ProgressBar x="10" y="39" id="prgrssBar" enabled="true" width="200"/>
	<mx:TextArea x="10" y="75" width="200" height="409" id="tracer"/>
	
</mx:Application>

it seems to load this just fine, as well as this. But not this or this.

You can test out different .swf files if you want by adding "?UrlString=<location of .swf file>" to the end of this.

If anyone can help me, it would be much appreciated.

dercheezle
dercheezle
  • Member since: Sep. 8, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Loading issues. 2009-03-05 17:31:13 Reply

Oh and bye the way, the tracer text box is simply my substitute for the "trace()" function in flash, since I've been debugging in a browser, I've needed some way to get feedback, so I built this little temporary text box into the app to show me these. It will not be included in the final application.

dercheezle
dercheezle
  • Member since: Sep. 8, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Loading issues. 2009-03-06 18:18:09 Reply

Ah, come on people, I need help here!

roboprez
roboprez
  • Member since: Aug. 25, 2007
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to Loading issues. 2009-03-06 20:23:54 Reply

I don't think that anyone really knows the answer so people are ignoring it. I have no idea what the answer but I'm just posting to make you feel better.


~Last FM~(Music) ~DeviantART~(Flash)