creating a movie button

  • Hazzardusa
  • Newbie
  • Newbie
  • Hazzardusa
  • Posts: 5
  • Loc: San Diego, Ca

Post 3+ Months Ago

i am trying to set up a button that will play a movie when the button is RolledOver.
so far what i have done is set up the button area as the same size as the movie and set the actionscript to stop the movie when it first starts and wait until the button is rolled over for the movie to play.
then i need the button to play all the way through until the 30th frame where the computer will ask if the button is still has the mouse on top of it. if so, then i need it to go back to the 5th frame, if not, then it needs to play to the end.
at the end, i have it setup to go back to the beginning and stop.
here is my actionscript for the first frame

stop();
ButtonAU.onRollOver = function () {
play();
}

now that i think about it, i should probably make a loop that checks to see if the button is rolledover
anyone else know of a better way of doing this?
thanks in advance
mike
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

I'm assuming your "button" is the movieclip symbol?

If so...

Code: [ Select ]
ButtonAU.onRollOver = function(){
play();
}
  1. ButtonAU.onRollOver = function(){
  2. play();
  3. }
will work fine.

However the tricky part is checking if the mouse is still over the button. onRollOver only activates once, so you can't continually check if the mouse is over the clip.

However, that is where hitTest() comes in.

On frame 30 of your animation you can add in an action like this
Code: [ Select ]
if (this.hitTest(_root._xmouse, _root._ymouse, false)){
gotoAndPlay(5);
}
  1. if (this.hitTest(_root._xmouse, _root._ymouse, false)){
  2. gotoAndPlay(5);
  3. }
What that should do (untested, you may need to use _parent.hitTest, can't think straight right now) is when frame 30 is hit, it checks if the mouse is still over the clip area, if it is, then it goes back to frame 5... otherwise the gotoAndPlay action gets ignored and the animation finishes playing out.




This is of course assuming your button is a movieclip symbol that contains the animation.
  • Hazzardusa
  • Newbie
  • Newbie
  • Hazzardusa
  • Posts: 5
  • Loc: San Diego, Ca

Post 3+ Months Ago

thanks man, the hittest worked out great.
i just need one last piece of info to get this whole thing running.

i have deleted the button named buttonau
now what i have is the movie clip i want to play and the main scene.
what i have for the actionscript in the first frame is
BoneClip.onRollOver = function() {
BoneClip.play();
}
boneclip being the movieclip
this is the only thing that still doesn't work
i can either get it to play the main scene over and over again or to not do anything at all but i still havn't gotten this whole thing to work.
i am going to try a few other things and if i fix it, i'll post back.
thanks again.
mike
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Change BoneClip.play() to this.play() otherwise Flash will be looking for a clip called "BoneClip" within the movieclip symbol.
  • Hazzardusa
  • Newbie
  • Newbie
  • Hazzardusa
  • Posts: 5
  • Loc: San Diego, Ca

Post 3+ Months Ago

sweet, it finally works. thanks for all your help.
mike
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Yay :)
  • hexler
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13
  • Loc: Ohio

Post 3+ Months Ago

Hi. This thread was a big help with me in my learning the movie rollover function. Thanks much! I just have one thing to ask.

Can I reverse this action so when the user rolls off the movie, the animation plays in reverse?

So far I have a hand coming into screen with the current


Code: [ Select ]
mouseover.onRollOver = function() {
  this.play();
};
  1. mouseover.onRollOver = function() {
  2.   this.play();
  3. };


in place, but I'd like the hand to go in reverse and exit the screen when the user rolls off the movie. Can you help me out here Lostinbeta?

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.