[flexcoders] selectedIndices are Strings???

2006-06-08 Thread Jim Robson










I dont understand why DataGrid.selectedIndices
returns an array of Strings. I thought that indices were generally integers. (For
example, Array.indexOf returns an int.) 

Can anyone explain why the selected index of a DataGrid is a
String?

When dgTest is a DataGrid instance, the
following code generates a compiler error:





var arr:Array = dgTest.selectedIndices;

for(var i:int in arr){

// do something

}



The error that the compiler returns is as follows: 

Implicit coercion of a value of type String to an
unrelated type int. 




__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___





Re: [flexcoders] selectedIndices are Strings???

2006-06-08 Thread Tom Bray



Try either of these two options:   for( var i:int; i  arr.length; i++ )   {trace( arr[i] );   }   //or   for each( var i:int in arr )
   {trace( i );   }The for...in loop that you're using is for iterating over the properties of objects, which it expects to evaluate as strings. So, in your for...in loop, the var i refers to the indices of the array, not the values you're looking for which are the selectedIndices of your dg. The for...each loop above is new to AS3 and is the simplest way to do what you want.
HTH,TomOn 6/8/06, Jim Robson [EMAIL PROTECTED] wrote:









  











I don't understand why DataGrid.selectedIndices
returns an array of Strings. I thought that indices were generally integers. (For
example, Array.indexOf returns an int.) 

Can anyone explain why the selected index of a DataGrid is a
String?

When "dgTest" is a DataGrid instance, the
following code generates a compiler error:





var arr:Array = dgTest.selectedIndices;

for(var i:int in arr){

// do something

}



The error that the compiler returns is as follows: 

"Implicit coercion of a value of type String to an
unrelated type int. "







  















__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___



RE: [flexcoders] selectedIndices are Strings???

2006-06-08 Thread Jim Robson










Thanks Tom,



I believe array indices are ints, not
strings. However, I also believe that datagrid indices are strings, because
when I used the Array.sort() function on the DataGrid.selectedIndices array,
the order was all messed up. For example, 10 came before 2.
For that reason, I ended up writing a custom sort function to get around the
issue.



Thanks again!



Jim











From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tom Bray
Sent: Thursday, June 08, 2006 1:07
PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders]
selectedIndices are Strings???











Try either of these two options:

   for( var i:int; i 
arr.length; i++ )
   {
   
trace( arr[i] );
   }
   
//or

   for each( var i:int in
arr ) 
   {
   
trace( i );
   }

The for...in loop that you're using is for iterating over the properties of
objects, which it expects to evaluate as strings. So, in your for...in
loop, the var i refers to the indices of the array, not the values you're
looking for which are the selectedIndices of your dg. The for...each loop
above is new to AS3 and is the simplest way to do what you want. 

HTH,

Tom



On 6/8/06, Jim
Robson [EMAIL PROTECTED]
wrote:













I don't understand why DataGrid.selectedIndices
returns an array of Strings. I thought that indices were generally integers.
(For example, Array.indexOf returns an int.) 

Can anyone explain why the selected index of a
DataGrid is a String?

When dgTest is a DataGrid instance, the
following code generates a compiler error:





var arr:Array = dgTest.selectedIndices;

for(var i:int in arr){

// do something

}



The error that the compiler returns is as follows: 

Implicit coercion of a value of type String to an
unrelated type int. 
























__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___






Re: [flexcoders] selectedIndices are Strings???

2006-06-08 Thread Tom Bray



>From the docs on Array.sort():All elements, whatever the data type, are sorted as if they were strings, so 100 
precedes 99, because 1 is a lower string value than 9. But you can easily change the default sort behavior by doing this:arr.sort(Array.NUMERIC);-Tom
On 6/8/06, Jim Robson [EMAIL PROTECTED] wrote:









  











Thanks Tom,



