I wanted to animate drawing a circle in Flash using small circles, or points. I got the idea from looking at two other programs that I had created. The first program, called Equation, looks like this:
var cirqy:Number = 220
var cirqx:Number = 250
const addam:Number = -1.2
var total:Number = .8
for (var i:int = 100; i < 107; i++) {
var circle:Sprite = new Sprite();
circle.graphics.lineStyle(.5, 1);
circle.graphics.beginFill(0xBC51F8);
circle.graphics.drawCircle(cirqx, cirqy, 5);
graphics.endFill();
addChild(circle);
cirqx = cirqx + addam + 16 ;
total = total + addam;
cirqy = cirqy - (Math.pow(total, 2)+16);
}
This program was a convoluted way of simulating a sine wave. I probably tried to use the sine function but I didn't know how, which is why I resorted to using adding and exponents. It's passable if you get the numbers right, but it's not a true sine wave.
Here is the second program, which is a re-do of my old Jump program, which was lost forever when my old PC crashed a few years back:
import flash.utils.Timer;
import flash.events.TimerEvent;
var timer:Timer;
Red.addEventListener(MouseEvent.CLICK, RedJump);
function RedJump(event:MouseEvent):void
{
timer= new Timer(.01*1000, 30);
timer.addEventListener(TimerEvent.TIMER, redTimerStep);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, redTimerDone);
timer.start()
}
function redTimerStep(event:TimerEvent):void {
Green.x -= 8;
}
function redTimerDone(event:TimerEvent):void {
Green.x += 240;
}
Blue.addEventListener(MouseEvent.CLICK, BlueJump);
function BlueJump(event:MouseEvent):void
{
timer= new Timer(.01*1000, 30);
timer.addEventListener(TimerEvent.TIMER, blueTimerStep);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, blueTimerDone);
timer.start()
}
function blueTimerStep(event:TimerEvent):void {
Green.x += 8;
}
function blueTimerDone(event:TimerEvent):void {
Green.x -= 240;
}
Yellow.addEventListener(MouseEvent.CLICK, YellowJump);
function YellowJump(event:MouseEvent):void
{
timer= new Timer(.01*1000, 30);
timer.addEventListener(TimerEvent.TIMER, yellowTimerStep);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, yellowTimerDone);
timer.start()
}
function yellowTimerStep(event:TimerEvent):void {
Green.y += 4;
}
function yellowTimerDone(event:TimerEvent):void {
Green.y -= 120;
}
Orange.addEventListener(MouseEvent.CLICK, OrangeJump);
function OrangeJump(event:MouseEvent):void
{
timer= new Timer(.01*1000, 30);
timer.addEventListener(TimerEvent.TIMER, orangeTimerStep);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, orangeTimerDone);
timer.start()
}
function orangeTimerStep(event:TimerEvent):void {
Green.y -= 4;
}
function orangeTimerDone(event:TimerEvent):void {
Green.y += 120;
}
This program will be made through the Actions window, as I am not proficient with classes yet.
No comments:
Post a Comment