CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Flash & ActionScript (http://www.codingforums.com/forumdisplay.php?f=52)
-   -   Objects question (http://www.codingforums.com/showthread.php?t=284322)

shaunthomson 12-18-2012 06:05 AM

Objects question
 
Hi

Dumb question, but I can't figure this simple thing out...

I have an array of objects:
Code:

var monthlyDP:Array = new Array({label:"1st", X:"first"},{label:"2nd", X:"second"},{label:"3rd", X:"third"},{label:"4th", X:"fourth"},{label:"last", X:"last"});
I know "1st", and want to retrieve the value associated with it (so "first").

Is it a case of having to also know the index of that object, or is there a way to seach and array like this when you know the label of the object, and just want the value?

Thanks!

adaminaudio 12-24-2012 07:49 PM

Hi there,

I'm hoping I understand your question right but I'll try:

would it be possible for you to use a dictionary for this? (associative array, same thing)

and say something like:
PHP Code:

var monthlyDP:Dictionary = new Dictionary();
monthlyDP["1st"] = "first";
monthlyDP["2nd"] = "second";
monthlyDP["3rd"] = "third"

...and so on.

that way you get direct access. Of course there are multiple ways of doing this.

Hope that starts you in the right direction.

-Adam

shaunthomson 01-04-2013 01:51 PM

THAT would be SOOOOOOO much easier. I'm going to try it. Thank you!


All times are GMT +1. The time now is 01:06 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.