PDA

View Full Version : Changing Object Colours by text import


Phill
07-08-2004, 08:56 AM
Hi all, I am very new to Flash and apologise if anyone has asked this before.

I have an app I am trying to make which is as follows;

It has two layers. On layer 1 is an imported world map as a jpg. On layer two I have traced out regions of it as vector shapes with the pen tool and converted them to symbols (buttons). This is so I can alter the colour of different regions, so for example africa might have a semi-transparent overlay of yellow to show whose control it is under at this point in time i.e. the yellow player. It is like a board game, think Risk or Diplomacy, the map is just a visual representation of who has what at the end of each turn. All I want it to do is create the semi transparent coloured overlays on top of the underlying world map to show which players own which territories.

At present I am defining new color objects and attaching them to each region with the setTransform command. This seems to all be pretty straightforward and works just fine. What I would really like to do though is have those values fed into each region by a text file, so I could just change the text file and let the app update itself, and this is where I am stuck. Any help would be appreciated.

fgf
07-14-2004, 09:32 PM
read the manual entry for loadVars

The text file you will load should look something like this

&player1color=#ff0000&player2color=#00ff00

when you load it in to a loadVars object these values become properties of that object so you can access them like so

colorsLoader= new LoadVars();
colorsLoader.load("colors.txt");
// goto remember to wait for it to load see onload event. if this line followed imediately aftert the last one it would work as the text file wouldn't have loaded
currentcolor=colorsLoader.player1color

fgf

PS. i'm ok with people asking dumb or repetative questions AS LONG AS they do it in the newbie forum. Thats whats its for.

Phill
07-15-2004, 01:36 AM
Thank you very much. I figured it should be possible to substitute the numbers in the SetTransform command with variables but had no idea how. Thanks for the text file format help too.