Tuesday, March 23, 2010

Movie Clip - onPress

HI, I have a movie clip as a button.



I want to fire the button when the user press over the mc.
When I use onPress - I need hold the mouse button for

the entire move to play - If i just press the mouse once, it
only plays for second.



I've tried all the event functions (including onKeyDown) but
not joy.



Any ideas?



ThanksMovie Clip - onPress
How about using onRelease?



my_mc.onPress = function (){

// play the movie

}



my_mc.onRelease = function (){

// stop and/or reset the movie

}





Movie Clip - onPress
You will probably also want to handle onReleaseOutside



my_mc.onRelease = my_mc.onReleaseOutside = function (){

// stop and/or reset the movie

}






KenpoMelvin,



%26gt; HI, I have a movie clip as a button.



I'm with you so far.



%26gt; I want to fire the button when the user press over

%26gt; the mc.



What does ''fire the button'' mean? Is this button the movie
clip you

just mentioned?



%26gt; When I use onPress - I need hold the mouse button

%26gt; for the entire move to play - If i just press the mouse

%26gt; once, it only plays for second.



The MovieClip.onPress event, like every event, occurs over a
very small

timeframe. An event is really just a message -- just a quick
burst -- that

in this case says, ''Hey, someone just pressed this movie
clip!'' What you

*do* with that message is up to you. I could see purposefully
coding an

onPress event to play a timeline, then coding an onRelease
event to pause

that timeline again. In which chase, as you describe, the
timeline would

only play while you held down the button.



%26gt; I've tried all the event functions (including onKeyDown)

%26gt; but not joy.



Maybe if you showed a bit of your code and explained what
you're after.

Let's see what you've got.





David Stiller

Adobe Community Expert

Dev blog,
http://www.quip.net/blog/

''Luck is the residue of good design.''





No comments:

Post a Comment