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

Get Current frame

Explorer ,
Feb 14, 2017 Feb 14, 2017

Hello, I have searched the forums and can't seem to get an answer on how to get the current frame using createJS. Any help would be much appreciated. This has always been an easy thing to do in past version.. Thanks

17.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

LEGEND , Feb 15, 2017 Feb 15, 2017

This is another example of something that was added with v0.7.1. If you were looking in 0.7.0 docs you wouldn't have found currentFrame.

Translate
LEGEND ,
Feb 14, 2017 Feb 14, 2017

this.currentFrame

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
LEGEND ,
Feb 14, 2017 Feb 14, 2017

Incidentally, if you type "createjs current frame" into Google, literally the first search result answers this question.

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
Explorer ,
Feb 15, 2017 Feb 15, 2017

Yes, I used Google first, thank you. Apologies for not mentioning that I already tried this.currentFrame. However, the output I am getting no matter where I am in the timeline is 0.

What I ended up doing is adding a ticker and manually incrementing it:

function handleTick(event) {

     theCurrentFrame = theCurrentFrame+1;

     console.log(theCurrentFrame);

}

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
LEGEND ,
Feb 15, 2017 Feb 15, 2017

http://www.createjs.com/docs/easeljs/classes/MovieClip.html#property_currentFrame

Or if you don't feel like using that, this.timeline.position provides raw access to the current frame.

If this.currentFrame is returning 0 when you think it shouldn't, then your this is wrong. Are you perchance accessing it in an event handler? If you create a new blank canvas document and stick an alert(this.currentFrame); in the tenth or whatever frame of the root timeline, does it not report the current frame?

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
Engaged ,
Feb 15, 2017 Feb 15, 2017

Hi aewu,

try what Clay suggests but remember if you insert 10 frames together up to 10 and put the code

this.stop();

alert(this.currentFrame);

in then it will read the first frame and be zero always.

But if you insert a blank keyframe on frame ten and add the code above to that frame you will get 9.

This caught me out.

Hope I explained that well?

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
LEGEND ,
Feb 15, 2017 Feb 15, 2017

https://forums.adobe.com/people/Gory+Greg  wrote

in then it will read the first frame and be zero always.

But if you insert a blank keyframe on frame ten and add the code above to that frame you will get 9.

Well, yes. Timeline code executes only in the frame you first define it in. Otherwise you'd have the same code executing over and over and over until your actions layer hits the next keyframe.

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
LEGEND ,
Feb 15, 2017 Feb 15, 2017

This is another example of something that was added with v0.7.1. If you were looking in 0.7.0 docs you wouldn't have found currentFrame.

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
New Here ,
May 01, 2018 May 01, 2018

Yes. And it comes right to this page.

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
LEGEND ,
May 01, 2018 May 01, 2018
LATEST

I'm guessing you're referring to the suggestion about Google. That's quite common, where a suggestion to Google something will end up showing the suggestion to Google something.

Did you have additional questions about this.currentFrame?

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