Copy link to clipboard
Copied
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
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.
Copy link to clipboard
Copied
this.currentFrame
Copy link to clipboard
Copied
Incidentally, if you type "createjs current frame" into Google, literally the first search result answers this question.
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Yes. And it comes right to this page.
Copy link to clipboard
Copied
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?