Copy link to clipboard
Copied
I've been working on this button for a few days. This is my first project in Animate, and I am still trying to wrap my brain around timelines, instances, symbols, and ActionScript. I've created the various elements of the button and their animations, and here is the cycle for the mouse over "highlight" sequence:
It may be hard to make out so I will explain the cycle. There are two layers in the movie clip symbol mvc_IndexButton3_Combined, one for the BaseShape and one for the EndCap. I created a shape tween for both shapes to change their colours and to expand the End Cap inwards, and labelled the first frame on that tween "Over". Then I copied the tween animation and reversed the frames. I labelled the first frame of that tween "Out".
I have been trying to create "smart cursor on/off" effects, so that if the user takes the mouse cursor off the button while it is partway through the animation, the animation will reverse from whatever the current frame is back to what appears to be the initial state (but is actually the end of the reversed animation on frame 20). It seemed impossible to do this with a button symbol, so I am trying to make the movie clip act like a button with ActionScript code. These are all the things I have gleaned from other tutorials to get this far.
So back on the main timeline, I have applied an ActionScript to frame 1 to make this happen, but I am getting an output error:
This code:
mvc_IndexButton.addEventListener(MouseEvent.ROLL_OVER, SmartRollOver);
mvc_IndexButton.addEventListener(MouseEvent.ROLL_OUT, SmartRollOut);
function SmartRollOver(e:MouseEvent):void{
mvc_IndexButton.gotoAndPlay("Over")
}
function SmartRollOut(e:MouseEvent):void{
mvc_IndexButton.gotoAndPlay(20-(mvc_IndexButton.currentframe-5));
}
Results in:
ArgumentError: Error #2109: Frame label NaN not found in scene NaN.
at flash.display::MovieClip/gotoAndPlay()
at IndexButton_fla::MainTimeline/SmartRollOut()
I got the code from a YouTube video:
How do I properly execute this script?
currentframe should be currentFrame.
p.s. learn to use the trace() function to debug your actionscript. if you'd have used
trace(20-(mvc_IndexButton.currentframe-5));
you would have figured out the problem and the solution quicker.
Copy link to clipboard
Copied
currentframe should be currentFrame.
p.s. learn to use the trace() function to debug your actionscript. if you'd have used
trace(20-(mvc_IndexButton.currentframe-5));
you would have figured out the problem and the solution quicker.
Copy link to clipboard
Copied
Thanks, I'm a complete beginner, so it could have taken me weeks to stumble across the trace function. I've never done any coding outside of Papyrus either, so I'm not used to this capitalization paradigm.
Copy link to clipboard
Copied
you’re welcome.
Copy link to clipboard
Copied
that won’t be any easier given what you’re tr ying to do.
Copy link to clipboard
Copied
Out of curiosity, is there a way for me to use the "Out" frame label in
mvc_IndexButton.gotoAndPlay(20-(mvc_IndexButton.currentframe-5));