-
A script to make a movieclip move in a circle
Hey this is my script to draw a rectangle. I want to write a script for it to move in a circle of certain diameter at a certain velocity. Is this possible?
Code:
this.createEmptyMovieClip("mEye001", this.getNextHighestDepth());
mEye001.lineStyle(0, 0xFF0000);
mEye001.beginFill(0xFFFF00, 100);
mEye001.lineTo(100, 0);
mEye001.lineTo(100, 100);
mEye001.lineTo(0, 100);
mEye001.lineTo(0, 0);
mEye001.endFill();
mEye001._x = 100;
mEye001._y = 100;
-
Registered User
hi,
This post should help.
-
i found this script for moving the movieclip in the link you gave me, however, i can figure out how to put them together...
Code:
onClipEvent(load)
{
cx = Stage.width/2; // coords of center of circle (center of screen, in this case)
cy = Stage.height/2;
rad = 100; // radius of circle
speed = 6; // speed of travel (seconds to make a complete circuit)
speedScale = (0.001*2*Math.PI)/speed;
}
onClipEvent(enterFrame)
{
var angle = getTimer()*speedScale;
this._x = cx + Math.sin(angle)*rad;
this._y = cy + Math.cos(angle)*rad;
}
-
may i need to add a listener somewhere... ideas? the output says "**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 19: Expected a field name after '.' operator.
mEye001.onClipEvent(load) {"
Last edited by 72monkeys; 05-02-2006 at 08:43 AM.
-
Flashmatics
Code:
var centerX:Number = Stage.width/2; // coords of center of circle (center of screen, in this case)
var centerY:Number = Stage.height/2;
var radius:Number = 100; // radius of circle
var radians:Number = 0;
var speed:Number = 0.1;
makeSquare();
var mcSquare:MovieClip;
var nMove:Number;
function makeSquare():Void{
mcSquare = _root.createEmptyMovieClip("mEye001", _root.getNextHighestDepth());
mEye001.lineStyle(0, 0xFF0000);
mEye001.beginFill(0xFFFF00, 100);
mEye001.lineTo(100, 0);
mEye001.lineTo(100, 100);
mEye001.lineTo(0, 100);
mEye001.lineTo(0, 0);
mEye001.endFill();
mEye001._x = 100;
mEye001._y = 100;
nMove = setInterval(mover, 1000/24);
}
function mover():Void{
mcSquare._x = centerX + radius * Math.cos(radians);
mcSquare._y = centerY + radius * Math.sin(radians);
radians += speed;
}
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
|