Cryoma Member of the Year
Reputation: 198
Joined: 14 Jan 2009 Posts: 1819
|
Posted: Fri Mar 01, 2013 11:26 pm Post subject: as3 quetsion |
|
|
edit derp fixed it
Rusty as fuck haven't coded in like two years, halp plzzzzzzzzzzzzz
I'm trying to use an event listener for mouse event buttonDown, which is a boolean, and I can't remember for the life of me how to set this up.
I want to have two functions that are executed always (onenterframe) depending on the value of the boolean.
To elaborate, I have a mc instanced "shape" with a short animation in it, I want the animation to play when the user is clicking on it, but when they mouseUp I want it to reverse and play backwards to the start.
I had this code set up but it only plays forwards and doesn't rewind at all, which is why I'm trying to figure out the boolean instead of the two constants:
| Code: | import flash.events.MouseEvent;
var rewind:int;
shape.stop();
shape.addEventListener(MouseEvent.MOUSE_DOWN, reportClick);
shape.addEventListener(MouseEvent.MOUSE_UP, reportUnClick);
shape.addEventListener(Event.ENTER_FRAME, checkRewind);
function reportClick(event:MouseEvent):void
{
rewind = 0;
shape.play();
}
function reportUnClick(event:MouseEvent):void
{
rewind = 1;
}
function checkRewind(event:Event){
if (rewind == 1) {
prevFrame();
}
}
|
|
|