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

Actionscript 3 coding to return to home page 10 secs after sound file stops

New Here ,
Jan 27, 2013 Jan 27, 2013

Hi..

I am having some problems with my Flash Project.

At the moment the whole thing works but I now need it to do something I have never done before.

Basically, the user will select a page and the project will then run, via actionscript 3.0 coding, a sound file and display the appropriate page within the timeline.

I have a back button that once tapped will return to home page.

I now need it to return to home page 10 secs after the sound file has stopped as well as keep the function of the back button.

What do I do?

I can provide the coding I am using if required.

I am currently using Flash Pro CS6 on a Win 7 Pro PC.

Thank you for your help

Michael

TOPICS
ActionScript
592
Translate
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

correct answers 1 Correct answer

LEGEND , Jan 27, 2013 Jan 27, 2013

If you need to time something happening you have a couple of choices of timer elements to choose from. 

The least complicated would likely be to use the setTimeout() function and have it call the same function that the button uses.  You just need to assign the function's event argument to null (as in:  function buttonFunctionName(evt:MouseEvent=null) ).

Another option is to use the Timer class.

Both of these options are documented in the help files if you need to find how to use them.

Translate
LEGEND ,
Jan 27, 2013 Jan 27, 2013

If you need to time something happening you have a couple of choices of timer elements to choose from. 

The least complicated would likely be to use the setTimeout() function and have it call the same function that the button uses.  You just need to assign the function's event argument to null (as in:  function buttonFunctionName(evt:MouseEvent=null) ).

Another option is to use the Timer class.

Both of these options are documented in the help files if you need to find how to use them.

Translate
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
New Here ,
Feb 03, 2013 Feb 03, 2013

Thank you Ned for your help, however as I do not really understand how the settimeout function works, it has now made me more confused.

I think I have nutted out what I am trying to say.

Essentially my project is like a web page if you like.

I have six individual pages which all display a picture and play a sound file.

What I would like to do is after each page is selected it will play a sound file, I then want it to wait 10 secs and then go back to a

home page (which will be frame 1) or if they are impatient there is a back button that directs you back to frame 1.

I have included the code used by the back button to manually get back to frame 1 either whilst the sound file is playing or after it has finished

back_btn.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToGoToAndStopAtFrame_1);

  function fl_ClickToGoToAndStopAtFrame_1(event:MouseEvent):void

{

    gotoAndStop(1);

}

/* Click to Stop All Sounds

Clicking on the symbol instance stops all sounds currently playing.

*/

back_btn.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToStopAllSounds);

function fl_ClickToStopAllSounds(event:MouseEvent):void

{

    SoundMixer.stopAll();

}

I just want it to return to home page automatically once the sound file is finished and there is nil input from the touch screen. (This will simulate someone walking away midway and leaving it with 2nd  web page showing.)

I hope this makes sense.

Thank you

Translate
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 ,
Feb 03, 2013 Feb 03, 2013

Show the code you use to initiate the sound.  That is where you need to initiate the timing activity.

You do not need two functions for handling the same event and it will probably be less confusing for you to understand and keep track of if you don't do what you show...

back_btn.addEventListener(MouseEvent.CLICK, fl_BackBtnClick);

function fl_BackBtnClick(event:MouseEvent):void

{

    gotoAndStop(1);

    SoundMixer.stopAll();

}

Translate
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
New Here ,
Feb 04, 2013 Feb 04, 2013

So sorry Ned, please disregard.

Thank you so much for your help, hopefully my husband will know what to do with this information as I was just passing it on to him.

Sorry again

Nicole

Translate
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 ,
Feb 04, 2013 Feb 04, 2013
LATEST

No problem Nicole, you're welcome. 

Translate
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