PDA

View Full Version : Creating VBox in ActionScript or Code


john100
02-09-2006, 12:43 AM
I have this simple xmxl code. I would like to create exactly the same things in Action Script

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" layout="absolute">
<mx:Canvas x="82" y="66" width="1000" height="1000">
<mx:VBox x="163" y="114" width="100" height="100" cornerRadius="5" borderThickness="5" borderStyle="solid" backgroundColor="#8facff">
<mx:Image click="getURL('http://www.cnn.com')" source="0004734.jpg" width="29" height="24" verticalAlign="bottom" />
<mx:Image click="getURL('http://www.cnn.com')" source="0004734.jpg" width="29" height="24" verticalAlign="bottom" />
</mx:VBox>
<mx:VBox x="19" y="13" width="100" height="100" cornerRadius="5" borderThickness="5" borderStyle="solid" backgroundColor="#8facff"/>
</mx:Canvas>
</mx:Application>


thank you in advance

hangalot
02-09-2006, 05:18 PM
in as3 you would


import mx.controls.Button;
import mx.containers.VBox;
private function someFunction():void
{
var n:VBox = new VBox();
var p:Button = new Button();
var z:Button = new Button();
n.addChild(p);
n.addChild(z);
p.label = "hallo";
z.label = "hallo 2";
this.addChild(n);

}



in flex 1.5 as2 you need to use createChildren, thats pretty simmiliar to this approach

john100
02-11-2006, 04:57 AM
Thanks it works

Incrue
02-12-2006, 11:07 AM
Wait...xmxl? This thing wasnt called xml?Or it is another thing?
And this addChild...this seems to put an object inside another, isnt it?OR it is to put a xml child inside another?
This is so confusing...

hangalot
02-12-2006, 03:40 PM
it is called mxml. yes addChild adds a child to the displayList. this has nothing todo with xml