>> I understand the advantages, but I can't seem to understand HOW to
use it in even a simple example.

Well, this is the jumping off point where you would want to look at what
you want to build, and see what things are relatable objects described
with data.  For example, if you wanted to build your own video player,
you might create a VideoPlayerVO with the following properties, like so:

var videoPlayerVO:VideoPlayerVO = new VideoPlayerVO();

videoPlayerVO.url = "myVideoes/myFLV.flv";
videoPlayerVO.description = "This is a video of stuff that is cool.";
videoPlayerVO.replayable = true;
videoPlayerVO.seenByUser = false;
videoPlayerVO.showCuePoints = true;

Then you have a video player you create, you give it the values
contained in the VO in order for it to play.  The answer to your
question is really about how you use data within your application.  By
using VOs, you keep your related data together.


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)






-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Cor
Sent: Tuesday, September 07, 2010 4:54 PM
To: 'Flash Coders List'
Subject: RE: [Flashcoders] parsing multi-dimensional array

I understand the advantages, but I can't seem to understand HOW to use
it in even a simple example.
I see what you are trying to tell, but then I want to try something in a
working example, and then my brain comes to a halt.

What I normally do is creating an object:

var o:Object = new Object();
o. shirtVO = someValue;
o.sleeveVO = someValue;
o.color = 0x990000;

people.push(o);

I received a beautiful example from Muzak, but I am not able to build it
my own.
I guess I am not smart enough... :-(



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

>> I think I still don't understand the big trick of value objects.   

Can you explain what you mean by that?  Do you mean the advantage of
value objects?  Value Objects (an OOP design pattern) help you tie
related bits of data together, and help you describe what the data is,
help you keep values typecast when placed in an array, help you nest
objects logically - so when you code, nested data is easier and more
intuitive to access than multidimensional arrays.    For example,
instead of:

var personID:Number = 3;

//multidimensional array:
var personsShirtSleeveColor:uint = people[personID] [2][4][3]

and hope you're at the right level (2) and right sub level (4) and what
you grab is a color and that it's cast as a number/uint..., to me, this
makes more sense:

//value objects:
var personsShirtSleeveColor:uint =
people[personID].shirtVO.sleeveVO.color;

Where people is an array of PeopleVOs.

...and my code editor has code hinting along the way, and the compiler
enforces typecasting.  With multidimensional arrays, none of your data
is described, it's like trying to find something hidden in a room with
all the lights turned off.

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)






-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Cor
Sent: Tuesday, September 07, 2010 2:20 PM
To: 'Flash Coders List'
Subject: RE: [Flashcoders] parsing multi-dimensional array

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
_______________________________________________
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
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to