Actionscript 3 组元素在adobe flex 3中不起作用
我试图在AdobeFlex3中创建带有关闭按钮的多个选项卡。为此,我创建了父对象和子对象。选项卡的父对象和关闭按钮的子对象,并将这两个对象按语法放置在名为“addButton()”的函数中的组容器中。我的代码在AdobeFlex4.5中运行良好,但在AdobeFlex3中不起作用。由于某些原因,我不得不使用AdobeFlex3。我尝试过其他容器,如:HBox、ControlBar等,但它们无法生成正确的选项卡视图。下面是代码Actionscript 3 组元素在adobe flex 3中不起作用,actionscript-3,flash,apache-flex,adobe,flex3,Actionscript 3,Flash,Apache Flex,Adobe,Flex3,我试图在AdobeFlex3中创建带有关闭按钮的多个选项卡。为此,我创建了父对象和子对象。选项卡的父对象和关闭按钮的子对象,并将这两个对象按语法放置在名为“addButton()”的函数中的组容器中。我的代码在AdobeFlex4.5中运行良好,但在AdobeFlex3中不起作用。由于某些原因,我不得不使用AdobeFlex3。我尝试过其他容器,如:HBox、ControlBar等,但它们无法生成正确的选项卡视图。下面是代码 <?xml version="1.0" encoding="u
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="127" minHeight="34" backgroundColor="#F4E8E8">
<s:layout>
<s:FormItemLayout/>
</s:layout>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.graphics.SolidColor;
import spark.components.Button;
import spark.components.Group;
import spark.primitives.Rect;
public function addButton():void {
//Child Object
var myButton:Button = new Button();
myButton.id = "dd";
myButton.label="X";
myButton.width = 40;
myButton.height = 20;
myButton.depth =1;
myButton.x=50;
myButton.setStyle("color",'red');
myButton.addEventListener(MouseEvent.CLICK, btn);
//Parent Object
var lble:Group = new Group();
var solidColor:SolidColor = new SolidColor(0xFF0000);
var rec:Rect = new Rect();
rec.fill = solidColor;
rec.percentWidth = 100;
rec.percentHeight = 100;
lble.width = 127;
lble.height = 34;
lble.depth =0;
lble.addElement(rec);
lble.addEventListener(MouseEvent.CLICK, lable);
lble.addElement(myButton);
myGroup.addElement(lble);
}
private function btn(e:Event):void {
e.stopPropagation();
jj.text = 'Text For Button';
}
private function lable(e:Event):void {
kk.text = "Text For Label";
}
]]>
</fx:Script>
<s:HGroup id="myGroup">
<s:Button width="126" height="34" click="addButton();" label="Click" skinClass="spark.skins.spark.ButtonSkin"/>
</s:HGroup>
<s:Label id="jj" x="14" y="150" width="1200" height="50" backgroundColor="gray" text="Button"/>
<s:Label id="kk" x="14" y="69" width="1200" height="50" backgroundColor="gray" text="Label"/>
</s:Application>
请帮助我1)组元素(容器)在Flex 3中不工作:
它肯定不会在Flex3中工作,Flex3和Flex4或者mx(halo)和spark(Gumbo)之间有很大的区别。如果您想将组件从spark转换为mx,或者从mx转换为spark,那么您需要清楚地了解这两个方面
这里有一篇很好的文章解释了
2)我试图在adobe flex 3中创建多个带有关闭按钮的选项卡:
由于Flex是一个成熟了10年的框架,所以有很多开源组件可用,您不必从头开始创建组件。但我很感激你用自己的方式去做
在开始创建组件之前,请先了解一下这一点
1)组元素(容器)在Flex 3中不工作:
它肯定不会在Flex3中工作,Flex3和Flex4或者mx(halo)和spark(Gumbo)之间有很大的区别。如果您想将组件从spark转换为mx,或者从mx转换为spark,那么您需要清楚地了解这两个方面
这里有一篇很好的文章解释了
2)我试图在adobe flex 3中创建多个带有关闭按钮的选项卡:
由于Flex是一个成熟了10年的框架,所以有很多开源组件可用,您不必从头开始创建组件。但我很感激你用自己的方式去做
在开始创建组件之前,请先了解一下这一点
您可以使用Box作为mx组件。以下是您可以在flex 3中执行的操作:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.containers.Box;
public function addButton():void {
//Child Object
var myButton:Button = new Button();
myButton.id = "dd";
myButton.label="X";
myButton.width = 40;
myButton.height = 20;
myButton.x=50;
myButton.setStyle("color",'red');
myButton.addEventListener(MouseEvent.CLICK, btn);
//Parent Object
var box:Box = new Box();
box.setStyle("borderThickness", "1");
box.setStyle("borderStyle", "solid");
box.setStyle("borderColor", "black");
box.setStyle("backgroundColor", "0xFF0000");
box.width = 127;
box.height = 34;
box.addEventListener(MouseEvent.CLICK, lable);
box.addChild(myButton);
myHBox.addChild(box);
}
private function btn(e:Event):void {
e.stopPropagation();
jj.text = 'Text For Button';
}
private function lable(e:Event):void {
kk.text = "Text For Label";
}
]]>
</mx:Script>
<mx:HBox id="myHBox">
<mx:Button width="126" height="34" click="{addButton();}" label="Click"/>
</mx:HBox>
<mx:Label id="jj" x="14" y="150" width="1200" height="50" text="Button"/>
<mx:Label id="kk" x="14" y="69" width="1200" height="50" text="Label"/>
</mx:Application>
您可以使用Box作为mx组件。以下是您可以在flex 3中执行的操作:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.containers.Box;
public function addButton():void {
//Child Object
var myButton:Button = new Button();
myButton.id = "dd";
myButton.label="X";
myButton.width = 40;
myButton.height = 20;
myButton.x=50;
myButton.setStyle("color",'red');
myButton.addEventListener(MouseEvent.CLICK, btn);
//Parent Object
var box:Box = new Box();
box.setStyle("borderThickness", "1");
box.setStyle("borderStyle", "solid");
box.setStyle("borderColor", "black");
box.setStyle("backgroundColor", "0xFF0000");
box.width = 127;
box.height = 34;
box.addEventListener(MouseEvent.CLICK, lable);
box.addChild(myButton);
myHBox.addChild(box);
}
private function btn(e:Event):void {
e.stopPropagation();
jj.text = 'Text For Button';
}
private function lable(e:Event):void {
kk.text = "Text For Label";
}
]]>
</mx:Script>
<mx:HBox id="myHBox">
<mx:Button width="126" height="34" click="{addButton();}" label="Click"/>
</mx:HBox>
<mx:Label id="jj" x="14" y="150" width="1200" height="50" text="Button"/>
<mx:Label id="kk" x="14" y="69" width="1200" height="50" text="Label"/>
</mx:Application>
我认为Flex 3不支持spark组件。我认为Flex 3不支持spark组件。