Skip to main content
Hipreme
Participant
February 13, 2019
Question

Is there any event for when a sprite changes in a motion

  • February 13, 2019
  • 1 reply
  • 219 views

I have been programming a command for Animate(a jsfl file), and I'm implementing something with it's Animate's own 'Export Motion as XML'.

The problem is that after exporting it, it just gives its transform informations, and I'm needing to get the sprite/frame/image change on it's motion, I have been trying to find in it's documentation about looking IF the actual frame is a keyframe, and the closest thing is frame.hasMotionPath() and frame.isMotionObject()

Now, I'm wanting informations or triggers when the keyframe got different informations about more internal frames, if it changed the image during the motion, and to what image it changed

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
February 13, 2019

Hi.

You can detect keyframes by using the frame.frameStart and frame.duration properties.

Anyway, I think I didn't get what exactly you want to do.

Can you elaborate more or give some example?

Regards,

JC

Hipreme
HipremeAuthor
Participant
February 14, 2019

What I want is: know when in the motion it change the actual image it is using

Let's suppose that in a motion I make one symbol change its image from 'idle.png' to 'walk.png', it usually don't appear something like that

Can i know in the motion any attribute that says what image it is current using? As I know transform attributes is possible, but I didn't find anything about the image

JoãoCésar17023019
Community Expert
Community Expert
February 14, 2019

Hi again.

If I'm understanding correctly, you can use the libraryItem property.

Say for example you have a timeline with only one layer and that there are two keyframes with one bitmap in each keyframe. The first bitmap is called idle.png in the Library and the second is called walk.png in the Library.

You could write this:

var doc = fl.getDocumentDOM();

var timeline = doc.getTimeline();

var frames = timeline.layers[timeline.currentLayer].frames;

var current;

var previous = null;

frames.forEach(function(frame, index)

{   

    current = frame.elements[0].libraryItem.name;

   

    if (previous && previous !== current)

            fl.trace("changed" + ", " + index + ", " + previous + ", " + current);

   

    previous = current;

});

Please let me know if this helps you.

Regards,

JC