|
-
Hello
I found an example on: http://actionscript-toolbox.com/sample3drotator.php.
I tried it out but can't get it to work.
Is this possibzle in KM?
Regards
Henk
-
Hi Henk,
The only thing I can see that won't work in KM is attachMovie()
Code:
for (i=1;i<=nBalls*3;i++) {
this.attachMovie("expBall","mcBall"+i, i);
this["mcBall"+i].angle = i * Math.PI*2/nBalls;
}
What you will have to do is place the expBall movie clip somewhere inside the controlling movieclip and hide it by putting something like this in the "load" event.
(this.expBall._visible = false;)
then do something like this to the code above to workaround the attachMovie()
Code:
for (i=1;i<=nBalls*3;i++) {
expBall.duplicateMovieClip("mcBall"+i, i);
this["mcBall"+i].angle = i * Math.PI*2/nBalls;
}
I have not tried this, but I think that should work..
Hilary
--
-
Ok,
I tried it, and my code was ok - except for the this.expBall._visible = false;
Don't put that in because it will hide all the duplicated mc's.
Draw a small ball
select the ball
make it into a movieclip ("Shapes" > "Convert to movie clip")
name the movieclip "expBall" in the "shapes" dialog box (F9)
select expBall and make that into a movie clip
select this Movie clip on the stage (probably called mc2)and double click it to show the properties dialog box.
click the "Actions" under "behavior" tab in the properties box.
click the "+"
click "Action script"
and paste this code into the AS editor.
Code:
onClipEvent(load) {
perspective = 300;
anglespeed = Math.PI/72;
tilt = 3;
radius = 36;
nBalls = 12;
startx1 = 45;
startx2 = 145;
startx3 = 245;
starty = 30;
for (i=1;i<=nBalls*3;i++) {
expBall.duplicateMovieClip("mcBall"+i, i);
this["mcBall"+i].angle = i * Math.PI*2/nBalls;
}
}
onClipEvent(enterFrame) {
expBall._visible = false;
if (!_root.turnedOff) {
for (i=1;i<=nBalls;i++) {
mcrBall = this["mcBall"+i]
mcrBall.angle += anglespeed;
a = Math.sin(mcrBall.angle)*radius;
b = Math.cos(mcrBall.angle)*radius;
scalar = perspective/(b+perspective);
mcrBall._x = a*scalar + startx1;
mcrBall._y = b*scalar/tilt + starty;
mcrBall._xscale = scalar*100;
mcrBall._yscale = scalar*100;
mcrBall._alpha = (120-b)/2;
}
for (i=nBalls+1;i<=nBalls*2;i++) {
mcrBall = this["mcBall"+i]
mcrBall.angle += anglespeed;
a = Math.cos(mcrBall.angle)*radius;
b = Math.tan(mcrBall.angle)*radius;
scalar = perspective/(b+perspective);
mcrBall._x = a*scalar + startx2;
mcrBall._y = b*scalar/tilt + starty;
mcrBall._xscale = scalar*100;
mcrBall._yscale = scalar*100;
mcrBall._alpha = (120-b)/2;
}
for (i=nBalls*2+1;i<=nBalls*3;i++) {
mcrBall = this["mcBall"+i]
mcrBall.angle -= anglespeed;
a = Math.sin(mcrBall.angle)*radius;
b = Math.cos(mcrBall.angle)*radius;
scalar = perspective/(b+perspective);
mcrBall._x = a*scalar + startx3;
mcrBall._y = b*scalar/tilt + starty;
mcrBall._xscale = scalar*100;
mcrBall._yscale = scalar*100;
mcrBall._alpha = (120-b)/2;
}
}
}
Close the dialog boxes and test the movie
Phew!
A bit over the top, but someone else might find it useful
Hilary
--
BTW - all this great code comes from http://actionscript-toolbox.com/
[Edited by bridelh on 07-03-2002 at 11:28 AM]
-
undead creature
Search for the thread "Most wanted in v3.1 or v4.0" and you'll find more about "3D rotator" (?).
Also,I used a version of this script (a long time ago) in my main page.
cheers
-
Hi Hilary
Works fine, thanks!
Maybe a little over the top; reason for the question was: most examples or tutorials in flash are rather indistinct and confused (confusing), your explanation makes things clear.
Regards
Henk
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|