I believe array indices are ints, not
strings. However, I also believe that datagrid indices are strings, because
when I used the Array.sort() function on the DataGrid.selectedIndices array,
the order was all messed up. For example, "10" came before "2".
For that reason, I ended up writing a custom sort function to get around the
issue.



Thanks again!



Jim











From:
flexcoders@yahoogroups.com [mailto:
flexcoders@yahoogroups.com] On Behalf Of Tom Bray
Sent: Thursday, June 08, 2006 1:07
PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders]
selectedIndices are Strings???











Try either of these two options:

   for( var i:int; i 
arr.length; i++ )
   {
   
trace( arr[i] );
   }
   
//or

   for each( var i:int in
arr ) 
   {
   
trace( i );
   }

The for...in loop that you're using is for iterating over the properties of
objects, which it expects to evaluate as strings. So, in your for...in
loop, the var i refers to the indices of the array, not the values you're
looking for which are the selectedIndices of your dg. The for...each loop
above is new to AS3 and is the simplest way to do what you want. 

HTH,

Tom



On 6/8/06, Jim
Robson [EMAIL PROTECTED]
wrote:














I don't understand why DataGrid.selectedIndices
returns an array of Strings. I thought that indices were generally integers.
(For example, Array.indexOf returns an int.) 


Can anyone explain why the selected index of a
DataGrid is a String?


When dgTest is a DataGrid instance, the
following code generates a compiler error:








var arr:Array = dgTest.selectedIndices;


for(var i:int in arr){


// do something


}





The error that the compiler returns is as follows: 


Implicit coercion of a value of type String to an
unrelated type int. 




























  















__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___



RE: [flexcoders] selectedIndices are Strings???

2006-06-08 Thread Francis Cheng










Dont forget that the Array.sort()
method sorts using string values by default, so even when sorting an array of
numbers or ints, they will be sorted as if they were strings. To get numeric
sorting, so that 10 comes after 2, use the
Array.NUMERIC sort option, e.g.:



myArray.sort(Array.NUMERIC);



Heres the relevant example from the
ActionScript documentation for Array.sort():



The following code creates the Array object numbers
with elements [3,5,100,34,10]. A call to sort()
without any parameters sorts alphabetically, producing the undesired result [10,100,3,34,5].
To properly sort numeric values, you must pass the constant NUMERIC
to the sort() method, which sorts numbers
as follows: [3,5,10,34,100]. 

Note:
The default behavior of the sort()
function is to handle each entity as a string. The Array.NUMERIC
argument does not actually convert other data types to the Number data type; it
simply allows the sort algorithm to recognize numbers.



var numbers:Array = new Array(3,5,100,34,10);



trace(numbers); // 3,5,100,34,10

numbers.sort();

trace(numbers); // 10,100,3,34,5

numbers.sort(Array.NUMERIC);

trace(numbers); // 3,5,10,34,100





Francis















From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Jim Robson
Sent: Thursday, June 08, 2006
10:11 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders]
selectedIndices are Strings???













Thanks Tom,



I believe array indices are ints, not strings. However, I also
believe that datagrid indices are strings, because when I used the Array.sort()
function on the DataGrid.selectedIndices array, the order was all messed up.
For example, 10 came before 2. For that reason, I
ended up writing a custom sort function to get around the issue.



Thanks again!



Jim











From: flexcoders@yahoogroups.com
[mailto:flexcoders@yahoogroups.com] On Behalf Of Tom Bray
Sent: Thursday, June 08, 2006 1:07
PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders]
selectedIndices are Strings???











Try
either of these two options:

   for( var i:int; i 
arr.length; i++ )
   {
   
trace( arr[i] );
   }
   
//or

   for each( var i:int in
arr ) 
   {
   
trace( i );
   }

The for...in loop that you're using is for iterating over the properties of
objects, which it expects to evaluate as strings. So, in your for...in
loop, the var i refers to the indices of the array, not the values you're
looking for which are the selectedIndices of your dg. The for...each loop
above is new to AS3 and is the simplest way to do what you want. 

HTH,

Tom



On 6/8/06, Jim Robson [EMAIL PROTECTED] wrote:













I don't understand why DataGrid.selectedIndices
returns an array of Strings. I thought that indices were generally integers.
(For example, Array.indexOf returns an int.) 

Can anyone explain why the selected index of a
DataGrid is a String?

When dgTest is a DataGrid instance, the
following code generates a compiler error:





var arr:Array = dgTest.selectedIndices;

for(var i:int in arr){

// do something

}



The error that the compiler returns is as follows: 

Implicit coercion of a value of type String to
an unrelated type int. 






























__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___






RE: [flexcoders] selectedIndices are Strings???

2006-06-08 Thread Jim Robson










You know, I looked at that page in the
docs this morning, but I guess my eyes just skipped right past that part. 



It seems decidedly counterintuitive, but I
should be used to that by now; Ive been developing Flash apps for 6
years! 



Thank you for the help. Now I can go back
and simplify my code!



Jim











From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tom Bray
Sent: Thursday, June 08, 2006 1:26
PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders]
selectedIndices are Strings???











From the docs on Array.sort():

All elements, whatever the data type, are sorted as if they were strings,
so 100 precedes 99, because 1 is a lower string value than
9. 

But you can easily change the default sort behavior by doing this:

arr.sort(Array.NUMERIC);

-Tom



On 6/8/06, Jim
Robson [EMAIL PROTECTED]
wrote:













Thanks Tom,



I believe array indices
are ints, not strings. However, I also believe that datagrid indices are
strings, because when I used the Array.sort() function on the
DataGrid.selectedIndices array, the order was all messed up. For example,
10 came before 2. For that reason, I ended up writing a
custom sort function to get around the issue.



Thanks again!



Jim











From: flexcoders@yahoogroups.com
[mailto:
flexcoders@yahoogroups.com] On Behalf Of Tom
Bray
Sent: Thursday, June 08, 2006 1:07
PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders]
selectedIndices are Strings???















Try either of these two options:

   for( var i:int; i 
arr.length; i++ )
   {
   
trace( arr[i] );
   }
   
//or

   for each( var i:int in
arr ) 
   {
   
trace( i );
   }

The for...in loop that you're using is for iterating over the properties of
objects, which it expects to evaluate as strings. So, in your for...in
loop, the var i refers to the indices of the array, not the values you're
looking for which are the selectedIndices of your dg. The for...each loop
above is new to AS3 and is the simplest way to do what you want. 

HTH,

Tom



On 6/8/06, Jim
Robson [EMAIL PROTECTED]
wrote:













I don't understand why DataGrid.selectedIndices
returns an array of Strings. I thought that indices were generally integers. (For
example, Array.indexOf returns an int.) 

Can anyone explain why the selected index of a
DataGrid is a String?

When dgTest is a DataGrid instance, the
following code generates a compiler error:





var arr:Array = dgTest.selectedIndices;

for(var i:int in arr){

// do something

}



The error that the compiler returns is as follows: 

Implicit coercion of a value of type String to
an unrelated type int. 














































__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___






RE: [flexcoders] selectedIndices are Strings???

2006-06-08 Thread Jim Robson










Thanks Francis,



Tom Bray also straightened me out on that.




I was wrong, and I feel properly
chastened.



Thank you for the help!











From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Francis Cheng
Sent: Thursday, June 08, 2006 1:26
PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders]
selectedIndices are Strings???













Dont forget that the Array.sort() method sorts using string
values by default, so even when sorting an array of numbers or ints, they will
be sorted as if they were strings. To get numeric sorting, so that
10 comes after 2, use the Array.NUMERIC sort
option, e.g.:



myArray.sort(Array.NUMERIC);



Heres the relevant example from the ActionScript
documentation for Array.sort():



