one external swf playing over another, after a timer? - actionscript-3

I have two external .swf's. I need to have the first one played on load and then the second swf needs to be played over the first one after a timer.
If someone could help me out with a code I would greatly appreciate it!
(note: I'm not that good with actionscript, so bear with me)

Set up a timer, on timer event create a Loader object with the URL of the second SWF (it can only be loaded from the same server the parent SWF gets loaded) and add it as a child of the parent SWF.
The code examples are easily found on google, like this one:
http://kb2.adobe.com/cps/141/tn_14190.html

Related

How to get an external SWF to play on only one frame AS3?

I have an external SWF file loading perfectly fine to my Flash site. However, once the frame has been viewed, it carries on running in other frames when I only want it to play on frame 6. Any suggestions would be great. Thanks in advance.
Are you using a ViewStack? Make sure everything's embedded specifically into the right child of the ViewStack. If that's not the problem, edit your answer (don't just comment) so as to take the code you mentioned in your comment, and not only show that, but also the code whose greater context it falls under (like the scope of the URLRequest).

AS3 UILoader swf continues to play in the background

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.

SWF file seek information

Is it possible to get and set seek position of a swf file (either in ActionScript 2/3 or ActiveX API of Flash Player) ?
I tried to use frame number at first (to determine which part of the movie is being played) however sometimes whole animation has 2 frames and it does not help.
Any ideas?
Thanks.
if your loaded SWF contains all animation on the stage timeline ( i mean the top level ) then the progress you are seeking is:
var progress:Number = swf.currentFrame / swf.totalFrames;
if you want to set seek:
swf.gotoAndPlay ( progress * swf.totalFrames )
Also it can be that the all animation is not on the top level, but in the movieClip, which address you know, i mean stage.getChildByName ( 'something ).getChildeByName ('something )...
but if you have an swf where are multiple movieclips, and they are playing independantly, then nothing i can help....
Not without coding something in to the SWF as far as I know. Because animations in Flash can be in embedded MovieClips, or entirely scripted in a single frame, there is no easy way to detect the total playing time or how far an animation has progressed. Any get/seek functionality, or even a progress broadcast, would have to be scripted in the SWF and accessed through ExternalInterface.
Please be more specific about your problem. If your swf file is only 2 frames, then what is it that you are trying to seek through? Does your swf load a video, for example, and this is what you are trying to seek through? (In which case you can get properties of a video object's playback position and state).
Without more information, it's hard to provide a clear answer.

as3 removeChild issue

I'm loading some swf files at 0 on my stage. They are the pages of my site.
To change from page to page I use removeChildAt(0) and then I addChildAt("page_title", 0).
The problem is that removeChild dont delete the functions from the first swf file loaded (before unloaded).
How can I stop then?
Do I have to use other way to removeChild?
Thanx!
It sounds to me like you aren't actually removing them. First things first, removing something from the display list is only a visual/interactive change. It is still running until you remove any references to it, being event listeners or w/e, and then you must set it to null so that garbage collection will grab it on the next cycle.
If you are using Flash Player 10, spender is correct that unloadAndStop will work for you as they just recently created it to fix your very problem.
I just thought I should explain what is going on, because people should not only know about the fix, but why things happen.
One other suggestion, I wouldn't load these movies to stage, I would create a container Sprite/MovieClip to hold them, that way even if you add other things later, they are separated, clean, and easy to access through their parent (imageContainer_mc for instance).
Assuming you are loading with a Loader you can use the unloadAndStop method.
More info here:
http://www.gskinner.com/blog/archives/2008/07/additional_info.html
Alternatively, you can load the submovie into a different ApplicationDomain to insulate the loaded code from your main app. Take a look at the flash.system.ApplicationDomain class (it's a parameter to the Loader.load() method).

AS3 Preloader which loads itself, not an external swf

How can I create a preloader which does this? I have seen many examples of code to load an external swf, but never something that loads itself.
Thanks for the help, this is driving me crazy...
It's really simple. First you need to move everything except the preloader off the first frame.
Everything else is basically the same as an external preloader - the only difference is that you're checking the current and total size of the current movie, rather than a separate one.
alternatively ...
You can try FlashDevelop's Preloader template, makes it really easy