A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Duplicate function?

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    29

    Duplicate function?

    I am using keyboard events in the Actionscript. Frame 1 is a keyframe with the following function:

    stage.addEventListener (KeyboardEvent.KEY_UP, keyUpHandler);

    function keyUpHandler (event:KeyboardEvent):void {
    gotoAndStop(2);
    }
    Frame 2 is also a keyframe. It has the following function:

    stage.addEventListener (KeyboardEvent.KEY_UP, keyUpHandler);

    function keyUpHandler (event:KeyboardEvent):void {
    gotoAndStop(3);
    }
    While it's true that these functions have the same name, they are on separate keyframes! That shouldn't result in a Duplicate Function error, should it?

  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    5
    One thing that you should get used to while learning AS3, is to try not to use timelines.
    Use the document class for all your code. Say for example you have a movieclip on frame 1, and another one on frame 2.

    You could simple write code that removes movieclip1, and adds movieclip2. This would replicate the effect of gotoAndStop(x).

    Anywho, in answer to your question, they do count as duplicate functions because in the end, all the code you put in frames gets moved into a document class anyways, thus all the functions you declare in any frame are all in one class. So effectively, they ARE duplicate functions.

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    29
    How do I replicate "gotoAndStop" with Actionscript?

    I have created a small application that represents what I am rying to build. It is a 4-frame timeline with 4 blue boxes. The arrow keys should move the red cursor to the corresponding blue box. But, it moves in random directions. What am I doing wrong?

    Here is the file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center