Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
suchi89

Load new swf on clicking skip intro button

Recommended Posts

I am a newbie in Action script 3. I have 2 swf files. One is intro.swf and another is the main.swf. When clicking the skip intro button in the intro.swf i need to close the intro and play the main.swf. Also when the last frame of the intro reaches, the main.swf should start playing. Is there any way in AS3 to do these two parts?

 

Link to comment
Share on other sites

Hi and welcome to the GreenSock support forums?

 

Have you tried LoaderMax's SWFLoader? It makes it very easy to load swfs.

 

I don't know how much AS3 you know so I'll just give you a little to help you get started

 

 

import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.SWFLoader;


var intro:SWFLoader = new SWFLoader("intro.swf", {container:this, x:100, y:100, onComplete:completeHandler});
intro.load();


function completeHandler(e:LoaderEvent):void{
trace(e.target) // the loader that fired the event
trace("intro complete");
}

I've attached the CS5 fla and swf.

 

 

 

 

 

 

 

basic_SWFLoader_CS5.zip

Link to comment
Share on other sites

Hi and welcome to the GreenSock support forums?

 

Have you tried LoaderMax's SWFLoader? It makes it very easy to load swfs.

 

I don't know how much AS3 you know so I'll just give you a little to help you get started

 

 

import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.SWFLoader;


var intro:SWFLoader = new SWFLoader("intro.swf", {container:this, x:100, y:100, onComplete:completeHandler});
intro.load();


function completeHandler(e:LoaderEvent):void{
trace(e.target) // the loader that fired the event
trace("intro complete");
}

I've attached the CS5 fla and swf.

 

Thanks for the reply. I have modified this script as below and the skip intro button is working fine.

import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.SWFLoader;

skipbutton.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
	var intro:SWFLoader = new SWFLoader("main.swf", {container:this, x:0, y:0});
	SoundMixer.stopAll()
	intro.load();
}

But I have one more problem. When timeline reaches last frame of the intro.swf, the main.swf should be loaded. Both the swf has different audios. I have put the another script in the last frame of the intro.swf. The main.swf of is loading without its audio, but the audio of the intro.swf is replaying for it. What I need is when the main.swf is loading the intro's audio must be stopped and the start playing main.swf's audio itself.Please help.

import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.SWFLoader;


	var intro:SWFLoader = new SWFLoader("main.swf", {container:this, x:0, y:0});
	SoundMixer.stopAll()
	intro.load();
Link to comment
Share on other sites

Glad to hear you are making progress.

 

I don't know why exactly main.swf's audio isn't playing but I would recommend the following

 

1: unload the intro.swf when you are done with it and flush it's content

intro.unload(true)

2: don't create a new SWFLoader for main with the same name as the one you were using for intro.swf

 

not so good:

var intro:SWFLoader = new SWFLoader("main.swf", {container:this, x:0, y:0});

better:

var main:SWFLoader = new SWFLoader("main.swf", {container:this, x:0, y:0});

Here are the docs for SWFLoader which may be helpful at some point:

http://api.greensock.com/as/com/greensock/loading/SWFLoader.html

 

 

Let us know if you still have trouble with the audio.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×