Highlighted

"Smart" Rollover Effect on MovieClip Button & Argument Error #2109

Explorer ,
Jul 14, 2019

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:

IndexButtonHighlightCycle.gif

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:

Screenshot (14).png

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?

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

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.

TOPICS
ActionScript

Views

181

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

"Smart" Rollover Effect on MovieClip Button & Argument Error #2109

Explorer ,
Jul 14, 2019

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:

IndexButtonHighlightCycle.gif

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:

Screenshot (14).png

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?

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

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.

TOPICS
ActionScript

Views

182

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 14, 2019 0
Adobe Community Professional ,
Jul 14, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 14, 2019 2
Explorer ,
Jul 14, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 14, 2019 0
Adobe Community Professional ,
Jul 14, 2019

Copy link to clipboard

Copied

you’re welcome.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 14, 2019 0
kglad LATEST
Adobe Community Professional ,
Jul 14, 2019

Copy link to clipboard

Copied

that won’t be any easier given what you’re tr ying to do.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 14, 2019 1
Explorer ,
Jul 14, 2019

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)); 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 14, 2019 0