How to constrain loaded swf? - actionscript-3

I load swf files continuously, but if one of the swfs has some defective code such as Mouse.hide() the mouse disappears when the swf is loaded. I want to constrain such malicious code in loaded swfs.
There is also another problem related to containing loaded or loading swfs. When I load a swf which loads another swf to operate, It never completes loading (Event.Complete of contentLoaderInfo) because it needs another swf to load. However, the swf should be loaded before it runs. Since loaded swf is as-2, loader does not give any error. I am also suspicious whether or not it will give error if it is as-3.

Check the LoaderMax classes from greensock.com . This should help solve the problem of swf loading other swf before running, since you can listen to the overall loading progress and react accordingly.

Related

I need to remove a loaded swf file loaded by a different swf file

I have an swf file (swf2) that loads into my main swf file (swf1). On the click of a button (which is housed in the loaded swf file swf2) I need to stop swf2 from running and load on new swf (swf3).
I am using removeChild(loader);
But the problem is loader in in the parent (swf1) swf, how do I reference it?
Sorry if this is not enough info, I am not really an expert here.
Thanks
The way I understand this is that you have swf1 loading swf2. Swf2 contains a button that when pressed, causes swf1 to unload swf2 and load swf3.
There are a few ways to do communicate between loaded swfs and their parents. One way (the method I usually use depending on context) is that you could have the loaded swf throw an event that the parent can listen to and catch. In this case, your loaded swf2 could throw a "close" event the parent swf1can catch and then use to trigger the unloading of the swf2 (and load the swf3).
For another way, check to see if you can access the parent (which would be the main loading swf, swf1) inside the loaded child swf by it's parent property. I can't always recommend this though as it can be unclear to what 'parent' may refer to in the future if you reuse swf2 with another loader.
Something else to consider though, if this button is meant to control loading and unloading of children swfs, would it make more sense to move it out to the loader itself since that is where the behaviour is? This would also eliminate the problem.

How to cache loaded swf avatars in Flex 4

I'm using custom renderer with s:SWFLoader inside to display clients swf avatars in s:List. useVirtualLayout is "on".
When new client arrives (or leaves chat) s:List send new data to the renderers.
So SWFLoader in renderer have to load new data. And as a result we have flickering. When swf avatar disappears for second and appears again.
I've resolved this issue when all avatars was just images. I've saved content from Loader and used it as data source for s:Image.
But with swf avatars this approach does not work because after adding on stage we cannot change parent of the AVM1Movie (have not tried another version because i have to support this one too).
I've looked in SWFLoader source code and found that Loader added on stage before loading data.
Also i've tried to load swf to ByteArray and call loadBytes. But flickering still exists.
And i've tried to return Loader as a source.
So what will you recomend to do in this situation? Is swf caching possible?

Load SWF data without loading sound, then load sound later

So, hypothetical situation here:
I have an SWF that's 30MB. Sound files (music) make up 25MB, art and other things make up the remaining 5MB.
Would it be possible for me to load the 5MB of necessary art and other things first to allow the user to operate the app, then after that's all loaded and they are operating the app, load the remaining 25MB of sound files in the background?
UPDATE:
Loading SWF (or other entities) externally is not an option.
You can do this by modifying the compilation settings and strategically placing the sound.
By default, anything placed on the timeline will be loaded sequentially; the Flash Player will play the SWF as soon as the first frame is loaded. If you use the default compilation settings, all library content will be placed in the first frame, so the movie doesn't start until everything is available.
You can modify these settings, however, to allow for a more sequential load order: For each of your library elements, you can uncheck "export into frame 1" in the properties window. Now these elements won't be loaded, until they appear in the main timeline. This way, if you place your content carefully, you can allow for all important elements to be loaded in the first frame, or if you have a progress bar, until the main movie starts, while all streaming elements load with the animation, which has to be placed accordingly. Make sure though, that you don't leave anything out (by not placing it on the timeline), or call elements from ActionScript before they are loaded completely. It is very important to test this thoroughly, because if anything goes wrong in the load order, your entire SWF might stop working.
Also, remember that the SWF loads sequentially: If you have a sound in, say, frame 300, and another in frame 1000, the one in 300 will be loaded first. If you jump to frame 1000 from a menu in frame 10, you have to take into account that the frame might not be loaded yet. So there has to be some sort of checking mechanism (framesLoaded) and/or dialog to inform the user about additional loading time, and prevent the application from crashing.

Loaded object in ActionScript3 with higher FPS

How can I load a swf in ActionScript 3 with a higher fps than the instance doing the loading with Loader?
Thanks!
I see this question quite a bit,
Unfortunately I have to tell you there is no way to play an externally loaded SWF at a different frame rate than the one doing the loading. There is only ever one stage instance (the one in the parent SWF). When you load another external SWF it is treated like any other MovieClip in the display list.
Tyler.

Adding an as2 swf to the stage in an as3 swf

I have a menu control (as2), that is completely self-contained and doesn't rely on any interaction with the parent (as3). The menu control does load an external xml file that is in the same directory as the swf.
The menu control works fine when I run it on its own. But when I import it into the Library of my as3 fla, add it the stage and run it, it just sits and does nothing.
I can see the images that are part of the control, which leads me to believe it can't load the xml, but I'm not sure.
Does anyone have any ideas about:
Loading an as2 swf into and as3 swf where they don't need to interact
Loading an external file into an swf inside of another swf
Have you tried with flash.net.Loader or if you are going for a Flex app: SWFLoader?