-1

私の問題はこれです:
ビジュアル要素にmxmlを使用したい...コンポーネントをグラフィカルに設定し、プログラムするクラスとして使用したいのですが...これを行う方法は??? 2つのクラスがあります。1つはas、もう1つはmxmlです...これは私のコードです。

public class chat extends Application{
    private var nc:NetConnection = null;
    public var connect:Button;      
    public var status:Text;

    public function VideoChat(){
        addEventListener(FlexEvent.APPLICATION_COMPLETE, mainInit);
    }

    private function mainInit(event:FlexEvent):void{            
        status.text = "Status quo";

        connect.addEventListener(MouseEvent.CLICK, doConnect);
    }

およびmxml:

<?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="955" minHeight="600" backgroundColor="#FBF8F8"
           preloaderChromeColor="#CC3535" 
           >

    <mx:Button x="77" y="547" height="19" label="Connect" id="connect"/>
    <mx:UIComponent id="videoReceiveContainer" x="77" y="52" width="500" height="400"/>
    <mx:Button x="507" y="547" label="Play" id="play"/>
    <mx:Text id="status" x="77" y="460" width="501" height="58"/>
    <mx:Button x="297" y="547" label="Publish" id="publish"/>
</s:Application>
4

1 に答える 1

0

まず第一に、あなたのAS3コードは少しファンキーです。

public class VideoChat extends Application{
    private var nc:NetConnection = null;
    public var connect:Button;      
    public var status:Text;

    public function VideoChat(){
        addEventListener(FlexEvent.APPLICATION_COMPLETE, mainInit);
    }

    private function mainInit(event:FlexEvent):void{            
        status.text = "Status quo";

        connect.addEventListener(MouseEvent.CLICK, doConnect);
    }
}

クラスの名前は、コンストラクターの名前と一致する必要があります。

次に、MXML:

<?xml version="1.0" encoding="utf-8"?>
<local:VideoChat xmlns:fx="http://ns.adobe.com/mxml/2009"
                 xmlns:s="library://ns.adobe.com/flex/spark"
                 xmlns:mx="library://ns.adobe.com/flex/mx"
                 xmlns:local="*"
                 minWidth="955" minHeight="600" backgroundColor="#FBF8F8"
                 preloaderChromeColor="#CC3535" 
                 >

    <mx:Button x="77" y="547" height="19" label="Connect" id="connect"/>
    <mx:UIComponent id="videoReceiveContainer" x="77" y="52" width="500" height="400"/>
    <mx:Button x="507" y="547" label="Play" id="play"/>
    <mx:Text id="status" x="77" y="460" width="501" height="58"/>
    <mx:Button x="297" y="547" label="Publish" id="publish"/>
</local:VideoChat>

お気づきの方もいらっしゃると思いますが、XML名前空間'local'を定義しましたxmlns:local="*"。また、s:Applicationタグはに置き換えられましたlocal:VideoChat

最後に、コメントでページをロードするためのパスを尋ねました。する必要があります...bin-debug/name.html。このHTMLファイルは、プロジェクトのコンパイル済みSWFを表示するラッパーです。

于 2012-05-07T16:07:15.020 に答える