[FMX2004] Problem with function variables

Hi everyone!
I’ve had a slight problem with this thing I’m trying to make, its basically a map, that loads a XML document, where it says the points of the streets and the name. Well… I have a function, that creates all the streets, wich works just fine. All the streets are located in different movieclips, that are like _root.streets.street0,street1,street2,etc. My problem is that I want to store a Variable in lets say: _root.streets.street1.streetName but, if I put the variable in the function, it erases it when it completes, how would I make it not dissapear? I don’t think making it global would solve my problem…

Hope you can understand my question, if you need anymore information, just explain what you don’t understand and I’ll try to explain better. Thank you all!

I don’t think making it global would solve my problem…

Just curious, why this wouldn’t work :puzzled:

well, I suppose that then there whould only be one streetName and not many different…

Well you could actually define an array in the _root timeline. And store all the values into one array :slight_smile:

yes, i thought ot that, but then how whould I know when, you rollOver a street, what street that actually is?

You can use associative arrays (I think that’s the name).

They act like the id for the value in the array. For example instead of …

arrayObj[0] = value1;
arrayObj[1] = value2;

you can write it as …

arrayObj[“street0”] = value1;
arrayObj[“street1”] = value2;

Do you see what I mean? :puzzled:

yeah, I get it, but how whould it get the name of the street? is there a value that gets the instance name of a movieclip? otherwise it wouldn’t be posible.

I found the _name property, I think I will solve it, otherwise I have another idea that might work, just put all the code in frame 2 and not make it a function… thanks alot man!!!

Yes your array thing works!!! thanks a lot :slight_smile:

You’re welcome :slight_smile: