Jump to content

creating an associative array dynamically


music_lp90

Recommended Posts

First, I think I've mentioned this before but with Flash you don't need to start variables with a $ symbol. I think you're going to end up confusing yourself when you have two different variables like $instanceName and instanceName. Variable names are supposed to be descriptive and the $ doesn't add a lot to distinguish one variable from the other.You have a problem here:$position[a] = saveData;In that context the variable a is the object that you just dragged, it's a movie clip object. You can't use a movie clip object as an index to an array. Array indices need to be either numbers or strings. It would probably be best when you create the movie clip to also store the instance name as a property of it.instanceName.myName = $instanceName; (see how it's confusing to have 2 variables with the same name?)Later on when you're saving the position of the moved object you can use that property to get the index that you should use for the arrays.

Link to comment
Share on other sites

Thanks justsomeguy. Yes, I see what you mean about the variables being confusing, so I'll work on getting those changed. I like to use the $ sign just so at a glance I can know I'm dealing with a variable, but I have not been consistent with that. So, I will work on that and try to get the movieclip name instead of using the actual object as the key. For some reason I thought using "a" would use it's name.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...