Highlighted

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

Community Beginner ,
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?

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

Views

109

Likes

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

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

Community Beginner ,
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?

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

Views

110

Likes

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
Mar 09, 2019 0
Adobe Community Professional ,
Mar 09, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 09, 2019 0
Advocate ,
Mar 10, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 10, 2019 0