Copy link to clipboard
Copied
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 Murphy​ CatSulzmann​
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks Mark, I'm definitely going to try this
Copy link to clipboard
Copied
Your welcome! Hope it works out for you! Its a fun 'Event'!
Copy link to clipboard
Copied
It certainly is a fun Event
But I'm still struggling where to put your code and strangely it always reports a "syntax error" because it seems to have a problem with the first "{"
Of course I could be using it wrong but I've tried this out for hours now!
So I made a simplified version which you can download here.
It's set up exactly like my original file but this time I simply used differently coloured boxes instead of the single frames of my figure rendering.
The goal here should be, that if I'm swiping fast to the left or right when I test the movie and then release the mouse button it should continue to show the differently coloured boxes for a certain time until it eventually comes to a stop on a specific box.
I simply can't figure out how the onEnterFrame repeat or loop comes into play here.
Sorry for being such a noob but I normally don't write scripts
Find more inspiration, events, and resources on the new Adobe Community
Explore Now