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

How do I use Action script to make a symbol start to play whenever another symbol does?

Community Beginner ,
Mar 09, 2019 Mar 09, 2019

Copy link to clipboard

Copied

import flash.events.MouseEvent;

stop(); //pause the timeline

addEventListener(MouseEvent.CLICK, Go);

function Go(e: MouseEvent) {

gotoAndPlay("Frame1");

}

So this function plays an animation of a trap door opening.

In another symbol, I have the ball that falls out of the trap door and moves around the screen. What Action script do I have to put in the other symbol to make it start playing when function Go starts to play?

Views

199

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

correct answers 1 Correct answer

Advocate , Mar 10, 2019 Mar 10, 2019

Hi James

What ClayUUID is saying is that you have to extend your Go-function as below. First let's assume your ball-symbol is a movieclip. Give it an instance name in the properties panel. Call it simply "ball".

Now within ball in the timeline add a layer  and call it "actions". Here in the first frame code:

stop();

If you want the ball to stop again after the falling-out-of-the-trapdoor animation has finished, then add a stop(); in the last frame too.

I also assume that you have a button which start

...

Votes

Translate

Translate
LEGEND ,
Mar 09, 2019 Mar 09, 2019

Copy link to clipboard

Copied

You don't. You make the Go function tell both of them to start playing.

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
Advocate ,
Mar 10, 2019 Mar 10, 2019

Copy link to clipboard

Copied

LATEST

Hi James

What ClayUUID is saying is that you have to extend your Go-function as below. First let's assume your ball-symbol is a movieclip. Give it an instance name in the properties panel. Call it simply "ball".

Now within ball in the timeline add a layer  and call it "actions". Here in the first frame code:

stop();

If you want the ball to stop again after the falling-out-of-the-trapdoor animation has finished, then add a stop(); in the last frame too.

I also assume that you have a button which starts the whole process (going to Frame1 and making the ball play. Let's call this button for this example "gobtn".

Then in the frame/actionscript where you have the Go-function, extend it like this:

import flash.events.MouseEvent;

stop(); //pause the timeline

gobtn.addEventListener(MouseEvent.CLICK, Go);

function Go(e: MouseEvent) {

    ball.play();

    gotoAndPlay("Frame1");

}

You have to make sure that in the frame where the Go-function is, the ball is also present. See that in the first ball-stop()-frame any visual content itself is not present or invisible.

That should do the trick

Klaus

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