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

play from currentFrame and stop on targeted frames in animate CC (html5)

Community Beginner ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

I was struggling with this code and still not find correct way of doing this. so posted here.

 

All frame are in my nested movieclip (mc_1). now I want to go on target frame by clicking on the button inside movieclip from the currentFrame as shown in below image.
here is my code:

 

this.stop();

var a = this;

a.mc_1.t.addEventListener("click",test_1)
function test_1(){
if(a.mc_1.currentFrame > 0){
var tds = 29 +(a.mc_1.currentFrame-a.mc_1.currentFrame); //wanted to get targeted frame number
a.stage_freezeobject.gotoAndStop(tds); \\ this will directily jump onto frame29 but I wanted to play from current frame and stop on 29.
}

any help will much appreciate.

 

below are 2 examples of two different currentFrames and play direction whereas 1 direction is normal play and 2nd direction is reverse play. it will be good if both ways are possible, if not, then 1 of this will fullfill my need.

 

Captureaaa.JPG

Views

1.5K

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

Community Expert , Jul 23, 2020 Jul 23, 2020

when currentFrame > target frame, you need to start a loop (eg, ticker) to play backwards and if < play forwards.  eg

 

// assuming target is defined
function test_1(){
if(a.mc_1.currentFrame > target && !createjs.Ticker.hasEventListener("tick")){ 
createjs.Ticker.addEventListener("tick", reversePlayF);
} else if(a.mc_1.currentFrame < target && !createjs.Ticker.hasEventListener("tick")){ 
a.mc_1.play();
createjs.Ticker.addEventListener("tick", playF);
}
}
function reversePlayF() { a.mc_1.gotoAnd
...

Votes

Translate

Translate
Community Expert ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

when currentFrame > target frame, you need to start a loop (eg, ticker) to play backwards and if < play forwards.  eg

 

// assuming target is defined
function test_1(){
if(a.mc_1.currentFrame > target && !createjs.Ticker.hasEventListener("tick")){ 
createjs.Ticker.addEventListener("tick", reversePlayF);
} else if(a.mc_1.currentFrame < target && !createjs.Ticker.hasEventListener("tick")){ 
a.mc_1.play();
createjs.Ticker.addEventListener("tick", playF);
}
}
function reversePlayF() { a.mc_1.gotoAndStop(a.mc_1.currentFrame-1);
if(a.mc_1.currentFrame==target){
createjs.Ticker.removeEventListener("tick", reversePlayF);
}

function playF{
if(a.mc_1.currentFrame == target){
a.mc_1.stop();
createjs.Ticker.removeEventListener("tick", playF);
} }

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
Community Beginner ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

Thank you so much.

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
Community Expert ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

LATEST

you're welcome.

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