从内至外效果:
效果代码如下:
var speed:Number = 0.3;
var radius:Number = 0;
var angle:Number = 0;
var xpos:Number;
var ypos:Number;
var centerX:Number = stage.stageWidth / 2;
var centerY:Number = stage.stageHeight / 2;
//生成容器
var container:Sprite = new Sprite();
//把容器加入舞台的中心
container.x = centerX;
container.y = centerY;
addChild (container);
//设定线条样式 4个像素、白色
container.graphics.lineStyle (4, 0xffffff);
//起始点在舞台的中心
container.graphics.moveTo (0, 0);
//注册进入帧事件侦听器
addEventListener (Event.ENTER_FRAME, onEnterFrame);
//事件响应函数
function onEnterFrame (event:Event):void {
/* We’ll stop the drawing after the radius is over 100
pixels.
We still continue to rotate the container.
*/
if (radius > 100) {
speed = 0;
container.rotation += 10;
}
else {
//Increase the radius in each frame
radius += 0.5;
//New x and y coordinates
xpos = Math.cos(angle) * radius;
ypos = Math.sin(angle) * radius;
//Draw to the new coorninates
container.graphics.lineTo (xpos,ypos);
//Rotate the container
container.rotation += 10;
//The greater the speed, the faster we
draw circles
angle += speed;
}
}
var radius:Number = 0;
var angle:Number = 0;
var xpos:Number;
var ypos:Number;
var centerX:Number = stage.stageWidth / 2;
var centerY:Number = stage.stageHeight / 2;
//生成容器
var container:Sprite = new Sprite();
//把容器加入舞台的中心
container.x = centerX;
container.y = centerY;
addChild (container);
//设定线条样式 4个像素、白色
container.graphics.lineStyle (4, 0xffffff);
//起始点在舞台的中心
container.graphics.moveTo (0, 0);
//注册进入帧事件侦听器
addEventListener (Event.ENTER_FRAME, onEnterFrame);
//事件响应函数
function onEnterFrame (event:Event):void {
/* We’ll stop the drawing after the radius is over 100
pixels.
We still continue to rotate the container.
*/
if (radius > 100) {
speed = 0;
container.rotation += 10;
}
else {
//Increase the radius in each frame
radius += 0.5;
//New x and y coordinates
xpos = Math.cos(angle) * radius;
ypos = Math.sin(angle) * radius;
//Draw to the new coorninates
container.graphics.lineTo (xpos,ypos);
//Rotate the container
container.rotation += 10;
//The greater the speed, the faster we
draw circles
angle += speed;
}
}
从外至内效果:
效果代码如下:
var speed:Number = 0.3;
var radius:Number = 100;
var angle:Number = 0;
var xpos:Number;
var ypos:Number;
var centerX:Number = stage.stageWidth / 2;
var centerY:Number = stage.stageHeight / 2;
//We are going to add all our graphics onto a container
var container:Sprite = new Sprite();
//Add the container to the center of the stage
container.x = centerX;
container.y = centerY;
addChild (container);
//Set the container’s graphics line style to be 4 pixels and
white
container.graphics.lineStyle (4, 0xffffff);
//Starting point
container.graphics.moveTo (100, 0);
addEventListener (Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame (event:Event):void {
/* We’ll stop the drawing after the radius is under 0
We still continue to rotate the container.
*/
if (radius < 0) {
speed = 0;
container.rotation += 10;
}
else {
//Decrease the radius in each frame
radius -= 0.5;
//New x and y coordinates
xpos = Math.cos(angle) * radius;
ypos = Math.sin(angle) * radius;
//Draw to the new coorninates
container.graphics.lineTo (xpos,ypos);
//Rotate the container
container.rotation += 10;
//The greater the speed, the faster we
draw circles
angle += speed;
}
}
var radius:Number = 100;
var angle:Number = 0;
var xpos:Number;
var ypos:Number;
var centerX:Number = stage.stageWidth / 2;
var centerY:Number = stage.stageHeight / 2;
//We are going to add all our graphics onto a container
var container:Sprite = new Sprite();
//Add the container to the center of the stage
container.x = centerX;
container.y = centerY;
addChild (container);
//Set the container’s graphics line style to be 4 pixels and
white
container.graphics.lineStyle (4, 0xffffff);
//Starting point
container.graphics.moveTo (100, 0);
addEventListener (Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame (event:Event):void {
/* We’ll stop the drawing after the radius is under 0
We still continue to rotate the container.
*/
if (radius < 0) {
speed = 0;
container.rotation += 10;
}
else {
//Decrease the radius in each frame
radius -= 0.5;
//New x and y coordinates
xpos = Math.cos(angle) * radius;
ypos = Math.sin(angle) * radius;
//Draw to the new coorninates
container.graphics.lineTo (xpos,ypos);
//Rotate the container
container.rotation += 10;
//The greater the speed, the faster we
draw circles
angle += speed;
}
}