• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using a button to open an SWF in the same player...

Guest
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

Hello,

I seem to be having some trouble figuring out the proper kind of script that would allow me to use a button to call up and play a new SWF in the exisiting player (in this case, the projector). I am working on an interactive presentation which is now complete. However, I need a splash screen that opens on launch which offer different langauges. Each langauge has its own swf. I need a menu on the splash screen that the user can use to select their langauge by clicking the respective button that lanches that particular swf. Right now, I just need one button as the other langauge versions are still in production.

With that said, is there an easy way to launch an swf from the splash screen? I have tried a few different actionscripts but I seem to be always coming back to loadmovie script (which I havn't really mastered yet). My early attempts would load the new SWF but the current one stays in the player. It is kind of a mess.

Anyway, I am hoping there is a simpler option. I am a beginner at actionscript 3, so I am still figuring things out. I have worked with AS1 and AS2 and it seems those versions were linked swfs easier that AS3. I just want the button to leave the existing player and open the new swf (but leave the splash screen behind). This would function like website navigation, so I am not needing anything fancy. Most of the documentation I have read so far either assumes you want the swf to import and be part of the internal navigation or want multiple swfs loaded internally. That is definitely not what I want.

Anyway, thank you in advance for any help/insight.

TOPICS
ActionScript

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

For AS3 you want to look into usng the Loader class.  Try searching Google for a tutorial using "AS3 Loader tutorial".

The basics of the code would be...

var ldr:Loader = new Loader();

ldr.load(new URLRequest("your.swf"));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

Thank you, Ned. I am looking into some tutorials online. I have been dabbling with that particular class but have had mixed results. Mostly, I need the current swf to go away and the new swf to play. My best attempt so far only imported the swf but it still has the old one in view. Anyway, I ababoned that to try some other stuff but still havn't made progress. I am now attempting to make a new script using the loader class. I will post it when its done.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

Well, I think I got it working. The code I came up with seems a lot more simple than what I was experimenting with. I am pretty sure I did something earlier that was similar to this code but the current swf stayed with the player when the new one loaded, I am pretty sure the old swf is hiding underneath the new one but after some testing, the actual presentation is working as intended so I am waving the AS3 white flag and am accepting how this functions in its present state. I nearly gave myself a heart attack trying to get this simple function to work

Anyway, heres my "final" code. If anyone sees something that should be adjusted, please let me know.

play_iv.addEventListener(MouseEvent.CLICK, loadmain);

function loadmain(event:MouseEvent):void {

            var prevu_english:Loader = new Loader();

            prevu_english.load(new URLRequest("assets/PreVu - English.swf"));

            addChild(prevu_english);

}

Also, Thankyou Ned. You pointed me in the right direction. If I didn't keep looking at the loader class, I probably would have spent days doing trial and error until I got somewhere.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

Is the other swf you mention the one that has the code you use to load the second, or is it another swf that resides within a main file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

The swf that is executing the above code is the first swf the pops up which is the splash screen. The swf that is called up (ie PreVu - English.swf) is the linked file and contains the entire interactive presentation, which has alot of actionscript for various navigation functions. I would just like the splash screen SWF to go away when the second SWF is launched. After the second swf is running, the entire presentation works as intended and there is no more external SWFs to deal with. I suspect the entire presentation is playing over top of the original splash screen SWF. In the "old days", if I was to link a series of SWFs together, they would open one after the other and not embed themselves into the previous swf.

Essentially, I would just like to kill the splash screen when the presentation has launched but at this point, I am happy with the results even if the original splash screen is underneath the second SWF (if that is indeed the case). Of all the things I have done with this presentation, this was the biggest struggle so I think what I have will be ok. Now I have to figure out how to link a couple of PDF's without using navigatetoURL and then I am done.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2012 May 15, 2012

Copy link to clipboard

Copied

The splash screen would have to have been a loaded swf just like the presentation in order for it to be removable.  I cannot tell from your description if that is the case,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 15, 2012 May 15, 2012

Copy link to clipboard

Copied

LATEST

Yea, right now, the splash screen is the projector. I need an exe for this project as the client is having dvd's made and would like it to autorun. Anyway, I think I may have an idea how to unload it. I would just have to make a blank file and apply the same loader class but as a frame action and have it point to the splash screen. Mmmm, that might just work! I will play around with it tonight when I am home from work. Thank you for the insight!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines