Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Action scripts on buttons 1

Status
Not open for further replies.

Jusenkyo

Programmer
Aug 16, 2002
295
GB
Hello all

OLDNEWBIE has given me an example of a button which fades in and out on rollover, using action scripts. (Thread 250-649509)

There are two tweens that do all the fading, and three actionscripts that stop the movie at the beginning, middle and end of the movie.

So essentially, when you roll the mouse over the button, the colour fades to white, and when you move the mouse off, it fades back to grey.

I realise that I could just ask OLDNEWBIE for some changes to be made to the button... but does anyone else know how to always make the button roll back to grey, if the user just rolls quickly over the button, and so not activating the second part of the movie?

Hope that makes sense!

If you need an example, just let me know...

Cheers guys!
(Especially OLDNEWBIE)
 
The scripts I've proposed use play & reverse play upon rollover and rollout of the button, and can't really be tripped unless the mouse pointer quickly leaves the whole movie area.
What are you now asking for exactly? Some kind of built-in checking & delay that would prevent the button from changing color, if the rollover was only a quick and maybe unintentional one?

Regards,

cubalibre2.gif
 
remove the middle (stop) command in the middle? so the movie always moves from beginning to end?

cut out some frames in the 2 tweens, so the fade is quicker and less noticable when touched by accident?

 
well, I would like the image to change whatever, but I want it to always return back to the original colour, unless the mouse is on the button, then I want it to stay white until the mouse is removed...
 
There is no stop action in the middle of the tween in my script. Removing frames in the tween would only make the change visible faster.

Regards,

cubalibre2.gif
 
That's what my scripts do! I really don't understand what you're asking for.

Regards,

cubalibre2.gif
 
If you look at - the image fades back to the original blue box if you move the mouse over it quickly... So it almost stops executing the rest of the movie and returns back to the original image...

The only problem is... I cant seem to see how you achieved this effect! Thats what i want to know!

Cheers
 
I've achieved that effect with a hitTest script that's placed on the clip itself, and that script is commented, explaining it. Right-click the clip and select actions to see the script!

Regards,

cubalibre2.gif
 
This code?...

onClipEvent (enterFrame) {
// if the mouse IS over the button ...
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
// if the button is NOT at 100% alpha...
if (_root.fade._currentframe<_root.fade._totalframes) {
// keep playing the next frame...
_root.fade.nextFrame();
}
// if the mouse is NOT over the button
} else {
// if the button is NOT at 0% alpha
if (_root.fade._currentframe>1) {
// keep playing the previous frame...
_root.fade.prevFrame();
}
}
}


I dont have the fade to alpha effect on my button!... I need this kinda code, but for it to say:

On frame 7: If mouse over, stop();
Else
Play (7);

 
I really don't get it... I must be too old!
Can you post your .fla so I may understand what you're trying to achieve?

Regards,

cubalibre2.gif
 
Alas, I have no webspace to post it!!!

But I'll try and explain again!

From the comments on the above code, I think that it does the following:

If the mouse is over the button, and the alpha is not 100%, continue playing the movie...
if the mouse is NOT over the button, and the alpha is not 0%, then continue playing the previous frame.

I want something very similar to this, but I haven’t got the alpha effect on my button. So I need another trigger to allow this to happen.
Allso - my button is identical to - but with different images...

Make more sense?
 
Here is the current code for when the movie initialises:

onClipEvent(initialize){
this.onRollOver=function(){
play();
}
this.onRollOut=function(){
play();
}
this.onDragOut=this.onRollOut;
}
 
Your last post is again very confusing... But to answer the previous one, those &quot;alpha&quot; comment lines are in fact just a figure of speech, trying to describe (obviously failing in your case!) what's happening through the script. Alpha is not the trigger on this, it's basically based on the mouse's position and the actual position of the playhead within the clip...
In other words, if the mouse is over the button (clip)and that the playhead's position is smaller than the last frame of that clip, than play the clip until the playhead reaches the last frame and stops. On the other hand, if the mouse is no longer over the button (clip), then go to the previous frame until the clip is no longer bigger than 1 and stops. Alpha has really nothing to do with all of this and is not the trigger, the playhead's position is.

Regards,

cubalibre2.gif
 
Ok... makes sense.

Any idea how I adapt this code to work for my button?
 
If you can post your .fla, e-mail it to me. Zip it up!
You'll find e-mails if you hit my handle and check my profile.

Regards,

cubalibre2.gif
 
OK OLDNEWBIE, I have emailed my .fla file to you... thanks in advance for anything you can do to help!!
 
Thanks a million OLDNEWBIE.. You are an absolute STAR*!
 
However, I have another problem!!! (Does it never end I hear you cry!!)

The FLA works perfectly, on its own... however, I am inserting the flash object into a cell on my webpage... so whenever you rollout of the box, it stops playing the movie - and so stays on whatever colour you are currently on!!

I am thinking that I may have to re-do my whole banner and menu bar in flash, that way the stage will be much bigger, and the rollovers should work.

However, when I import my images from fireworks into flash, they go either all weird colours, or really fuzzy!!

Any more advice from anyone?

P.S. I will email you something to explain if you need more info!

 
If you check out the menubar in:

I know its way way better than anything I could ever do, but I want this kind of effect where the image fades from one thing to another whenever the mouse goes over it, and back again whenever it leaves - Which is what OLDNEWBIE did 4 me (cheers buddie) - But it doesnt seem to want to work when I put the fla inside a cell on my HTML site!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top