ActionScript 3.0 :: Loading Multiple SWF - Complete Never Called
Dec 21, 2010
I've got some code that loads multiple swf files -- it works great, EXCEPT when the swf files are really small - then they load before the listeners are called - so the "COMPLETE" is never called. So my app just never works.
Here is Actionscript Code:
var _swfLoader:Loader;
var _swfRequest:URLRequest;
var allSWF:Array = new Array();
function loadSWFS():void{
allSWF = ["f1.swf","g2.swf","bob.swf"];
[Code] .....
My currentSwfProgress function always seems to work - so if i load 5 swf files, i will get the trace from the currentSwfProgress 5 times -- but not from the loadComplete function. I have been reading though, that the ProgressEvent.PROGRESS listener is unreliable in certain browsers (chrome for one). I think if I could somehow call the loadComplete function from currentSwfProgress function - that would work, but i do not know how to get the "EVENT" needed in loadComplete from the "ProgressEvent" used in the currentSwfProgress. Maybe something like this...
Actionscript Code:
function currentSwfProgress(
e:ProgressEvent):void{
if (e.target.bytesLoaded == e.target.bytesTotal){
trace("1 - FILE LOADED!");
loadComplete(e.get.the.parent.event())
}}
I am loading in binary files with the url class which can be quite large 10mb + and it works fine on my server but another server I am testing on it can sometimes not work. Sometimes it will not load the file and other times it will only load about 20% and it throw a complete event??? Then of course other times it works fine. This server is https maybe that has something to do this it?
So, I'm trying to load resources, add them to a dictionary, and have a drawing method search through that dictionary and draw based on certain predicates. I have a function that iterates through an Vector of Strings, calling on an instance of Loader to load them instantiated as a URLRequest.
private function loadImages(urls:Vector.<String>):void { var loader:Loader = new Loader();
[Code].....
So the issue is: Only the first images in my Vector are drawing. Upon further inspection, I found that the completeHandler was only being called once (I put a trace in the complete handler to check). However, the Loader is invoking load everytime the loop iterates. I tried instantiating separate loaders for each resource, just to see if it would work, but I had no luck with that. Do I need to make separate loaders and event handlers? Or am I just not using Loader correctly?
I've got a system that loads in little avatar images. When the avatar is loaded in I resize it to 24x24.
Here's some ActionScript Code: var urlReq:URLRequest = new URLRequest( String(playerInfo.vector.scalar.(@id == "AvatarURL")) ); var ldr:Loader = new Loader(); ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, resizeAvatar); ldr.load(urlReq); avatar.addChild(ldr); container.addChild(avatar);
Here is the resizeAvatar function... ActionScript Code: // Resizes the avatar to fit correctly public function resizeAvatar( e:Event ):void { e.target.content.width = 24; e.target.content.height = 24; e.target.content.smoothing = true; }
Now I'm using the e.target.content item because as far as I can see that's the only way to get at a way or resizing the image dynamically (using an Array isn't an option). Here's the funny part, the above code works perfectly in the Flash IDE but when on a live site that Event.COMPLETE is not calling!? The image is loading in but it never gets resized.
im loading multiple images but how do I make sure the program will start once all images have dispatched a complete event. like make a universal loader for all the other "small loaders" if you understand.
i am trying to return an XML object, but having issues. The object is only created via an Event.complete function. I need to return the XML created from my loadXML function via my grabXMLfromFile function.
Code: function grabXMLFromFile(attrPathToXML:String):XML { var fileUrl:String = attrPathToXML; var myUrlRequest:URLRequest = new URLRequest(fileUrl);
I have a "loader.swf" after which my "main.swf" loades. I have used a loaderPro v3 (AS2) component. Doing that was easy but then when it starts loading, even before the loading completes the main.swf starts playing in the background. And i have no coding in my actions panel.
I have a problem with a dynamic video player that I have created in flash. The video player is "SCORM" compliant so that when the user clicks the "exit" button a class file is called to mark the user complete in an LMS.I have tested the SCORM Code previously and it works with out issue. Usually I have the completion code embedded in an Actions Layer of the movie. This is the first time I have attempted to call the completion status in a class file, I have added a "trace statement" when the movie is tested within flash it runs the trace statement properly, but when uploaded to the LMS environment the course does not complete properly
I have an arbitrary number of images I want to load. I want to load them, wait until I get an Event.INIT for each, and only then proceed with the rest of the program. I know I can do that by having an Event.INIT listener update and check some count variable, but is that the standard approach? Is there a more elegant or AS-specific way?
I am loading multiple image files, but they all finish loading at different times and pop up on the screen at random. if theres a way to make an event COMPLETE for multiple files that would wait for all to load before triggering a function?
I'm trying to load external swf (with more than one frame and actionscript 3 on every frame - I used there "timeline" coding) from my main swf.code for loading external swf into main swf:
var loader01:Loader; function openGame1(evt:Event):void{ loader01 = new Loader(); var requestSWF01:URLRequest = new URLRequest("game01.swf");
I'm loading flv in swf using FLV player component using as 3.0. When I'm testing it online, sometimes flv triggers complete event before getting finished.
Below is my code. import fl.video.*; var f:FLVPlayback=new FLVPlayback(); f.source="video1.flv"; var vidWidth=990; var vidHeight=480; [Code] .....
i have a swf file which i want to load into a fla file and export as a new swf file. I understand this part but my actionscript 3.0 code that i put on frame one of the timeline does not work. I have tried every version i have seen online including in adobe's actionscript 3 classroom in a book.... and other books..... i want the swf to run immediately so i dont think i need any event listeners since i am not clicking a button or anything like that... just running the swf at start.
I'm an experienced AS developer, but this is something very basic about flex that I can't figure out. In the class below, I'm not sure why the function imageLoaded would not be executed when the image loads a url. Is there a race condition happening here? The application is completely loaded by the time this object is created and setPicture is called. How can I get the Event.COMPLETE event to fire properly in this case?The line and Log.info functions are conveniences for me, and they definitely work. Here's my MXML definition:
this only happens when I'm running from my local web server. The external swf get loaded just fine and I get the progress event, but just not the complete event.
Here are the three events I listen for currently myLoader.contentLoaderInfo.addEventListener(Event. COMPLETE, OnGameLoaded); myLoader.contentLoaderInfo.addEventListener(Progre ssEvent.PROGRESS, OnGameLoadProgress);
My flash app (as3, flash9) needs to load images from multiple servers.
When running the site on localhost, the loading of images works, regardless of which address it was loaded from. I can load it from
[URL]
But what does NOT work is to have a "Event.COMPLETE" triggered from the Loader that I use, if the Url of the image is not the same address as the one where I load the flash file from. The image loads and displays, but no COMPLETE or even an ioError event is triggered.
I have loaded a jpeg image in flash. Now I need the handler after the loading complete. I have used ActionScript Code: var imageLoader:Loader = new Loader(); var req:URLRequest=new URLRequest(arr[0]); imageLoader.load(req); mc.addChild(imageLoader); imageLoader.addEventListener(Event.COMPLETE, image_func); function image_func(e:Event):void { trace("image laoded complete"); } The above code is not working for loading complete.
I am trying to make a simple mp3 player using flash. The songs are loaded using an XML file which contains the song list. The following code is inserted into a new keyframe.
The problem over here is in the nextSong() function. I am unable to preserve the value of currentIndex. Although I am incrementing currentIndex every time the function is called, but the value remains unchanged.
Unfortunately the search function on the site doesnt seem to be working. I have a website [URL]. We have created a loading page so that the user enters the site when the site is fully loaded. Unfortunately this doesnt work for those parts of the website that are being loaded externally i.e. through XML files.
An example of this can be seen on the showcase section on the left side of the Home Page.
Can I also mention that there are over 250 images being loaded externally through the XML files as well as a number of text blocks. I as a web developer are completely against this amount of images but the client wants them in so unfortunately they have to stay.
I'm coding a FontRegister class that register fonts from an external library.swf.Instead of writing 'manually' all the font class names as strings ("MyFont1","MyFont2",...) to be registered via getDefinition(), I wanted the script to automatically list and register all the fonts in the loaded swf.Font.enumerateFonts() only works on the current ApplicationDomain.... How do I check|trigger enumerateFonts in library.swf when loading is complete?
How do you return data from a custom class, and only when something in the custom class has completed something. For example, let's say I have this code in the custom class[code]...
This, of course, doesn't work. I need the whatever.getLoadedObject() method to wait until the loading has finished inside the custom class then do whatever with the image loaded.
how can I load in flex spark Image control and wait for complete loading? MX:image have method load() and listen COMPLETE event this is not in spark Image...is there only source?? or how can i listen when image is complete loading??
I made a test where I download a file using URLLoader - something like this:
[Code]....
in the middle of the downloading process I physically disconnect the internet connection. the download stalls - but after aproximately 30 seconds downloadSuccessful is invoked, although only half of the data was downloaded. how can I make sure that the data to be downloaded is complete and correct?
I have a Button that when clicked loads a Flex module in my AIR application. However,occasionally the Module fails to load the first time the button is clicked, but it works the second time it's clicked. When I debug it in the debugger the READY event is not fired so the remaining logic is never called.
var moduleInfo:IModuleInfo = ModuleManager.getModule(managedModule.url); moduleInfo.addEventListener(ModuleEvent.READY, function(event:ModuleEvent):void { trace("ModuleEvent.READY called.");
I have a base that contains a load movie action loading "drag_bar.swf" into an mc called "content".drag_bar is a drag menu i created. It works when its opened by itself but doesnt work once it has been loaded into the base file.I know its because the AS in it contains the word "root" but when i changed it to "this", it still didnt work.
I have no experience with Object Oriented Programming, so I wonder about the following:
1) Will the code past the .LOAD line (in red) be executed only after the image completes loading? 2) Can I nest several listeners as seeing in my code below?