|
|
|
#1 |
|
Junior Member
Join Date: Oct 2004
Location: atlanta, ga
Posts: 7
|
trigonometry
i am trying to make a 5 point star rotate clockwise while pulling apart (as diamonds), and as it rotates, to have 5 more diamonds come out from behind the original 5. i want the new 5 points to start at about 20% opacity and end up at 100% by the time they fall into place and complete the new 10 point star. from there, i want to use alpha, scale and rotation to create a kaliedoscope effect which eventually settles back into the 10 point star at 100% opacity. i have figured out that the best way to do this is with trig, but i am having trouble getting started. ideas? suggestions? tutorials? i sincerely appreciate any help offered...
Last edited by linedrivehitter; 10-12-2004 at 01:06 PM. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Here's a couple of scripts to get you started.
Everything you want to do can be done once you master the basic circular formula which looks like this: cx,cy are the center of the cirlce and radius is the radius of the circle
I would take some time studying this loop to figure out what is going on here . If you alternate between two radii, then you get a star shape. For example, if kNbrPoints is 10 and you alternate between two radii, you would get a 5 pointed star. Here's some code which uses this formula to make a spinning & mutating 5 point star shape.
For lots of kaleidoscopic effects - check out my website, link below. Last edited by jbum; 10-12-2004 at 08:14 PM. |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2004
Location: atlanta, ga
Posts: 7
|
thanks..this has been very helpful...i appreciate it. is it possible to do this starting with a movie clip symbol for each point/of the star, rather than actually drawing the shape with actionscript???
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Yes... let's say you have a series of duplicate movieclips named star1 - star5.
You can use a loop like the following to arrange them in a circular manner.
You may need to add a fixed amount to the rotatation to correct it. The script assumes that your basic diamond shape is pointing to the right. |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Oct 2004
Location: atlanta, ga
Posts: 7
|
thanks again...this is really a HUGE help to me. just wondering though...do you think it is a good idea to put each individual "diamond" MC into another MC already positioned into the star shape? would it work to re-use one MC symbol (diamond shape) and just rotate it to form the star? or would that mess up the trig? also, i guess that is what is giving me the most trouble right now...how to actually organize the MCs and the movie as a whole.
|
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Personally, I would use copies of one MC and rotate each copy. There are numerous examples of this kind of thing on my website, for example:
http://krazydad.com/bestiary/bestiar...ang_scope.html http://krazydad.com/bestiary/bestiary_bubbles.html http://krazydad.com/bestiary/bestiary_buttons.html Each of these movies have source code that you can download. Most of these kaleidoscopes actually make 10 copies of each object, in order to make a 5-pointed shape - each copy occupies a wedge corresponding to a 'half-diamond'. To get each half of the diamond I turn one of the copies around by setting the _xscale to -100. However, using whole diamonds, as you've described will work as well. The best way to learn this stuf is to do a lot of experiments and play with it until you have a better understanding of the math involved. |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Oct 2004
Location: atlanta, ga
Posts: 7
|
ok, that makes sense...so, in the first actionscript you posted, how would i modify that to not draw the segments but rather to act on the MCs with the images? the motion of that script is exactly what i am trying to do...
i sincerely appreciate your help! |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Here's a sample .fla to start you off.
There is a single movieclip in the library which is exported as 'diamond' which looks like a diamond on it's side. Here's the script:
You can also create additional sets of 5 diamonds which have different colors, and an offset added to the phase, to cause them to be interleaved with the others. Last edited by jbum; 10-15-2004 at 03:36 PM. |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Oct 2004
Location: atlanta, ga
Posts: 7
|
thanks again for your help...this is really close to what i am trying to do with this thing. just wondering...how do i control alpha and scaling in the actionscript? and looping? the end result is going to have text fading in and out around the star and eventually settle into the 10 point star with no further animation. about 15 seconds worth of animation total. i have attached a rough animated gif to show you what i am trying to accomplish. i guess once i understand how to handle scaling and alpha, i would just layer several instances of the MCs to create the movie? i really appreciate your input.
|
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
You can also animate _alpha, _xscale and _yscale in the movement function.
For what you want to do, you can do a tween in the movement function where each component you are animating has a start value and a stop value. A useful way to structure the movement function is like so:
One other thing, this statement: var r = (getTimer() - this.startTime)/this.duration; Gives you linear animation in that r smoothly travels from 0 - 1 in a straight line without easing. If you want easing, add the following line: r *= r*(3-2*r); Which'll give you ease-in and ease-out. Last edited by jbum; 10-18-2004 at 03:39 PM. |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Oct 2004
Location: atlanta, ga
Posts: 7
|
ok...i have modified diamonds.fla to use my diamond symbol appropriately sized and to rotate and expand/contract as i need it to in the first set of diamonds. i am confused about how to implement the "movement" script you posted last into diamonds.fla...played with it almost all night and couldn't get it to work. do i include everything in moveFunction (new) into moveDiamond (old)? or do i keep 2 separate functions? also, each individual diamond symbol is a movie clip...should i assemble the rest of the diamonds i need (20+) in the same layer or should i create a new layer for each set of 5 to control stacking?
you rock. |
|
|
|
|
|
#12 | ||||
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Quote:
Quote:
For me, the key to doing this kind of animation is a) thoroughly understanding what the sin/cos functions do (the earlier scripts) and b) being able to manipulate variables over time using a value that goes from A to B over time (the movement script). Understanding both of these things is crucial for successfully combining the scripts. Quote:
When I was learning to use a very complicated analog synthesizer years ago (the Buchla 200 system), my teacher said something very useful about experimentation. He basically said that it's good to play & experiment, as it often leads to interesting sounds. But it's also good to alternate this with another method, in which you start with an exact idea of what you want, and you work towards getting there in a very systematic way. Experimentation is good, if it leads to understanding, but blind experimentation can just needless complicate things and make them harder to understand. The best experimenation is systematic experimentation. The key to playing with a script is to make sure you understand as well as you can before you start tweaking it. Then, if you don't understand one variable, play with just that one variable until you understand it. Always make small changes and if the results are counterintuitive, figure out why, rather than changing it. Quote:
If you started with all 5 diamonds on the stage, then it's probably easier to create new layers (but don't fall into the trap of putting a different script on each layer - keep your script on a single 'script' layer). |
||||
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Oct 2004
Location: atlanta, ga
Posts: 7
|
well, i got the first 2 sets to work as i need them to, but those sets do not have alpha changes or scaling. after playing with this over the past 2 days or so, i am still having trouble "seeing" how to lay out the scripts and layers in my head...huge learning curve for me. can you maybe take a step back and give me a "bigger picture" explanation in terms of symbols and layers and actionscript??? thanks!
|
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|