A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] rewind button in AS3

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    8

    resolved [RESOLVED] rewind button in AS3

    Im trying to create a rewind button to take me to the start of my movie clip.

    I have entered this code but the button doesnt seem to want to work:

    rewindBtn.onRelease.addEventListener(MouseEvent.CL ICK); void
    function (){
    movieMc.seek(0);
    }

    Instead, it comes up with this error:

    TypeError: Error #1010: A term is undefined and has no properties.
    at Videodoc_fla::MainTimeline/frame1()


    Can someone please suggest a way to solve this problem or suggest some new code?

    Thanks

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Unless you have a clip called "onRelease", that shouldn't be there. addEventListener takes two arguments, not one: The type of event, and the function to call. The listener function must take a single parameter of type Event, or a specific Event subclass, like MouseEvent. Your "void" declaration of the function return type is out of place. Although you can use an anonymous function as an event listener, this makes it very difficult to remove that listener later. Usually, you will want to use a normal named function.

    Code:
    rewindBtn.addEventListener(MouseEvent.CLICK, rewind);
    
    function rewind(e:MouseEvent):void{
      movieMc.seek(0);
    }

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    8
    Wow, you make it look so easy! It works too! Thank you so much, I still have a lot to learn about AS3 as you can tell lol.

    Thanks a bunch!

Tags for this Thread

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