Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-18-2012, 06:05 AM   PM User | #1
shaunthomson
New Coder

 
Join Date: May 2012
Posts: 89
Thanks: 51
Thanked 0 Times in 0 Posts
shaunthomson is an unknown quantity at this point
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!
shaunthomson is offline   Reply With Quote
Old 12-24-2012, 07:49 PM   PM User | #2
adaminaudio
New Coder

 
Join Date: Jan 2012
Location: Columbus, Ohio, U.S.A
Posts: 41
Thanks: 0
Thanked 8 Times in 8 Posts
adaminaudio is an unknown quantity at this point
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
adaminaudio is offline   Reply With Quote
Users who have thanked adaminaudio for this post:
shaunthomson (01-04-2013)
Old 01-04-2013, 01:51 PM   PM User | #3
shaunthomson
New Coder

 
Join Date: May 2012
Posts: 89
Thanks: 51
Thanked 0 Times in 0 Posts
shaunthomson is an unknown quantity at this point
THAT would be SOOOOOOO much easier. I'm going to try it. Thank you!
shaunthomson is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:56 AM.


Advertisement
Log in to turn off these ads.