View Full Version : Button
Drado
02-06-2005, 01:19 PM
How would i go about scripting a button so even when my coursor isn't on it the button still finishes it sequence?
Hi,
Use movieclips for your buttons instead of buttons. You can give any movieclip a button method with dot notation.....
mcName.onRollOver=function(){
do something;
}
mcName.onRollOut=function(){
do something;
}
Drado
02-07-2005, 09:05 PM
awsome do i replace the do something with something or do i really type that? ^_^ OH and thnx SOOOOO much :D
Drado
02-08-2005, 09:19 PM
My reall question now is how to a keep the clip from playing before i run my mouse over it? :(
Hi,
Put a stop action on the first frame of the movieclip. Target labeled frames as if the movieclip was a button.......
mcName.onRollOver=function() {
this.gotoAndStop('frameLabel');
}
mcName.onRollOut=function() {
this.gotoAndStop('frameLabel');
}
Getting in the habit of using frame labels is a good practice, but you can also target frame numbers....
mcName.onRollOver=function() {
this.gotoAndStop(2);
}
mcName.onRollOut=function() {
this.gotoAndStop(1);
}
Drado
02-09-2005, 01:35 AM
Ok, I must be doing something wrong.... let me tell me you what im doing. Ok first I make a MovieClip. I go into the movie clip and make a little movie sequence i want to have happen when the mouse moves of it. Then I click on the first frame of the movie clip and say the command for stop. From there I go back to Scene1 and single click on my movieclip and enter:
onClipEvent (load) {
Symbol1.onRollOver = function() {
gotoAndPlay(2);
}
That is the code that i would like to make the movieclip play with, but it never does. What am I doing wrong.
by any chance could you give me the code and tell me exactly where to put it? Sorry if I have been a bother, but I NEED to get this done for a project.
Hi,
Your mixing object and frame code. Object code requires an onClipEvent method. Frame code only requires an instance name. The two styles cannot be mixed. Example.....
Object code on a movieclip...
onClipEvent(rollover){
this.gotoAndStop(2);
}
Since the code is on the object a self reference of "this" tells the clip the code is to be executed on the object. Now, with frame code you can achieve the same rollover effect, but it is slightly different for frame code..
_root.mcName.onRollOver = function() {
_root.mcName.gotoAndStop(2);
}
The above frame code only needs the movieclip to have an instance name. You could still use the relative term "this" instead of _root.mcName. I figured showing an absolute path might be useful.
With that said, frame code is more desirable(in most cases) as it allows you to centralize your code and makes editing or upgrading much easier than having to select each object on stage to see it's code.
onClipEvent (load) {
Symbol1.onRollOver = function() {
gotoAndPlay(2);
}
The problem with the above sample is that you have a frame code event inside object code. The two methods cannot be mixed. Notice the difference in capitalization with frame methods vs object methods....
object methods...
load
enterframe
rollover
rollout
frame methods...
onLoad
onEnterFrame
onRollOver
onRollOut
Hope it helps
NTD
Powered by vBulletin™ Version 4.1.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.