actionscript 3 - How to Save a Shape (or Sprite) to a Folder After Creation? -


i trying create county map of illinois using x,y coordinates shp file. have x,y coordinates , county names saved in csv file have no problem reading in via actionscript 3 (and map looks great), in order save time in future application save each county shape permanent shape in application , give them labels, i.e. sprite1 (label='champaign'). possible? if so, appreciated.

in case not possible trying alternate solution: create new sprite (var spr:sprite = new sprite();) each county, draw using spr.graphics.drawpath, , give name (spr.name='champaign') , 'push' vector of sprites (var xy_sprites:vector. = new vector.();). great, doesn't work when try loop through each sprite in vector , add eventlistener sprite pop name when mouseover of counties. sprite data type not correct way go or missing sprites?

some of code draw shapes , save in vector:

function drawxymap(str:string):vector.<sprite> { var arr:array = str.split("\n"); var xy_sprites:vector.<sprite> = new vector.<sprite>(); (var i:int=0; i<arr.length-1; ++i) {     var spr:sprite = new sprite();     spr.graphics.linestyle(1.0, 0x000000);     spr.graphics.beginfill(0x666699);     arr[i] = arr[i].split(',');     var xy_commands:vector.<int> = new vector.<int>();     var xy_coord:vector.<number> = new vector.<number>();     (var j:int=1; j<arr[i].length; ++j) {         xy_coord.push(arr[i][j]*6);         if (j==1) {             xy_commands.push(1); // 1 move-to command             var cntry:string = arr[i][j-1] string; //country name         }         else if (j % 2 == 1) {             xy_commands.push(2); // 2 line-to command         }     }     spr.graphics.drawpath(xy_commands, xy_coord);     spr.name = cntry;     xy_sprites.push(spr);     addchild(spr); } return xy_sprites; 

}

but can't seem add event listener each sprite in vector of sprites created:

var str:string = csvloader.data string; var xy_spr:vector.<sprite> = drawxymap(str); each (var spr:sprite in xy_spr) { spr.addeventlistener(mouseevent.mouse_over,onover); } function onover(e:mouseevent):void { spr.alpha = .25; } 

any great. thanks!

you put of x, y co-ords vector data structure, , use graphics.drawpath() method, iterate on co-ords time instantiate county.

if created class extended shape, add vector references csv file, , every time create shape, automatically draws path.

check out useful document adobe:

http://help.adobe.com/en_us/actionscript/3.0_programmingas3/wsa8bd9022-bab1-46d3-9b26-0d9649743c8e.html

ps don't forget use proper drawing commands drawpath(). should able interact normal if do.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -