When you calling a "drawing" method like drawCircle(), the Flash Player
doesn't actually draw at that point. Instead, it adds this drawing
command to its vector "display list" and later, when no ActionScript is
executing, it rasterizes this display list into pixels and puts them on
the screen. So you can't draw the whole path in a single method.
Instead, use the Timer class and periodically call a method to draw a
bit more of the path.

 

- Gordon

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of chrisvet2001
Sent: Friday, January 19, 2007 4:41 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] sequential addition of sprite objects

 

I'm trying to develop a system to show how to get from point A to
point B on a floorplan...

I'm having 2 problems -- 
1) the best way to display these points over a period of time (to
'animate' the points) 
2) when i do build in some delays, nothing gets displayed until all of
the points are already there...

my prototype code is below...

package {
import flash.display.Sprite;

public class Breadcrumbs extends Sprite {

private var _pathX:Array = ['10','30','30','75'];
private var _pathY:Array = ['10','10','50','50'];

public function Breadcrumbs() {
init()
}

public function init():void {
drawPath();
}

private function drawPath():void {
var lastX:int = _pathX[0];
var lastY:int = _pathY[0];
var currentTime:Date;
var previousTime:Date = new Date();
var i:int = 0; 

while (i < _pathX.length) {
currentTime = new Date();
if (currentTime.getTime() > previousTime.getTime() + 5000) {
var s:Sprite = new Sprite();
s.graphics.beginFill(0xFF0000, 1);
s.graphics.drawCircle(_pathX[i], _pathY[i], 2);
addChild(s);
i++;
}
}
}
}
}

Any Ideas as to how to improve the 'delay' code and/or how to get the
individual points to show up one at a time?

Thanks,
Chris

 

Reply via email to