15.3.15

Draw a Circle 2

Now here comes the tricky part. In order to fuze these two programs together, we are going to start by mashing them up in the same actions panel in five sections. The five sections are: Import, Varibales, Timer, Circle and Work. The sections from the Jump program are in red. The sections from the fake sine wave program are in green:

import flash.utils.Timer;
import flash.events.TimerEvent;
var timer:Timer;

var cirqy:Number = 220
var cirqx:Number = 250
const addam:Number = -1.2
var total:Number = .8


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;
}


function createCircle(event:TimerEvent):void {
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);
}

No comments:

Post a Comment