Skip to main content
Participant
June 13, 2017
Question

Continuing Interactive Animation on Mouse Release

  • June 13, 2017
  • 1 reply
  • 1075 views

Hello, first of all this is my first time I created a discussion so please forgive me if I posted this in a wrong area

So in the past few weeks is started to work with Adobe Flash Professional CS6 and a little bit with Actionscript.

Due to another forum I was able to create my desired interactive turntable animation which you can see on this linked website.

Though I'm not completely satisfied with the result, as my animation ends very abruptly.


I actually want it to continue for some frames when I release the mouse button like in this linked example, so I asked the person what specific code he used but he seems to be inactive. In the comment section he only wrote that he used Actionscript 2.0 to achieve this effect.

I hope anyone can help me with this problem as I simply can't figure out how to achieve the desired effect.

It's also no problem if someone has a solution with Actionscript 3.0.

Here is the code I used in my example with Actionscript 2.0:

mc.stop();

var startX:Number;

var startFrame:Number;

var changeDistance:Number;

var travelDistance:Number;

mc.onPress = pressHandler;

mc.onRelease = releaseHandler;

mc.onReleaseOutside = releaseHandler;

function pressHandler():Void {

startX = mc._xmouse;

startFrame = mc._currentframe;

this.onMouseMove = moveHandler;

}

function releaseHandler():Void {

this.onMouseMove = null;

}

function moveHandler():Void {

changeDistance = Math.round((mc._xmouse - startX) / 15);

travelDistance = startFrame + changeDistance;

if (travelDistance > mc._totalframes) {

mc.gotoAndStop(travelDistance % mc._totalframes);

} else if (travelDistance < 0) {

mc.gotoAndStop(mc._totalframes + (travelDistance % mc._totalframes));

} else {

mc.gotoAndStop(travelDistance);

}

}

I really appreciate your time and thank you very much already

Ned MurphyCatSulzmann

This topic has been closed for replies.

1 reply

Community Expert
June 13, 2017

hey there!

I think what you are looking for is on onEnterFrame Event.... the onEnterFrame events repeats at the frame rate (if frame rate is 15FPS- it repeats 15x per second.

addEventListener(Event.ENTER_FRAME, onEnterFrame) {

    //put stuff to repeat here!

   trace("is this working?");

}

Put the stuff you want to repeat inside the function. Would love to help more but its a lot of coding to write it all out!


onEnterFrame Event (click to read about it on Adobe's Site)

Hope this helps!

cheers!
mark

headTrix, Inc. | Adobe Certified Training &amp; Consulting
Participant
June 14, 2017

Thanks Mark, I'm definitely going to try this

Community Expert
June 14, 2017

Your welcome! Hope it works out for you! Its a fun 'Event'!

headTrix, Inc. | Adobe Certified Training &amp; Consulting