currentFrame always 0 when export to Flash

Hi everyone
I have swf imported in my project that some movieclip that has 3 frames. the following code

trace(mc.currentFrame + “,” + mc.totalFrames);

will always print 0,1

this behaviour happens only when export to flash, it works correctly with HTML5

I have found the following issue raised before:

cab it be a bug in OpenFL?

This may be already fixed. Please see here

thank you for your reply, I am using OpenFL from Haxelib, which shows last update was on 29th March 2016, so I assume on next release of OpenFL it will be working, or if I use OpenFL from GIT it should be working

Hello. The link I’ve provided to you is the link for all pull requests of swf lib (and not of openfl). There are at least 2 pull requests that can help fix your bug.

I hope these pull requests will be merged soon but you can update the lib by yourself using these pull requests if you need it now.

thank you again for the reply, I tried to use latest lime, openfl and swf from git but my project failed to compile so I went back to the haxelib version, currently I solved it as I stated by calling event.stopPropagation(); however it is really nice to know that this will be fixed in next releases

@loudo Is there a specific pull request that you think would affect currentFrame on Flash?

I was thinking about the one you have commited yesterday and this one. But it seems to only affect currentLabel and not currentFrame, sorry for the confusion. The above linked commit fix the frame number called when you use a label in gotoAndPlay/Stop if I remember correctly.

I may take a look in this bug next time I use swf lib.

I just created a sample that should reproduce the problem, but currentFrame is returning properly on both Neko and Flash.

Is there any way to publish a sample somewhere of the SWF and the source code you are using, so I can try and see the same problem?

Thank you

I have created a new project to test it again

I am using OpenFL from Haxelib using FlashDevelop
I also created the swf in Adobe animate CC, I called the Movieclip class as TestMovie, I also gave a label for each frame as test1, test2, test3 etc.

here is my code:

var cc:TestMovie = new TestMovie();
var frm:Int = 3;
trace("expected label: test" + frm + " we got:" + cc.currentFrameLabel);
trace("expected frame: " + frm + " we got:" + cc.currentFrame);

the output:

Main.hx:28: expected label: test3 we got:null
Main.hx:29: expected frame: 3 we got:0

Main.hx:28: expected label: test3 we got:undefined
Main.hx:29: expected frame: 3 we got:3

Main.hx:28: expected label: test3 we got:null
Main.hx:29: expected frame: 3 we got:3

Actually another thing happened, when I added labels to the keyframes, the movieclip always shows the content of frame 1 in all targets, even though I set current frame to 3 in code, and in HTML5 and Neko they reported current frame 3 but display frame 1.

wait I see today Lime was updated to version 3.0.0, openFL to version 4.0.0 and swf to version 2.2.1 on haxelib

I am updating the libraries now and will check again

unfortunately updating lime, openFL and swf to latest version did not resolve the two issues

Okay, well maybe it’s related to adding frame labels. I’ll try again to recreate the issue early next week

@Mahmoud_Awad Could you also add a trace with cc.currentLabel and give your results.

@Mahmoud_Awad Could you also describe how you have created your timeline or maybe just make a screen capture of your timeline ?

I think swf lib may handle differently if your object is “keyed” or not.

@loudo here all info you have asked for:

Main.hx:25: expected label: test3 we got:null
Main.hx:26: expected frame: 3 we got:0
Main.hx:27: currentLabel:null

Main.hx:25: expected label: test3 we got:undefined
Main.hx:26: expected frame: 3 we got:3
Main.hx:27: currentLabel:undefined

Main.hx:25: expected label: test3 we got:null
Main.hx:26: expected frame: 3 we got:3
Main.hx:27: currentLabel:null

I changed the circle colour to blue in frame 1, and this is what I see on all platforms after i call


As you see it always shows frame 1 if I use labels.
if I remove them in Animate CC and export a new swf it works properly

However adding frame labels or remove them does not affect the currentFrame to be 0 on Flash target

Okay, latest commit to the SWF library repository should fix this :slight_smile:

Thank you very much for the fix, it always great to see Openfl getting better