Groups | Blog | Home
all groups > flash actionscript > december 2004 >

flash actionscript : movie clips


combava
12/9/2004 2:13:10 PM
hello all, i've been having some trouble getting my movie clips to behave like
buttons.

i was given this reference :
http://www.macromedia.com/devnet/mx/flash/articles/using_timelines.html

but when i follow these instructions exactly, my movie clip button scrolls
through its different states as soon as the file is launched. and when i put a
stop on the first and only frame of my movie, or one the first frame of the
movie clip, none of the script works at all, it just stays static on the first
button state.

what am i missing ?!

ps i must also say that i have a ton of these movie clip buttons to do, so the
solution of putting a script in each and every one is really a tedious last
resort.

what i had been doing was sliding a highlighted graphic underneath the rolled
over or selected button. this was great, except that the transparent part of
the movie clip did not register mouse interaction (rollover etc). i tried to
fix that by making the bounding box the hit area using getBounds, but i was
never able to get it to work properly.



mostlyliquid
12/9/2004 10:27:17 PM
To get the movie clips hit area bigger, just put a transparent movie
clip within it, and make that clip the size of the hit area you want.
It increases the size of the clip so its hit area is bigger.

For the running button...think of the movie clip as a movie clip...it
doesnt know rollover, rollout, etc. So label frames within the clip
(remember to put stops, goto's, etc...its a movie clip) and target them
on events...so:
//on your movie clip instance
on(rollOver) {
gotoAndStop("over");
//'over' is a frame label within the clip with this code
}
on(rollOut) {
gotoAndStop("out");
}

This is off the top of my head so check it, but its the basic idea. You
can use whatever labels you want.

For multiple buttons with similar behaviors, you can use a function to
control all of them, so on the button something like:

on(rollOver) {
buttonOver(this._name);
}
Then make a funciton like:
function buttonOver(buttonName) {
buttonName.gotoAndStop("over");
}
Just another idea.
GL,
-John
kglad
12/10/2004 6:43:24 AM
you need a stop() in the first frame of your movieclip button. if your
movieclip has instance name mc on the _root timeline, then code simliar to the
following will work:

mc.onRollOver=function(){
this.gotoAndStop("over");
}
mc.onRollOut=function(){
this.gotoAndStop("up");
}
mc.onPress=function(){
this.gotoAndStop("down");
// do whatever else
}
AddThis Social Bookmark Button