Hi again,
I think Francis Cheng example would off course never work.
/*
var arr:Array = new Array();
arr.foo = "foo";
arr.bar = "bar";
arr.push("foobar");
trace(arr.length); // output: 1
*/
I think that the Array method for accessing information, [], wille
developing is not to clear or you can say not so user friendly.
1.
id:Array = new Array (1, 2, 3);
name:Array = new Array ("John", "Michael", "Ana");
myArray:Array = new Array ( [ id[0], name[0] ], [ id[1], name[1] ],
[ id[2], name[2] ] );
trace( nameArray[0][0]);
trace( nameArray[0][1]);
Instead of:
2.
myArray:Array = new Array ();
myArray.push ({id:1, name:"John"});
myArray.push ({id:2, name:"Michael"});
myArray.push ({id:3, name:"Ana"});
trace (myArray[0].id)
trace (myArray[0].name)
As you see in example 2 I have the control of the list as an array but I
easily access information in a simpler and more understandable way.
This example works when you need to index a bunch of elements with
properties.
But I would use the 1 example to work the movements of a "tower" in a chess
game with key arrows. In this case information would be provided as rows and
columns:
[1] [2] [3] [4] [5] [6]
[7] [8] [9] [10] [11] [12]
[13] [14] [15] [16] [17] [18]
Regarding my xml problem: I did an example with a simple:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>
<jobQueueList>
<item min="45" hour="10" day="22" month="6"
year="2006">Content</item>
<item min="10" hour="18" day="23" month="6"
year="2006">Content</item>
<item min="0" hour="11" day="22" month="6"
year="2006">Content</item>
<item min="23" hour="17" day="23" month="6"
year="2006">Content</item>
<item min="20" hour="18" day="23" month="6"
year="2006">Content</item>
</jobQueueList>';
?>
....and flash received the code and recognize it as an object with xml
encoding.
Thanks anyway : (
[quoted text, click to view] "ImagicDigital" <> wrote in message
news:e5qcj9$j1$1@forums.macromedia.com...
> So are you returning more than one set of data at once? If not, you can
> push the values returned to your LoadVars object into an associative array
> just like you would XML values.
>
> var myList:Array = new Array ();
>
> loadFromServer.onLoad = function(success) {
> if (success) {
> myList.push ( {id: loadFromServer.userID, fname:
> loadFromServer.firstName, pass: loadFromServer.pass})
> } else {
> trace("error");
> }
> };
>
> Also, an associative array (what you have) is really just an object. As
> far as I understand (recent discussion here:
>
>
http://groups.google.com/group/macromedia.flash.actionscript/browse_frm/thread/3fb84bf9d6220ee6/18b9a9ef5ff15c96
> )
>
> it doesn't have access to all of the Array class methods anyway. Or how
> are you manipulating it?
>
> SteveStall wrote:
>
>>
>> Normally I use xml in order to have control of length of information,
>> example populating a list.
>>
>> I can dynamically read the length/number of items in the returned object.
>>
>> What I do is load an xml and then in flash I organise the information
>> into a multidimensional array based on objects.
>>
>>
>>
>> var myList:Array = new Array ();
>>
>> myList.push ({ id:<id>, name:<name>, pass:<pass> ... });
>>
>> // <id>, <name>, <pass> are provided with the xml
>>
>>
>>
>> This gives me the power to manipulate information with all the utilities
>> that Array Class provides. Sorting, shift, shuffle...
>
>>