One SWF on top of another

24 views
Skip to first unread message

illias...@gmail.com

unread,
Oct 3, 2007, 3:20:12 AM10/3/07
to SWFObject, illias...@jim-media.com
Hi, I've run into a bit of an issue where I think SWFObject could
provide the quick fix thats needed.

What I would like to do is have one flash swf load and play, and then
upon completion I'd like that SWF to be unloaded, and in its place
another swf with the exact same params be loaded, and all of this
automatically.

I'm wondering if its possible to have one SWF directly under another
and have little or no issues? (if there's better way I'd love to know)

Thanks in advance.

Philip Hutchison

unread,
Oct 3, 2007, 3:57:37 AM10/3/07
to swfo...@googlegroups.com
it sounds like you're asking two completely different questions.

1. when a SWF ends, can it unload itself and load another SWF automatically?

Yes. you can write a javascript function that uses SWFObject to embed each SWF.  when the first SWF is finished, you can use a bit of actionscript (getURL would be easiest) to invoke your javascript function, which would then delete the content of the flash DIV and write a new SWF.

something like:

[ in HTML ]
function loadSWF(swfname){
  //swfobject code here
}

function deleteandloadSWF(swfname){
  //find existing swf and delete or overwrite
  //call loadSWF(swfname) to load the next SWF
}

[ in last frame of SWF ]
var nextSwfName:String = "nextswf.swf";
getURL("javascript:deleteandloadSWF('" +nextSwfName +"')");


2. layering one SWF on top of another SWF (via DIVs in HTML) can be done, but i'd question if it's the smart move.  you'd be better off building a single SWF that contains everything you need, or building a 'player' SWF that loads external SWFs as movieclips.  layering them in the HTML will probably be messy and likely to cause some issues.  plus if you layer them you'd probably use wmode=transparent, which will bog down Flash Player.

my 2 cents.  :)
- philip

illias...@gmail.com

unread,
Oct 4, 2007, 5:10:39 PM10/4/07
to SWFObject
Okay I guess I was a bit confused before. Ahat I want to do is what
you state in '1'. I'm not sure what code I should write for my
javascript though. I have a line in my AS3 code that says:
navigateToURL(new URLRequest("javascript:loadNextSWF()"), "_self");

This basically calls a javascript method i call loadNextSWF() on the
current window/page, thing is I don't really know exactly what methods
I should be calling inside my loadnextswf() method. Also I'm not sure
but I'm guessing using navigateToURL which is the equivalent of getURL
is going to refresh the page, which isnt too big of a deal, as I'd
rather stay away from using ExternalInterface. Thanks again for the
help.

Reply all
Reply to author
Forward
0 new messages