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
Printable View
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()
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.Code:for (i=1;i<=nBalls*3;i++) {
this.attachMovie("expBall","mcBall"+i, i);
this["mcBall"+i].angle = i * Math.PI*2/nBalls;
}
(this.expBall._visible = false;)
then do something like this to the code above to workaround the attachMovie()
I have not tried this, but I think that should work..Code:for (i=1;i<=nBalls*3;i++) {
expBall.duplicateMovieClip("mcBall"+i, i);
this["mcBall"+i].angle = i * Math.PI*2/nBalls;
}
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.
Close the dialog boxes and test the movieCode: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;
}
}
}
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]
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