-
help to combine two scripts
Hey! I have two scripts. The first one draws square and moves it in a circle trajectory. However, I need a circle moving instead of the square. The second script draws a circle but I can't figure out how to combine these two scripts. Any ideas?
Firtst script:
Code:
// SCRIPT TO MOVE ALONG A CIRCLE TRAJECTORY
var nCenterX001:Number = Stage.width/2;
var nCenterY001:Number = Stage.height/2;
var nRadius001:Number = 100;
var nRadians001:Number = 0;
var nSpeed001:Number = 0.01;
// SCRIPT TO DRAW A SQUARE
drawSquare001();
var mcSquare001:MovieClip;
var nMotionInterval001:Number;
//
function drawSquare001():Void {
mcSquare001 = this.createEmptyMovieClip("mSquare001", this.getNextHighestDepth());
mSquare001.beginFill(0x0066FF, 100);
mSquare001.moveTo(50, 50);
mSquare001.curveTo(60, 50, 60, 40);
mSquare001.curveTo(60, 30, 50, 30);
mSquare001.curveTo(40, 30, 40, 40);
mSquare001.curveTo(40, 50, 50, 50);
mSquare001.endFill();
// SCRIPT TO CONTROL VISIBILITY OF THE SQAURE
function visibilityTrigger001() {
if (mSquare001._visible) {
mSquare001._visible = false;
} else {
mSquare001._visible = true;
}
}
nVisibilityInterval001 = setInterval(visibilityTrigger001, 3000);
//
nMotionInterval001 = setInterval(mover001, 1000/24);
}
// CONTINUED: SCRIPT FOR MOVING ALONG A CIRCLE TRAJECTORY
function mover001():Void {
mcSquare001._x = nCenterX001+nRadius001*Math.cos(nRadians001);
mcSquare001._y = nCenterY001+nRadius001*Math.sin(nRadians001);
nRadians001 += nSpeed001;
}
Second script:
Code:
drawCircle = function (x, y, r, alpha) {
if (arguments.length<4) {
alpha = 100;
}
this.lineStyle(0, 0, alpha);
var c1 = r*(Math.SQRT2-1);
var c2 = r*Math.SQRT2/2;
this.moveTo(x+r, y);
this.curveTo(x+r, y+c1, x+c2, y+c2);
this.curveTo(x+c1, y+r, x, y+r);
this.curveTo(x-c1, y+r, x-c2, y+c2);
this.curveTo(x-r, y+c1, x-r, y);
this.curveTo(x-r, y-c1, x-c2, y-c2);
this.curveTo(x-c1, y-r, x, y-r);
this.curveTo(x+c1, y-r, x+c2, y-c2);
this.curveTo(x+r, y-c1, x+r, y);
return this;
}
//Usage... functionName(_x,_y,radius,alpha)
myCircle = drawCircle(100, 100, 100, 100);
Last edited by 72monkeys; 05-06-2006 at 09:07 AM.
-
function mover001():Void {
myCircle._x = nCenterX001+nRadius001*Math.cos(nRadians001);
myCircle._y = nCenterY001+nRadius001*Math.sin(nRadians001);
nRadians001 += nSpeed001;
}
-
... i need the combined script look like the first one... just that it has to draw circles inside a movie clip...
-
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
|