Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-21-2012, 02:02 AM   #1
ronaldhutasuhut
Registered User
 
Join Date: May 2012
Posts: 5
Default Get specified array items

Hello all,

I need a favor,

Q:How to get a group of an Array specified item, and then show it in a cell of DataGrid?

The problem looks like this:

I have an array:
ActionScript Code:
var arr:Array=new Array('1','2','3','4','5');

and a DataGrid:
ActionScript Code:
var dg:DataGrid=new DataGrid(); dg.columns=["Col1","Col2"];

I want to add a group of specified arr Array to Col1 and Col2:

Col1 data will be = 1,4,5
Col2 data will be = 1,2,4

It's not like 'push', 'splice', 'slice','shift', etc. I just want to simply gathered a single array item with another to be a group in DataGrid as an Item. It should be like this:

dg.addItem({Col1:arr[0] and arr[3] and arr[4], Col2:arr[0] and arr[1] and arr[3]});

Can we do that? If we can, how to write the code correctly?

Thanks for your help!
ronaldhutasuhut is offline   Reply With Quote
Old 05-21-2012, 11:43 AM   #2
Scearezt
Satisfied User
 
Scearezt's Avatar
 
Join Date: Jun 2010
Location: C:\\System32\Hungary
Posts: 426
Lightbulb

Read about Dictionaries.
Scearezt is offline   Reply With Quote
Old 05-21-2012, 05:38 PM   #3
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,796
Send a message via AIM to abeall
Default

Is this a Flex DataGrid or Flash DataGrid? Either one, I don't think DataGrid is going to let you do that.
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 05-21-2012, 06:06 PM   #4
ronaldhutasuhut
Registered User
 
Join Date: May 2012
Posts: 5
Default

It's a flash one. You right @abeall, I thought I could save some times, if I can add item on the DataGrid this way:

dg.addItem({Col1:arr[0] and arr[3] and arr[4], Col2:arr[0] and arr[1] and arr[3]});

all I have to do is just type:

dg.addItem({Col1:arr[0+i] and arr[3+i] and arr[4+i], Col2:arr[0+i] and arr[1+i] and arr[3+i]});
dg.addItem({Col1:arr[1+i] and arr4+i] and arr[5+i], Col2:arr[1+i] and arr[2+i] and arr[4+i]});

// or something like that

for the next items.

I guess this will be my busy week, because I have to add the DataGrid items 'manually'.

Thanks for the information @Scearezt, I'm not sure the Dictionary class is what I need.
ronaldhutasuhut is offline   Reply With Quote
Reply


Thread Tools
Display Modes 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. The time now is 03:29 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.