Jump to content
Search Community

How to add a parameter to control the speed of drawing?

learner_7n test
Moderator Tag

Recommended Posts

Hi,

 

Now it draws a square with normal speed but I would like to customize the speed. How to add a parameter to control the speed of drawing?

 

import com.greensock.*;
import flash.events.MouseEvent;

//create line
var line:Shape = new Shape();
addChild(line);

//position mc1 at first point
mc1.x = p1.x;
mc1.y = p1.y;

var tl:TimelineMax = new TimelineMax({paused:true,onUpdate:drawLine});

tl.appendMultiple([
TweenLite.to(mc1, 1, {x:p2.x, y:p2.y}),
TweenLite.to(mc1, 1, {x:p3.x, y:p3.y}),
TweenLite.to(mc1, 1, {x:p4.x, y:p4.y}),
TweenLite.to(mc1, 1, {x:p1.x, y:p1.y})
], 0, TweenAlign.SEQUENCE);


function drawLine():void
{
   line.graphics.lineTo(mc1.x, mc1.y);
}

playTl(null);
function playTl(e:MouseEvent):void

/*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(5, 0x660000, 1);
   line.graphics.moveTo(p1.x, p1.y);

   tl.restart();
}

Thanks in advance for any help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...