I have a program that dynamically loads SWFs a user has uploaded to a server into another, larger, SWF. This means the embedded SWF can be any framerate and I have no control or knowledge of what is being uploaded.
What I want to do is show a message to the user that the framerate does not match the parent SWFs framerate and that it might playback too quickly or slowly.
However, when I try to find the framerate (using swfLoader.loaderInfo.frameRate) it only displays the parent's framerate, because the child's has been changed.
I need a way to find the framerate the original child SWF was set to before it was changed by the parent.
I tried going to Google for this issue, but nothing turned up a working solution to this problem.
You should use contentLoaderInfo.frameRate instead.
Related
I'm writing an android app in flex as I need to display swf animations.
These swf files are larger than the mobile screen - they're advertisements used elsewhere.
I don't seem to be able to resize the loaded swf file. I've set height and width on the container, the loader everywhere I can think of and nothing changes the size of the swf.
It's frustrating, the swf is of a set size as they display full screen when used as advertisements, I just want to show a small preview within the app of what they will look like.
I'm beginning to think that it cannot be done? or am I missing something
I've seen similar questions asked here, but no answer that works for me.
There is only one stage, and the loaded swf probably resizes itself according to the stage dimensions, so it ignores the properties of the loader.
If you can modify the code of the loaded swf, you can:
either add it a method like setSize(width, height), and invoke it from the main swf:
yourSWFLoader.content.setSize(width, height);
or access to the loader dimensions from the loaded swf, using something like:
width = parent.parent.width;
height = parent.parent.height;
The second solution assumes the SWF is loaded from a trusted domain.
I have a simple expandable advertisement which loads an external SWF file. The external SWF file contains an embedded video.
Using the UILoader component, I have loaded the SWF, added it to the stage and the video displays and plays fine.
The main issue is that I have a close button, which should unload the video, and stop it, essentially returning to the default state of the advertisement.
To unload the SWF, I am doing the following:
myUILoader.unload();
removeChild(myUILoader);
When I do this, the video and UILoader disappear from the screen. However, you can still hear the sound in the background, and if I load the SWF again, it creates multiple tracks in the background. Any suggestions?
There are a couple of things that could cause this. One is that the content inside your UILoader is adding event listeners to outside of itself. You can fix this by not allowing it to touch anything outside itself. I believe you can do this by placing it either in its own ApplicationDomain, SecurityDomain, or both. Consult the help for more details.
If this is not feasible, you can try SoundMixer.stopAll(), which will stop the obvious symptom, but will not fix the memory leak you probably have in this situation.
Another possibility, as Ronnie has alluded to, is that you still have a reference to the content of the loader somewhere. If you don't clear that, it will stay in memory.
However, there is another problem that can also cause this, which is that if there is navigation in the movie that skips over a frame that contains a MovieClip with audio set to "stream," the MC will be created but not fully instantiated and will stay in memory with no way to get any control over it or release it. I don't think this is what is happening from your description. If it is, the fix is to make sure that you visit the frame that contains the sound, however briefly, on the way to the other frame. This is actually something you might want to consider even without sounds, because it does occur any time you skip frames in nested MovieClips (you just have no evidence unless you profile the swf), and over time this will create a memory leak.
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.
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.
I have a child SWF file that has the Camera functionality.
It works fine if I run the child SWF by itself.
However, when I load the child SWF into a parent SWF, the Camera functionality does not work.
Doing some tracing it says that Camera access is denied. That happens without me even clicking on the deny button and in fact the usual security popup does not even show up.
I have added
import flash.system.Security;
flash.system.Security.allowDomain("*");
to both parent and child SWF.
What am I missing?
It's Flash 10 player.
Thank you,
Tee
Actually I figured it out.
In the HTML file, there is this wmode: 'direct'
That screw things up.
Thanks,
Tee