• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AS3 Next and previous buttons - jump to keyframe

Guest
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

You know, I used to know AS2.  It was fun.  It was easy.  And then after a break I've tried to pick up AS3 and everything is going horribly, horribly wrong.  Even searching online forums I can't work out how to get the solution I need.  I could revert back to AS2, but I am determined I am not going to let AS3 beat me.  Someone please help!

I am trying to add Next and Back buttons that will jump users between keyframes.

I have a layer called Actions, and a layer called Buttons.  The Buttons layer has two buttons of different types with Instance Names of "btn_Next" and "btn_Back" respectively.

Both layers have keyframes at frame 30 and frame 60.

The actions on frame 30 and frame 60 both say "stop();"

At present the action on frame 1 on the Actions layer says:

import flash.events.MouseEvent;

stop();

btn_Back.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler1);

function mouseDownHandler1(event:MouseEvent):void

{

prevFrame();

}

btn_Next.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);

function mouseDownHandler2(event:MouseEvent):void

{

nextFrame();

}

When I press Ctrl + Enter I am currently getting the error message

"TypeError: Error #1123: Filter operator not supported on type builtin.as$0.MethodClosure. at [Filename]_fla::MainTimeline/frame1()"

and the buttons do nothing.

Where am I going wrong? 

The thing I get particularly confused about reading other posts is whether I need to reproduce this code on each keyframe, or only on Frame 1 of the Actions layer.  I tried adding it to each keyframe, but then got errors about duplicating my functions.  So I tried removing the functions from all keyframes after the first one, but that didn't work either. 

I tried changing my instance names on each keyframe and changing the code on each keyframe, but that didn't seem to work either.  And it seems like a really inefficient way to do things.

Someone please help me. 

Mary

TOPICS
ActionScript

Views

8.4K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 04, 2013 Mar 04, 2013

there's nothing in that code that would trigger that error.

create a new flash, add your two buttons, then copy and paste that code into your new fla.  retest.

Votes

Translate

Translate
Community Expert ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

there's nothing in that code that would trigger that error.

create a new flash, add your two buttons, then copy and paste that code into your new fla.  retest.

Votes

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
community guidelines
LEGEND ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

The code you showed has nothing to do with the error the way it is.

Most probably you have an extra dot elsewhere in the code.

For example this syntax will throw the same error - note dot between addEventListener and (

btn_Back.addEventListener.(MouseEvent.MOUSE_DOWN, mouseDownHandler1);

Votes

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
community guidelines
Guest
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

I found the rogue fullstop, so the error message is no longer coming up.

But the buttons are still not doing anything.  I click the Next button, and nothing happens.

Votes

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
community guidelines
Community Expert ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

in frame one of the timeline that contains that code you need two buttons or movieclips (with instance names btn_Next and btn_Back) on-stage.  if those buttons are clickable, that code will work.

you can use the trace function to test if you're clicking the correct buttons/movieclips.

Votes

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
community guidelines
Guest
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

A co-worker helped me resolve this issue.  There were two things I was doing wrong:

  1. I had added keyframes to my Actions layer.  I created a new actions layer that ran across the entire presentation and added the code to that.
  2. I was expecting the nextFrame(); code to jump to the next keyframe (e.g. from frame 1 to frame 30), rather than just a single frame (e.g. from frame 1 to frame 2).  We deleted all the additional frames, so now the entire file has three frames, and there are no keyframes for the Buttons layer.

Thank you for hte help kglad and Andrei1.

Votes

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
community guidelines
Community Expert ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

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
community guidelines