Thanks Jason,

I think I still don't understand the big trick of value objects.  :-(
I will try to transform this in a working example so maybe then it will ring
the bell.


Thanks a lot,

Regards,
Cor van Dooren
The Netherlands


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Merrill,
Jason
Sent: dinsdag 7 september 2010 17:02
To: Flash Coders List
Subject: RE: [Flashcoders] parsing multi-dimensional array

>> Can you give an example, of such a multidimensional array, and how to
do this with value objects?

Hi Cor.  Sorry it took me so long to respond, due to Labor Day here in
the states.

Sure:

//Value Object examples:

package
{
        public class ExampleValueObject
        {
                public var myProperty:String;              //this
example has no default value
                public var myOtherProperty:Number = 0;     //this has a
default value.
                public var myOtherValueObjects:Array = []; //An array to
store other value objects
        }
}

package
{
        public class MyOtherExampleValueObject
        {
                public var someOtherExampleValue:String;        
        }
}

//Use value objects to store data, including value objects within value
objects:

var myExampleVOs:Array = [];

for each (var exampleValue:String in someData)
{
        var myExampleVO:ExampleObject = new ExampleValueObject();
        myExampleVO.myProperty = exampleValue;
        myExampleVO.myOtherProperty = someNumber;

        for each(var someOtherValue:String in someOtherData)
        {
                var myOtherValueObject:MyOtherExampleValueObject = new
MyOtherExampleValueObject();
                myOtherValueObject.someOtherExampleValue =
someOtherValue;

        
myExampleVO.myOtherValueObjects.push(myOtherValueObject);
        }

        myExampleVOs.push(myExampleVO);
}

Now you have an array of ExampleValueObjects, and each of those have
properties - and one of those properties is an array of
MyOtherExampleValueObjects.  And your code completion (at least in a
good AS code editor) will work on all this data, so no mistakes or
guesswork, and you've described related data in a logical, easy to
access, typecast and easy-to-transfer-around way.



Jason Merrill 

Instructional Technology Architect
Bank of America   Global Learning 

Join the Bank of America Flash Platform Community  and visit our
Instructional Technology Design Blog
(Note: these resources are only available for Bank of America
associates)



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Geen virus gevonden in het binnenkomende-bericht.
Gecontroleerd door AVG - www.avg.com 
Versie: 9.0.851 / Virusdatabase: 271.1.1/3118 - datum van uitgifte: 09/06/10
20:34:00

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to