• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

drawing symbols on a map - how to delay each placement?

Community Beginner ,
Jul 22, 2018 Jul 22, 2018

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

--------------------------------------------------------

TOPICS
ActionScript

Views

258

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 22, 2018 Jul 22, 2018

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

...

Votes

Translate

Translate
Community Expert ,
Jul 22, 2018 Jul 22, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2018 Jul 23, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2018 Jul 23, 2018

Copy link to clipboard

Copied

LATEST

You're welcome!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines