Flex3.0
阅读原文时间:2021年04月22日阅读:1

Flex组件不能显示问题:

1.组合组件要定义宽和高

package component
{
        import mx.controls.Label;
        import mx.core.UIComponent;

        public class LabelComponent extends UIComponent
        {
                public function LabelComponent()
                {
                        super();
                }
               
                override protected function createChildren():void{
                        super.createChildren();
                        var label:Label = new Label();
                        label.text = "success";
                        this.addChild(label);
                }
               
        }
}

2.html 中调用swf 以及传递参数

http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">                                   "allowFullScreen="true"  quality="high" bgcolor="#869ca7"        width="800" height="268" name="FetchInfo" align="middle"        play="true"        loop="false"        quality="high"        allowScriptAccess="sameDomain"        type="application/x-shockwave-flash"        pluginspage="http://www.adobe.com/go/getflashplayer">            

swf中得到参数的值:

 sourceid=Application.application.parameters["sourceid"];

3.swf 发送给服务端,接收返回的参数

使用HttpService对象

loginService.url ="/crawl/returnCrawlInfo2.dhtml";
    loginService.addEventListener(mx.rpc.events.FaultEvent.FAULT, getConfiguration);
    var loc1:*=new flash.net.URLVariables();
    loc1.dt = int(Math.random() * 10);
    loc1.sourceid=int(sourceid);
    loginService.send(loc1);

Action 通过:

request.getParameter("sourceid")得到swf 传递的值

返回的处理:

private function doResultHandle(arg1:mx.rpc.events.ResultEvent):void
   {
    var loc1:*=arg1.result.toString();
    var loc2:*=com.adobe.serialization.json.JSON.decode(loc1);
    if (loc2)
    {
     url1 = loc2.url;
     port = loc2.port;
    }
    start();
    return;
   }

其中Action 如果要输出直接JSon对象:使用过滤器

4.如何将socket 取得的数 放在DataGrid 中

1. 定义arrayClllection

2.绑定数据

3.添加数据

                    

使用{}绑定

                           

建立事件响应

private function socketConn():void
   {   
    socket.connect(url1, port);
    trace(url1+":"+port);
    //we.text="socketConn:"+url1+":"+port;
    socket.addEventListener(flash.events.Event.CONNECT, onConnnect);
    socket.addEventListener(flash.events.Event.CLOSE, onClose);
    socket.addEventListener(flash.events.ProgressEvent.SOCKET_DATA, runFun);
    return;
   }

读取数据

while (socket.bytesAvailable)
    {
     //we.text="runFun"+(number++);
     msg = socket.readMultiByte(socket.bytesAvailable, "utf-8");
     var temp:*=com.adobe.serialization.json.JSON.decode(msg);
     if(temp){
      status=temp.status;
      if(status == "ok"){
      temp.status="正常";
      }else{
       temp.status="失败";
      }
     arrColl.addItem(temp);
     //we.text="runFun"+(msg);
     }
    }
    return;

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章