2008 Jan 18 7:13 AM
Hi Experts,
Please suggest me where am i going wrong in action script code snippet pasted in this thread. I am not able to view child component.
* var childStateVBox:VBox = new VBox();*
* with (childStateVBox){*
* backgroundColor = "#CC3300"; *
* x = 10;*
* y = 20;*
* width = 320;*
* height = 130;*
* text = "Hello";*
* }*
* *
* vb1.addChild(childStateVBox);*
* childStateVBox.setVisible(true);*
vb1 is again a VBox which is declared in mxml tags. vb1 is displayed in flex app but childStateVBox is not visible. Here is how vb1 is declared in mxml
<mx:VBox id="vb1" autoLayout="false"
* backgroundColor="#CCCC00"*
cornerRadius="14"
paddingLeft="20"
paddingTop="20"
paddingRight="20"
paddingBottom="20"
x="49" y="185" width="494" height="267">
</mx:VBox>
Hi Experts,
Please suggest me where am i going wrong in action script code snippet pasted in this thread. I am not able to view child component.
* var childStateVBox:VBox = new VBox();*
* with (childStateVBox){*
* backgroundColor = "#CC3300"; *
* x = 10;*
* y = 20;*
* width = 320;*
* height = 130;*
* text = "Hello";*
* }*
* *
* vb1.addChild(childStateVBox);*
* childStateVBox.setVisible(true);*
vb1 is again a VBox which is declared in mxml tags. vb1 is displayed in flex app but childStateVBox is not visible. Here is how vb1 is declared in mxml
<mx:VBox id="vb1" autoLayout="false"
* backgroundColor="#CCCC00"*
cornerRadius="14"
paddingLeft="20"
paddingTop="20"
paddingRight="20"
paddingBottom="20"
x="49" y="185" width="494" height="267">
</mx:VBox>
2008 Jan 18 7:55 AM
remove the line
backgrondcolor = "#CC3300"
from your code and add
childStateVBox.setStyle("backgroundColor","#CC3300");
just before
vb1.addChild(childStateVBox);
the code would look like below
private function addVbox():void{
var childStateVBox:VBox = new VBox();
with (childStateVBox){
x = 59;
y = 53;
width = 234;
height = 329;
label = "Hello";
}
childStateVBox.setStyle("backgroundColor","#CC3300");
this.vb1.addChild(childStateVBox);
}
Regards
Raja
2008 Jan 18 8:09 AM
Hi Raja,
Thank for solving my problem. Can you please explain me when can we set properties using "with" clause and when to set properties using setter methods? I was not able to get setBackgroundColor thats why I set background color using "with" clause and it did not give error. Do we have to set all styles using setStyle method?
What is Label property of vBox used for?I wanted to print "Hello" inside that vbox. But Label command did not help me to solve it.
Regards,
Gopal
Edited by: Gopalakrishnan K R on Jan 18, 2008 2:15 PM
2008 Jan 18 10:52 AM
Hi Raja,
Thank for solving my problem.
1. Can you please explain me when can we set properties using "with" clause and when to set properties using setter methods? I was not able to get setBackgroundColor thats why I set background color using "with" clause and it did not give error. Do we have to set all styles using setStyle method?
2. What is Label property of vBox used for?I wanted to print "Hello" inside that vbox. But Label command did not help me to solve it.
3. I have a backgroundColor option set for vb1 (a vBox component). Now I am trying to draw a line in vb1 through graphics object. It is not displaying the line. But if i remove backgroundColor property of vb1 then line
is successfully displayed. Here is the code:
<mx:VBox id="vb1"
cornerRadius="14"
paddingLeft="20"
paddingTop="20"
paddingRight="20"
paddingBottom="20"
x="26.5" y="200" width="586" height="274" autoLayout="false" backgroundColor="#CCCC00">
private function createProcessDiagram():void{
var childStateVBox:VBox = new VBox();
with (childStateVBox){
x = 10;
y = 20;
width = 320;
height = 130;
label = "Hello";
}
childStateVBox.setStyle("backgroundColor","#CC3300");
vb1.addChild(childStateVBox);
vb1.graphics.beginFill(0xCCCC00);
vb1.graphics.lineStyle(10,0x00FF00);
vb1.graphics.moveTo(330,85);
vb1.graphics.lineTo(400,85);
vb1.graphics.endFill();
}
Regards,
Gopal
Edited by: Gopalakrishnan K R on Jan 18, 2008 2:15 PM
2008 Jan 18 2:35 PM
1. most of the styles can be set only to the instatiated object only. so you cannot use them during create . you have to create the object instance then use setstyle method.
2. if you want to print some text inside your vBox use mx:lable inside vbox
3. i dont have access to flex builder now. will have to check it and get back tomorrow
Raja
2008 Mar 18 3:20 PM
Use label tag to display hello in vbox
<mx:VBox id="vb1" autoLayout="false"
backgroundColor="#CCCC00"
cornerRadius="14"
paddingLeft="20"
paddingTop="20"
paddingRight="20"
paddingBottom="20"
x="49" y="185" width="494" height="267">
<mx:Label text="hello">
* *
</mx:Label>
</mx:VBox>
2008 Jul 04 5:54 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |