Hi y’all. This is my first time posting here, and I’m really hoping someone can lend me a hand. I’m pretty new to this Flash thing in general, but slowly managing to get a handle on it.
What I’m trying to do is this:
let’s say we have a four button navigation, with the button placed side by side on a horizontal plane. I can make the button roll on and off ok, and even change color on mouseDown. I need to take it a step further though…
When you rollover button 1, it changes color. When you roll out it changes back. When you press it changes color again. Now I want the button to, on release, rotate 180 degrees (to verticle) and move to the left. The three buttons to the right will move to the left along with the first. The clicked button will no longer rollover in this moved verticle state, but it will still be hot taking you back to the same landing page whenever clicked.
Now the other three buttons which are still horizontal but have moved to the left along with the 1st button, are still hot and function exactly as the first. When you click on button #2 or 3 or 4 though, the firs button rotates back to horizontal with everything moving back to the very starting position before the newly clicked button then shifts and rotates.
I’ve got a fairly clear example of what I’m trying to do. See the attached .fla file. I got the 1st button to almost do what I intend. Clicking on the second button returns the 1st to its original state, but without a smooth transition.
I must say I’m disappointed in the response I got to this post. Is it that what I’m hoping to do can’t actually be done? If so, I wish someone would tell me and ease my mind.
If what I’m asking IS possible, I just need to be pointed in the right direction.
Ok. So I will remove the buttons and use movie clips instead.
The 1st of the four buttons is no sweat. Pressing the button jumps to another frame that tilts the button down. Now that button one is down, if someone clicks on button #2, button 1 should tilt back up while button 2 is tilting down. Button two, and #s 3 & 4 should all also shift left as button 2 is tilting down.
How can you tell Flash to move several movies in sync at the same time? Should I create different scenes for each button? Its would seem that there has to be a better way. I’d have to create something like 14 scenes total… I think.
I hope I’m explaining myself alright. I’m still quite new to Flash, and haven’t learned all the jargon for it yet.
a way I thought of- use the _rotation property of each of the movie clips. So you do a [AS]movieclip.onEnterFrame = function(){ movieclip._rotation+=((targetrotation-movieclip_rotation)/speed);[/AS] , where speed is how fast you want the clip to rotate, and targetrotation is the degrees you want the movie clip to be rotated to (i.e. 90 if you want the clip to rotate 90 degrees). Also, if you want the clips to pivot from the left edge, set the registration point to the left edge.
This way, the clip will gradually rotate towards the target degrees, whatever you set that to. You could do an [AS]movieclip.onMouseDown = function(){ targetrotation =90;}[/AS]
if you wanted the clip to rotate to the 90 degree position when you clicked on it, and you could also set the target rotation to 0 for every clip but the one you clicked on if you want all the other clips to go back to 0 when you click on any of the other ones. Not sure if this makes sense, I suck at actionscript and it’s 2 AM…
hope it helps.
-C
I think you need to get a better understanding of Flash first. Doing different scenes would not be the right approach to go at this. Before you can walk, you must crawl; so start crawling.
Thanks Corey for your time and effort trying to help me out.
And yes, TaylorTAP, you are right - sorta.
What good is crawling or walking if you’ve got nowhere to go?
Seriously though. I didn’t think that what I wanted to do was going to be so tricky. I knew enough to know that scenes wasn’t the way to go. So I figgered I’d ask for a little help & guidance. That’s what this forum is for, isn’t it? One could easily respond to every question asked with your conveniently canned response.
Heck. I figure some of you peeps out there could write the script for what I wanna do in your sleep.
Yeah, there’s a lot of people here who could write it in their sleep. How are you gonna get there unless you figure it out?
Run through the actionscript tutorials until you get a good idea of how it works a little bit, if you haven’t already.
Most important thing I’ve learned yet? If you put a movieclip.onEnterFrame = function(){} line in the main timeline, or attach an onClipEvent(enterFrame){}
action to a movie clip, the code within the curly brackets executes every frame the movieclip is running. So if you want to slide movieclip instance “mymovie” to the left until it’s at (20,y), you put this code on the main timeline, and name the instance of the clip you want to move “mymovie”:
[AS]
mymovie.onEnterFrame = function(){
if(_root.mymovie._x>20){
_root.mymovie._x= _root.mymovie._x- 1;
}
}
[/AS]
That way, every time the movie clip enters a frame (which is every frame while it’s playing, 12fps by default), it changes the _x property by one, sliding it to the left one pixel 12 frames per second. That’s how you do a tween in actionscript. You would do a similar function to change the _rotation property of your clip gradually, and another function to change it back when you clicked again, and maybe call the same “change back” function in the other movie clips when you click on the one. You’ll figure it out.
-C
Thanks Coreyem. I appreciate your help, and agree with you that I need to figure this thing out with my own blood sweat and tears. Believe me, I’m trying. And slowly getting there. I wouldn’t want someone to go and write the whole script for me, I wouldn’t learn anything that way.
The snippet you gave me was extremely helpful, and I think it to be the key I’ve been looking for. I have just one question about it…
How can this event be triggered by onMouseUp? The code you gave me worked just fine until I switched onEnterFrame to onMouseUp. Now Instead of moving to the desired location in a sweeping animation as it should, it only moves one unit per mouse click.
[AS]
one1.onMouseUp = function(){
if(_root.one1._rotation>-30){
_root.one1._rotation = _root.one1._rotation - 1;
}
[/AS]Is there a simple way to make the animation play onMouseUp until it reaches it’s intended location?
I swear, I’m about this close ----> <---- to getting my mind around this. Thanks again for your help.
You’re pretty close. You want to setup the onEnterFrame function so that it uses a variable instead of a hard-coded number, and then you change the variable with the onMouseUp function. That way, the clip will constantly rotate towards the position indicated in your variable, so if you want to have the clip rotate somewhere else later (i.e. back to the starting position), you just change that variable.
so you would do[AS] one1.onLoad =function(){
startingrotation = 0;
targrotation = 0;
rotationspeed = 5;
}
You’re telling the clip to rotate towards the target rotation by 20% of the difference between target and current rotation, every frame. That produces an “easing” effect, where it rotates quickly at first, then gradually slower. If you don’t want that effect, you can just do the ol “this._rotation= this._rotation -1;” thing. You can change the speed by changing the [COLOR=red]rotationspeed[/COLOR] variable, and the target rotation (in degrees) by changing the [COLOR=red]
targrotation[/COLOR] variable. Another handy feature of this method is that in your onMouseUp functions for the other buttons, you can set the targrotation value for the other movie clips back to their starting position by executing this code: