Hi,
The following code draws a square on using Play Button. But I want it to be started drawing automatically without using the Play Button. I got the example code from searching the google.
import com.greensock.*;
import flash.events.MouseEvent;
//create line
var line:Shape = new Shape();
addChild(line);
//position mc at first point
mc.x = p1.x;
mc.y = p1.y;
var tl:TimelineMax = new TimelineMax({paused:true,onUpdate:drawLine});
tl.appendMultiple([
TweenLite.to(mc, 1, {x:p2.x, y:p2.y}),
TweenLite.to(mc, 1, {x:p3.x, y:p3.y}),
TweenLite.to(mc, 1, {x:p4.x, y:p4.y}),
TweenLite.to(mc, 1, {x:p1.x, y:p1.y})
], 0, TweenAlign.SEQUENCE);
function drawLine():void
{
line.graphics.lineTo(mc.x, mc.y);
}
play_btn.addEventListener(MouseEvent.CLICK, playTl);
function playTl(e:MouseEvent):void
{
//kill existing line
line.graphics.clear();
//start new line at first point
line.graphics.lineStyle(2, 0xFFFF00, .5);
line.graphics.moveTo(p1.x, p1.y);
tl.restart();
}
Please do help.