View Full Version : Button help
bigjimmo
02-04-2003, 12:23 PM
I'm trying to make a button that when clicked, moves aroung like a dial on a radio. I want it to move 90 degrees when it is first clicked and then another 90 when it is clicked the second time. I have made a Movie clip symbol of the button so that on frame 2 it has rotated 90 and on frame 3 it has rotated another 90.
What action script can I use to make the movie clip go to frame 2 on the first click and frame 3 on the second click. I tried the following:-
on (release){
_root.buttonMC.gotoAndPlay(2);
}
on (release){
_root.buttonMC.gotoAndPlay(3);
}
This obviously didn't work, it just goes to frame 3 but what action script do I use for it to work?
thanks
Jim
avatar
02-04-2003, 01:12 PM
Hi bigjimmo,
Do u mean something like this?
bigjimmo
02-04-2003, 01:28 PM
Yes that is similar to what I want, I couldn't see the action script though as I am using Flash 5.
Could you please post the action script here?
Thanks for your help
Jim
avatar
02-04-2003, 01:48 PM
Hi Jim,
Make a button and put this on the button
on (press) {
_root.i ++;
}
Then put this button in a MC...
Put this code on the MC
onClipEvent (enterFrame) {
this._rotation = 90*_root.i;
}
:)
I just realized that u might not want it to jump to the next position but go there in a tween like motion? Right?
bigjimmo
02-04-2003, 01:49 PM
Thanks alot
Jim:D
avatar
02-04-2003, 01:52 PM
Is it ok like this or do u want it to move like a tweened animation...
bigjimmo
02-04-2003, 01:55 PM
That is fine the way it is. How complicated is it to add the tween effect?
Jim
avatar
02-04-2003, 02:04 PM
For the tweening I would add a function... which can get a little complicated...
But if this is what you where looking for, why make it more difficult? :)
bigjimmo
02-04-2003, 02:37 PM
So my button turns around four times (90 degrees). Is it possible so that I can play 4 different Movie clip each time the button is clicked. e.g. changing channels on a T.V.?
avatar
02-04-2003, 03:20 PM
Sure...
Do something like this
if (i == 1){
_root.gotoAndPlay("whateverlabel")
} else if (i==2){
_root.gotoAndPlay("whateverlabel2")
}
...
But make sure that if you only have 4 mc you set i back to 0 when it reaches 4
:)
avatar
02-04-2003, 07:44 PM
If u were still wondering how to get a tweened effect...
Replace the code on th MC by this one...
onClipEvent (load) {
equiv = 0.3;
// this is the weak part of the code
// 180/angle MUST BE an integer
angle = 90;
}
onClipEvent (enterFrame) {
if (_root.i>=360/angle) {
_root.i = 0;
}
finalRot = angle*_root.i;
if (finalRot>180) {
finalRot -= 360;
dRot = Math.abs(this._rotation)-Math.abs(finalRot);
} else if (finalRot<=0) {
dRot = Math.abs(this._rotation)-Math.abs(finalRot);
} else {
neg = false;
dRot = Math.abs(finalRot)-Math.abs(this._rotation);
}
this._rotation += (dRot*equiv);
if (Math.round(drotation+targ._rotation) == rotation) {
targ._rotation = rotation;
}
}
bigjimmo
02-04-2003, 09:00 PM
Thanks for that avatar, you certianly know your action script.
Thanks for your help
Jim
bigjimmo
02-05-2003, 10:52 AM
OK, i'm nearly there. I've written the following code:-
if (i==1){
_root.channel2MC._visible=false
_root.channel3MC._visible=false
_root.channel4MC._visible=false
}
else if (i==2){
_root.channel1MC._visible=false
_root.channel3MC._visible=false
_root.channel4MC._visible=false
}
else if (i==3){
_root.channel1MC._visible=false
_root.channel2MC._visible=false
_root.channel4MC._visible=false
}
else if (i==4){
_root.channel1MC._visible=false
_root.channel2MC._visible=false
_root.channel3MC._visible=false
}
}
This works fine to start with but for example, if I click twice channel2MC plays, then if I click one more time nothing happens. I don't know what to do to resolve this problem?
Just one last thing, who do I set i back to 0?
thanks for your help,
Jim:D
avatar
02-05-2003, 11:54 AM
Can you put that piece of .fla online...
Otherwise it's gonna be hard to help ;)
Vitaly
02-05-2003, 12:58 PM
Is that how you want it to rotate? There's not much as though.
Vitaly
02-05-2003, 01:12 PM
I just hate how those attachments work. Anyways, you can download the files I attached from here http://vitaly.intervelopers.com/rotatingbutton.swf
http://vitaly.intervelopers.com/rotatingbutton.fla
bigjimmo
02-05-2003, 01:16 PM
ok here is the file.
avatar
02-05-2003, 02:08 PM
This should do the trick...
bigjimmo
02-05-2003, 02:35 PM
I've just looked at the .swf and it works perfectly, thanks alot. One small problem is that i'm using flash 5 and I cannot open the .fla file.
Sorry to be a pain but could send me a flash 5 compatable version or tell me how you did it.
Sorry about the inconvenience.
Cheers
Jim:D
avatar
02-05-2003, 02:53 PM
No probs :)
bigjimmo
02-05-2003, 02:58 PM
Brilliant, thank you very much!
I will leave you in peace now and will stop bothering you!
I really appreciate your help.
Cheers
Jim:D :D :D
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.