附件:
asWing.swc
示例一:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import org.aswing.*;
private var s:Sprite=new Sprite();
private function initApp(){
AsWingManager.initAsStandard(this);
var comp:UIComponent=new UIComponent();
var frame:JFrame=new JFrame(comp,"哈哈");
frame.setSizeWH(300,300);
frame.setDragable(true);
frame.setResizable(true);
frame.show();
container.addChild(comp);
}
]]>
</mx:Script>
<mx:Canvas width="100%" height="100%" id="container">
</mx:Canvas>
</mx:Application>
示例二:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Label id="mylabel" width="200" height="100"/>
<mx:Button id="mybtn1" label="button1" x="200"/>
<mx:Button id="mybtn2" label="button2" x="300"/>
<mx:Script>
<![CDATA[
import org.aswing.EmptyLayout;
import org.aswing.JPanel;
import org.aswing.JButton;
import org.aswing.AsWingManager;
public var panel:JPanel = new JPanel(new EmptyLayout());
public function init():void
{
mybtn1.addEventListener(MouseEvent.CLICK,clickbt1);
mybtn2.addEventListener(MouseEvent.CLICK,clickbt2);
AsWingManager.setRoot(mylabel);
panel.setSizeWH(200,100);
mylabel.addChild(panel);
panel.x=100;
panel.y=100;
//this.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);
AsWingManager.setRoot(this.parent);
AsWingManager.updateAfterMilliseconds(0);
}
public function clickbt1(evt:MouseEvent):void
{
if(panel.numChildren==2)
panel.removeChildAt(1);
var jb:JButton = new JButton("button--1");
jb.width=100;
jb.height=20;
panel.addChild(jb);
panel.revalidate();
trace(panel.numChildren);
}
public function clickbt2(evt:MouseEvent):void
{
trace(panel.numChildren);
if(panel.numChildren==2)
panel.removeChildAt(1);
var jb:JButton = new JButton("button--2");
jb.width=100;
jb.height =20;
panel.addChild(jb);
panel.revalidate();
}
]]>
</mx:Script>
</mx:Application>
asWing.swc
示例一:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import org.aswing.*;
private var s:Sprite=new Sprite();
private function initApp(){
AsWingManager.initAsStandard(this);
var comp:UIComponent=new UIComponent();
var frame:JFrame=new JFrame(comp,"哈哈");
frame.setSizeWH(300,300);
frame.setDragable(true);
frame.setResizable(true);
frame.show();
container.addChild(comp);
}
]]>
</mx:Script>
<mx:Canvas width="100%" height="100%" id="container">
</mx:Canvas>
</mx:Application>
示例二:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Label id="mylabel" width="200" height="100"/>
<mx:Button id="mybtn1" label="button1" x="200"/>
<mx:Button id="mybtn2" label="button2" x="300"/>
<mx:Script>
<![CDATA[
import org.aswing.EmptyLayout;
import org.aswing.JPanel;
import org.aswing.JButton;
import org.aswing.AsWingManager;
public var panel:JPanel = new JPanel(new EmptyLayout());
public function init():void
{
mybtn1.addEventListener(MouseEvent.CLICK,clickbt1);
mybtn2.addEventListener(MouseEvent.CLICK,clickbt2);
AsWingManager.setRoot(mylabel);
panel.setSizeWH(200,100);
mylabel.addChild(panel);
panel.x=100;
panel.y=100;
//this.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);
AsWingManager.setRoot(this.parent);
AsWingManager.updateAfterMilliseconds(0);
}
public function clickbt1(evt:MouseEvent):void
{
if(panel.numChildren==2)
panel.removeChildAt(1);
var jb:JButton = new JButton("button--1");
jb.width=100;
jb.height=20;
panel.addChild(jb);
panel.revalidate();
trace(panel.numChildren);
}
public function clickbt2(evt:MouseEvent):void
{
trace(panel.numChildren);
if(panel.numChildren==2)
panel.removeChildAt(1);
var jb:JButton = new JButton("button--2");
jb.width=100;
jb.height =20;
panel.addChild(jb);
panel.revalidate();
}
]]>
</mx:Script>
</mx:Application>