PDA

View Full Version : actionscript makes baby jesus cry <-- new and need help



ValmontStudios
April 12th, 2002, 04:48 PM
I've been with flash since 4, but have always been very animation heavy. I've just recently realized that i need to start to learn to replace some of this animation with actionscript to cut down on filesize, etc. and i only know enough action script to do things like preloaders and basic menu functions... and so... my big question is this.
how in gods name do you rotate a symbol by attatching actions to it. Not instantaneous rotation, but the tweening kind. Thanks for reading.
Valmont

I am not Jubba
April 12th, 2002, 04:55 PM
you need to add the rotation each time the movie clip enters the frame hence you use

onClipEvent(enterFrame){
_rotation += 10
}

this will add 10 to the rotation of the movieclip, and it will keep adding 10 as long as that clip is on the mainstage. :) try to experiment.

ValmontStudios
April 12th, 2002, 04:59 PM
thanks, i was trying to do some setProperties stuff, where i could interactively force it to rotate, but not just have it... do it. thanks - btw by "10" in
onClipEvent(enterFrame){
_rotation += 10
}
do you mean speed or degrees?
thanks again
Valmont

I am not Jubba
April 12th, 2002, 05:26 PM
ten is the number of degrees. to make it spin faster try 20. that will get the spin. as far as interactivity..what exactly are you trying to do?

upuaut8
April 12th, 2002, 08:21 PM
Actually it's "radians" isn't it?

I am not Jubba
April 12th, 2002, 09:11 PM
i thought it was degrees, because in my analogue clock, i have to multiply the minutes and seconds by numbers that equal 360 to get degrees...i might be wrong, i'm under a lot of stress so don't listen to me...:) but i think its degrees...

I am not Jubba
April 12th, 2002, 09:18 PM
this is me being too @#%$ lazy to look for the edit button. :) but look at this


seconds._rotation = s*6

this is part of the code from my clock. There are 60 seconds in a minute, and 360 degrees in a full rotation, so 60*6 = 360

s*6 = 360 when s = 60. Every time the seconds goes up, the arm will rotate 6 degrees. I think that the 10, is degrees. try this...make a clip with a vertical line, and a circle on top, and put


onClipEvent(load){
_rotation = 45
}

it should go from | to / that being a 45 degree rotaiton....

I think I'm right, but again, I'm stressed and retarded...actually i saw a very good explanation of trig on the FOE Math Creativity forum, heres the link....

check out this link, it looks pretty good, i didn't look over it all the way yet, but i get my computer back sunday, and then I'll get my book (hopefully) next friday or so!

home.velocitus.net/leroyc.../index.htm (http://home.velocitus.net/leroyclimb/trigonometry/index.htm)

ValmontStudios
April 12th, 2002, 10:12 PM
nice logic with the clock there - never put any real thought into it. yeah i figure it's degrees, and the rotattion is continuous, but fluid, so thanks. what i'm trying to do is get down in code this menu system i've had stuck in my head for 2 weeks - i made a simple, mostly animation example you can see here: oroborous (http://www.valmontstudios.net/temp/movie4.swf)
i'm trying to set it up for some nice rollover effects with the circles, the end result being that the circles represent subdirectories, and each part of the circle represent a file - obviously a menu for a website - thanks for all your help thus far
Valmont

upuaut8
April 13th, 2002, 01:55 AM
hey, I'm lost when it comes to that stuff. I know what code to use to make it do.. but radiens to degrees and back again? I get lost.

ilyaslamasse
April 13th, 2002, 08:09 AM
Actually, our friends at Macromedia's have cut the pear in 2 (French idiom, never mind). When you write _rotation = 45 ; 45 is degrees, of course, because if you rotate your thing by 45 radians, 1st it's not at all precise, since radians are multiples or fractions of PI, and then it's huge !! That would be something like 7 times a full rotation.

Now if you use Math.cos for instance. The correct usage of this function is with radians. If you write Math.cos(45),you'll get something totally... not what you want.

pom 0]

ValmontStudios
April 13th, 2002, 05:53 PM
next question - how to control the direction and occurrence of the rotation based on actionscripted buttons... anyone?
Valmont

