AHow to apply a style
how apply style in actionscript? example, in code below, how apply 1 of 2 embedded css styles each of dynamically generated button?
thank you!
<?xml version="1.0" encoding="utf-8"?>
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()">
<mx:script>
<![cdata[
import mx.controls.button;
private var button:button;
[bindable] private var thisbuttonnumber:number
private function init():void{
for(var i:int=0;i<10;i++){
button=new button;
button.width=200;
button.label=string(i)
panel.addchild(button);
}
}
]]>
</mx:script>
<mx:style>
.button {
fontsize: 18pt;
color: red;
}
.buttonstyle1 {
fontsize: 12pt;
color: green;
}
</mx:style>
<mx:panel id="panel" />
</mx:application>
hi,
try this:-
<?xml version="1.0" encoding="utf-8"?>
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()">
<mx:script>
<![cdata[
import mx.controls.button;
private var button:button;
[bindable] private var thisbuttonnumber:number
private function init():void{
for(var i:int=0;i<10;i++){
button=new button;
button.width=200;
button.label=string(i)
button.setstyle('stylename','buttonstyle'+i.tostring());
panel.addchild(button);
}
}
]]>
</mx:script>
<mx:style>
.buttonstyle0 {
fontsize: 12pt;
color: green;
}
.buttonstyle1 {
fontsize: 14pt;
color: red;
}
.buttonstyle2 {
fontsize: 16pt;
color: white;
}
.buttonstyle3 {
fontsize: 18pt;
color: yellow;
}
.buttonstyle4 {
fontsize: 20pt;
color: green;
}
.buttonstyle5 {
fontsize: 22pt;
color: purpole;
}
.buttonstyle6 {
fontsize: 24pt;
color: cyan;
}
.buttonstyle7 {
fontsize: 26pt;
color: orange;
}
.buttonstyle8 {
fontsize: 28pt;
color: blue;
}
.buttonstyle9 {
fontsize: 30pt;
color: black;
}
</mx:style>
<mx:panel id="panel" />
</mx:application>
with regards,
shardul singh bartwal
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment