A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Movieclip onpress

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    6

    Movieclip onpress

    Hi there.

    Basically trying to set a gotoAndPlay event on a movie clip (onPress / onRelease)

    I've tried laying an invisible button over the top of the movie clip which did work, but disabled the movie clip from playing on rollover.

    I found the following code on a Adobe forum, but don't really understand it.

    myMovieClip.onPress = function () {
    trace ("onPress called");
    };

    Any ideas would be much appreciated - i know questions like this might be a little tedious.

    THanks

  2. #2
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    If you want it to do something when the button is clicked, use:

    Actionscript Code:
    myMovieClip.onRelease = function(){
          trace("onRelease Called");
    }

    Otherwise, if you want it to do something when the button is pressed down, use:

    Actionscript Code:
    myMovieClip.onMouseDown = function(){
       trace("onMouseDown Called");
    }
    Last edited by Osteel; 05-12-2010 at 09:45 PM.

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    6
    Hey Osteel, thanks for replying.

    ...but how/where do i define the 'gotoAndPlay'?

  4. #4
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Sorry, I read your question wrong the first time.

    Well, just inside the function. So, assuming you want your main timeline to gotoAndPlay a frame:

    PHP Code:
    myMovieClip.onPress = function () {
         
    _root.gotoAndPlay(2); // change the 2 to the frame number you want
    }; 

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