ilyaslamasse
April 13th, 2002, 08:35 PM
Well, making _rotation ++ will produce a clockwise rotation, whereas _rotation -- will produce a counterclockwise rotation.
What do you mean by occurrence ?
pom 0]

ValmontStudios
April 13th, 2002, 08:44 PM
actually i found that _rotation -= or _rotation += does the same things, but by occurence i mean, to have a button control the three states of the rotating object - stop, clockwise rotation, and counterclockwise rotation.

I've found that by adding a keyframe in the instance of the rotated symbol that has the counter action of the symbols rotation, i can stop the rotation, but only while the button mode (rollover, rollout, onclick, etc.) is active.

So, what happens is, i have this clockwise rotating symbol, and a button that stops it for a split second.

The only other thing i did, was using an animation that was exactly the opposite speed of the rotation on the symbol, and pointing the button to the frame that this animation is on..
but this will never have the functionality i need.

*sniff*
help

I am not Jubba
April 13th, 2002, 09:01 PM
I was wrong. Poms got it. just modify his code as necessary.

ValmontStudios
April 13th, 2002, 09:12 PM
::you want something that will rotate when a button is pressed right? or stop rotating.::

not exactly - here's a run down on exactly what i'm trying to do - after the flash loads, there is a symbol rotating on the stage and a button. on rollover, the symbol slows to a stop, and grows 120%. On rollout, it returns to normal. onclick, it stays where it is, and ignores the rollout script, so that it stays stopped and resized.
any ideas?

valmont

ilyaslamasse
April 13th, 2002, 09:45 PM
Put this kind of code in your clip that has to be called rotating :


onClipEvent (enterFrame) {

_xscale=_yscale+=(scale-_yscale)/7;

_rotation = (rot-_rotation) ;

}
Then in your button
on (rollOver) _root.rotating.bigger scale...I'm dead tired. I hope this made sense.

pom 0]

ValmontStudios
April 13th, 2002, 09:57 PM
::wants to cry:: no i didn't get it.. ack

ilyaslamasse
April 14th, 2002, 07:26 AM
There. No more cries. Shshshshhhhh.
I'm gonna make you a nice fla, just for you. Happy now ?

pom 0]

ilyaslamasse
April 14th, 2002, 08:29 AM
Sent.
pom 0]

ValmontStudios
April 14th, 2002, 05:05 PM
Lord god in heaven, you did in probably ten minutes what i've been experimenting to do for a week - i'm going to take this apart, lick each piece, and put it back together.
thanks pom.
let you know how it goes
Valmont

ValmontStudios
April 14th, 2002, 05:21 PM
pom, is the button action all that is involved? if so, what regulates the rotation speed, or is there a built in default? and secondly, if you wanted to have the circle stay in its enlarged position onclick, what would you do?

My, probably way too far outside the box, solution (and the only thing i can think of) is to have the onclick of the button be goto to a frame in which the button doesnt exist, and a replacement one does... otherwise even after you click, as soon as you rollout, the circle will resize. An easier way maybe?

Thanks for the fla by the way - it combined what i've spent a week learning into one simple step.

(btw, if anyone wants to see the code or fla pom sent me, ask him first, as i don't want to just make his things public w/out his permission)
tnx again
valmont

[[[Later Edit]]]
pom, i just saw the other actionscript - i was accidentally looking in the symbol rather than the instance - so i guess you can ignore the first question while i go look at the rest of this wonder
[[[/End Edit]]]

ilyaslamasse
April 14th, 2002, 07:42 PM
Took me a good dense half an hour to be honnest. I had a hard time with that rotation thing. And don't worry about giving the code, it's not copyrighted :lol:
About this click thing, i think you could solve that with a bunch of markers, as always.
on (press) {pressed=1;}
on (rollOut) {if (!pressed) scale = 100 ;}
or something like that.

pom 0]

ValmontStudios
April 14th, 2002, 08:08 PM
yeah, like i said in the opener of this topic, i'm completely new to actionscript, and have always been focused on using straight up animation to solve all my problems, so i don't get this marker thing, but i'll experiment..
check back here!
I'll probably be back again real soon - (and knowing my world, that tag didn't work.. sniff..)
thanks again
valmont