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

Trying to get the animation to play only though the play button.

New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

I don't understand actions all too well. I'm trying to get my animation to play only when "play" is pressed, the whole thing plays by itself instead.

Views

95

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
Community Expert ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

LATEST

Hi.

 

You need to first stop the timeline you're trying to control and then add an event listener to a button to play the same timeline.

 

Here are code suggestions for both HTML5 Canvas and AS3 documents:

 

HTML5 canvas

var root = this;

root.start = function()
{
	root.gotoAndPlay(1);
};

if (!root.started)
{
	root.stop();
	root.yourPlayButton.on("click", root.start);
	root.started = true;
}

 

AS3

import flash.events.MouseEvent;

function start(e:MouseEvent):void
{
	gotoAndPlay(2);
}

stop();
yourPlayButton.addEventListener(MouseEvent.CLICK, start);

 

Regards,

JC

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