Flex初体验

Flex入门推荐教程:http://wenku.baidu.com/view/98ee93fbaef8941ea76e05ef.html

虽然是基于Flash Builder 2讲的,基本上跟flex没有区别,何况它是从flex的基本用法讲起的。

特点:概念清晰,详略得当。



Flex跨域问题与swf中是一样的,最佳解决方法就是代理了。php本地代理:

<?php $ver = "1.0.0"; $copy=""; if(!isset($_GET['address']) || !$_GET['address']){ die(" nsT web proxy $ver PHP Web proxy :: nst.e-nex.com Address: Example: www.yourdomain.com/path/proxy.php?address=http://www.baidu.com or www.yourdomain.com/path/proxy.php?address=blogs.adobe.com/mchotin/feed \n $copy "); }else{ $address = $_GET['address']; $php_self= $_SERVER['PHP_SELF']; $total =""; $offset=0; $info =""; # v1.1 # $x=$address; $c=strlen($x); if($x{0}.$x{1}.$x{2}.$x{3}.$x{4}.$x{5}.$x{6}=="http://"){ for($i=7; $i < $c; $i++){ $total.=$x{$i}; } $address=$total; } # end of v1.1 # $get_add = explode("/",$address,2); if($_GET['address']){ $fp = @fsockopen($get_add[0], 80); if(count($get_add)<2){ array_push($get_add,"");} $out = "GET /$get_add[1] HTTP/1.0\r\n"; $out .= "Host: $get_add[0]\r\n"; $out .= "\r\n"; $out .= "Connection: Close\r\n\r\n"; for(fwrite($fp, $out);trim(fgets($fp));); while (!feof($fp)) { $info.=fgets($fp, 128); } fclose($fp); $script_url=$php_self; $web=$info; preg_match_all("#\s(href|src|action|codebase|url)=([\"\'])?(.*?)([\"\'])?([\s\>])#i", $web, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $uri = trim($match[3]); $fragment = ($hash_pos = strpos($uri, '#') !== false) ? '#' . substr($uri, $hash_pos) : ''; $addr=parse_url("http://".$address."/"); $path=pathinfo($addr['path']); $path=$path['dirname']; $path=str_replace("\\","",$path); if(!eregi("$address",$uri) and !eregi("http://",$uri)){$uri="http://".$addr['host']."/$path/$uri";} if(substr_count($uri, "http://".$addr['host']."/")>1){$uri=str_replace("http://".$addr['host']."/","",$uri); $uri="http://".$addr['host']."/$uri";} $url=$uri; $c=strlen($url); for($i=0; $i<$c; $i++){ $cp=substr($url, $i, $i+1); if(substr($url,$i-2,2)=="//" and substr($url,$i-3,3)!="://"){ $url=substr_replace($url, '', $i-2, 1); } } $uri=$url; $replace = ' ' . $match[1] . '=' . $match[2] . $script_url . '?address=' . $uri . $fragment . $match[4] . $match[5]; $web = str_replace($match[0], $replace, $web); } print $web; } #end of go } ?>
Flex例子:<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="feedRequest.send();"> <mx:Script> <![CDATA[ private function clear():void { my_text_input_1.text="clear it!"; } ]]></mx:Script> <mx:HTTPService id="feedRequest" url="http://localhost/proxy.php?address=blogs.adobe.com/mchotin/feed" useProxy="False" /> <mx:Label text="Hello World" /> <mx:TextInput id="my_text_input_1" width="100" text="{feedRequest.lastResult.rss.channel.title}" /> <mx:Button id="my_clear_button_1" label="clear" click="clear();" /> </mx:Application>

编译方法:

D:\http_root\code>mxmlc control.mxml Loading configuration file C:\Program Files\flex4sdk\frameworks\flex-config.xml D:\http_root\code\control.swf (314271 bytes)
D:\http_root\code>
 
 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值