Copy link to clipboard
Copied
Hi,
yesterday I gave Flash (AS3) a chance to draw me symbols on a map. The coordinates of which derive from a simple external file.
Since it is my first trial with Flash I am already quite happy with the current outcome. What puzzles me however, how I could delay the placement of the symbols so that they will be displayed on stage one after the other rather then altogether. I tried timers such as "setTimeout" or "tweener" (at a position see below) with no success. There is a delay but only before all symbols are displayed still at once. Most probably a very silly thing...
Structurally this happens:
--------------------------------------------------------
load coordinates from file into an array line by line (x/y coordinates)
start loop through array
retrieve X- and Y coordinates
instantiate shape
define shape-size, -color, -position
<-- TIMER!?
addchild (shape)
end loop
--------------------------------------------------------
Hi.
Let's supose you have a vector (can be a regular array) representing the coordinates you got from the external source and a libray symbol with a linkage name "Pin".
You set a interval and at each interval you pick a coord from the vector or array by incrementing a numeric variable by one.
Try this:
...import flash.geom.Point;
import flash.utils.setInterval;
import flash.utils.clearInterval;
var coords:Vector.<Point> = new <Point>[new Point(10, 50), new Point(75, 20), new Point(240, 360)];
var delay:Num
Copy link to clipboard
Copied
Hi.
Let's supose you have a vector (can be a regular array) representing the coordinates you got from the external source and a libray symbol with a linkage name "Pin".
You set a interval and at each interval you pick a coord from the vector or array by incrementing a numeric variable by one.
Try this:
import flash.geom.Point;
import flash.utils.setInterval;
import flash.utils.clearInterval;
var coords:Vector.<Point> = new <Point>[new Point(10, 50), new Point(75, 20), new Point(240, 360)];
var delay:Number = 1;
var count:uint = 0;
var interval:uint = setInterval(function()
{
if (count == coords.length - 1)
clearInterval(interval);
var pin:Pin = new Pin();
pin.x = coords[count].x;
pin.y = coords[count].y;
addChild(pin);
count++;
}, delay * 1000);
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Hi João,
it helped!! Although quite a tricky approach with respect to other programs.
Thanks a lot and have a nice day
Regards
Thomas
Copy link to clipboard
Copied
You're welcome!