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

How to stop at current frame on click

New Here ,
Mar 29, 2017 Mar 29, 2017

I just built a button with insert->new symbol... from the menu. For the "mouse over" frame, I converted it to a new symbol(movie clip), because I want to display many different pics on different frames when I have mouse over it. It does work. In addition, I want to make it stop at current frame when I click on it. Someone tell me I should write some codes and get the frame ID of the current frame, then stop on it. How to get the frame ID and stop at the frame I want?

TOPICS
ActionScript
1.5K
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

Community Beginner , Mar 30, 2017 Mar 30, 2017

If you put this code in the MovieClip you created. This will work, but it may not be what you envision. You'll want to create a new actions layer and make sure the code is in frame  1.

addEventListener(MouseEvent.MOUSE_OVER, stopOver);

function stopOver(event: MouseEvent): void {

stop();

}

addEventListener(MouseEvent.MOUSE_OUT, playOut);

function playOut(event: MouseEvent): void {

play();

}

This might be better, this way your view were will be able to move the mouse out of the way to completely see your

...
Translate
LEGEND ,
Mar 30, 2017 Mar 30, 2017

You should only need to execute a stop(); command pointed at the timeline that you wish to have stop.

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
Community Beginner ,
Mar 30, 2017 Mar 30, 2017
LATEST

If you put this code in the MovieClip you created. This will work, but it may not be what you envision. You'll want to create a new actions layer and make sure the code is in frame  1.

addEventListener(MouseEvent.MOUSE_OVER, stopOver);

function stopOver(event: MouseEvent): void {

stop();

}

addEventListener(MouseEvent.MOUSE_OUT, playOut);

function playOut(event: MouseEvent): void {

play();

}

This might be better, this way your view were will be able to move the mouse out of the way to completely see your image, but it does involve a click. Again, put this inside the MovieClip you created:

addEventListener(MouseEvent.CLICK, clickEvent);

var t: Boolean; // true or false variable, starts off as false.

function clickEvent(event: MouseEvent): void {

if (!t) {  // Looks to see if the 't' is faults, if it is, the movie stops.

stop();

} else {  // Otherwise, it plays.

play();

}

t = !t;    // This toggles the 't' variable to whatever it wasn't; false becomes true or vice versa.

}

If you're just experimenting, either option will work. Otherwise, you'll have to be more specific in your description in relationship to what you want to accomplish.

Good luck.

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