The following code
creates the Array object numbers with
elements [3,5,100,34,10]. A call to sort()
without any parameters sorts alphabetically, producing the undesired result [10,100,3,34,5].
To properly sort numeric values, you must pass the constant NUMERIC
to the sort() method, which sorts numbers
as follows: [3,5,10,34,100]. 

Note:
The default behavior of the sort()
function is to handle each entity as a string. The Array.NUMERIC
argument does not actually convert other data types to the Number data type; it
simply allows the sort algorithm to recognize numbers.



var
numbers:Array = new Array(3,5,100,34,10);



trace(numbers);
// 3,5,100,34,10

numbers.sort();

trace(numbers);
// 10,100,3,34,5

numbers.sort(Array.NUMERIC);

trace(numbers);
// 3,5,10,34,100





Francis















From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com]
On Behalf Of Jim Robson
Sent: Thursday, June 08, 2006
10:11 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders]
selectedIndices are Strings???













Thanks Tom,



I believe array indices are ints, not strings. However, I also
believe that datagrid indices are strings, because when I used the Array.sort()
function on the DataGrid.selectedIndices array, the order was all messed up.
For example, 10 came before 2. For that reason, I
ended up writing a custom sort function to get around the issue.



Thanks again!



Jim











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com]
On Behalf Of Tom Bray
Sent: Thursday, June 08, 2006 1:07
PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders]
selectedIndices are Strings???











Try either
of these two options:

   for( var i:int; i 
arr.length; i++ )
   {
   
trace( arr[i] );
   }
   
//or

   for each( var i:int in
arr ) 
   {
   
trace( i );
   }

The for...in loop that you're using is for iterating over the properties of
objects, which it expects to evaluate as strings. So, in your for...in
loop, the var i refers to the indices of the array, not the values you're
looking for which are the selectedIndices of your dg. The for...each loop
above is new to AS3 and is the simplest way to do what you want. 

HTH,

Tom



On 6/8/06, Jim Robson [EMAIL PROTECTED] wrote:













I don't understand why DataGrid.selectedIndices
returns an array of Strings. I thought that indices were generally integers.
(For example, Array.indexOf returns an int.) 

Can anyone explain why the selected index of a
DataGrid is a String?

When dgTest is a DataGrid instance, the following
code generates a compiler error:





var arr:Array = dgTest.selectedIndices;

for(var i:int in arr){

// do something

}



The error that the compiler returns is as follows: 

Implicit coercion of a value of type String to
an unrelated type int. 








































__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___






[flexcoders] selectedIndices

2005-02-04 Thread Eric Guesdon
Hi to all,
Are there any possibilities to select programmaticaly more than one row 
in Datagrid or in List where multipleSelection propertie is true.

Best regards.
--
Eric Guesdon / Capgemini / France
http://www.capgemini.com

This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient, you are not authorized 
to read, print, retain, copy, disseminate, distribute, or use this message or 
any part thereof. If you receive this message in error, please notify the 
sender immediately and delete all copies of this message.



Re: [flexcoders] selectedIndices

2005-02-04 Thread JesterXL
The property name is in your email:

youList.selectedIndices = [0, 3, 4];

That'll select row 0, 3, and 4.

- Original Message - 
From: Eric Guesdon [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Friday, February 04, 2005 5:51 AM
Subject: [flexcoders] selectedIndices




Hi to all,

Are there any possibilities to select programmaticaly more than one row
in Datagrid or in List where multipleSelection propertie is true.

Best regards.

-- 
Eric Guesdon / Capgemini / France
http://www.capgemini.com



This message contains information that may be privileged or confidential and 
is the property of the Capgemini Group. It is intended only for the person 
to whom it is addressed. If you are not the intended recipient, you are not 
authorized to read, print, retain, copy, disseminate, distribute, or use 
this message or any part thereof. If you receive this message in error, 
please notify the sender immediately and delete all copies of this message.




Yahoo! Groups Links