Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 ActionScript3和mxml_Actionscript 3_Flash_Apache Flex_Flash Builder_Mxml - Fatal编程技术网

Actionscript 3 ActionScript3和mxml

Actionscript 3 ActionScript3和mxml,actionscript-3,flash,apache-flex,flash-builder,mxml,Actionscript 3,Flash,Apache Flex,Flash Builder,Mxml,我的问题是: 我想使用mxml作为视觉元素。。。我想以图形方式设置组件,并在as类中进行编程,因为这对我来说很容易。。。怎么做???我有两个类:一个是as,一个是mxml……这是我的代码: public class chat extends Application{ private var nc:NetConnection = null; public var connect:Button; public var status:Text; publi

我的问题是:
我想使用mxml作为视觉元素。。。我想以图形方式设置组件,并在as类中进行编程,因为这对我来说很容易。。。怎么做???我有两个类:一个是as,一个是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>

首先,您的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。

问题出在哪里?什么不起作用或不被理解?这是正常的代码吗???因为当我运行它时,它只会播放空白页…对我来说,它显示了三个定义的按钮,没有其他。你希望它能显示什么?对我来说,它只是一个空白页…它需要显示三个按钮和一个视频容器…但你这里没有代码…你是如何运行它的???运行单击项目、运行方式和web应用???以及浏览器中的路径???是bin debug/name.mxml吗???现在我有一个错误:无法为组件类“fm.domain.H264”找到指定的基类“VideoChat”。有什么想法吗???当我喜欢你们推荐的时候,在mxml文件中,在大纲上我并没有容器…只有红色!根…也许这就是问题所在…@Jovan您的第一个错误与我没有看到的代码有关,所以我不能说。还有,我不明白你说的集装箱是什么意思。由于某种原因,包装是一个问题…我重新开始,这次我按照你说的做了,一切都很顺利。。。谢谢,山姆。。