Vector is Flash 10 only. So I don't think it works in CS3.
You can substitute Array if you're targeting Flash Player 9. On 3/22/2010 12:39 PM, Lehr, Theodore wrote:
nice... is vector do-able in cs3 - because I am egtting an error on that... ________________________________________ From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Steven Sacks [flash...@stevensacks.net] Sent: Monday, March 22, 2010 3:19 PM To: Flash Coders List Subject: Re: [Flashcoders] xml: counting parents I disagree with using explicit node names. He's building an org chart of people, so the nodes should be person and the title should be an attribute. <people> <person title="CEO" name="Bill Gates"> <person title="President" name="Steve Ballmer"/> <person title="Manager - North America" name="Joe Schmoe"> <person title="Manager - Pacific Northwest" name="Bob Jones"/> </person> </person> </people> You create a Person VO that you pass the node for deserialization: public class Person { public var title:String; public var name:String; public var subordinates:Vector.<Person>; public function Person(value:XML) { deserialize(value); } private function deserialize(value:XML):void { title = val...@title; name = val...@name; subordinates = parseSubordinates(value.person); } private function parseSubordinates(value:XMLList):Vector.<Person> { var vector:Vector.<Person> = new Vector.<Person>(); var len:int = value.length(); for (var i:int = 0; i< len; ++i) { vector.push(new Person(value[i])); } return vector; } } And you feed that to your view which traverses the stack: public class PersonView extends Sprite { protected var _data:Person; public function PersonView() { super(); } public function set data(value:Person):void { _data = value; draw(); } public function get data():Person { return _data; } protected function draw():void { // draw based on the data } } Pseudo-code but you get the idea. The PersonView would create other PersonViews inside of itself to draw the subordinates, and each view would be responsible for doing its own layout in the draw function, taking into account the width/height of its children, etc. Pretty clean overall. The reason draw() is protected is because you might want to create concrete implementations of PersonView. Perhaps some titles use a specific view and you don't want to clutter PersonView with too many if then else statements, so you just instantiate a specific ConcretePersonView based on the _data.title and the concrete views take care of drawing themselves. That's how I would build it, at least. _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders