Flex读取浏览器参数
这个类提供的功能有:
从浏览器中获取完整的URL
主机名
当前所使用的协议
端口
主域名后面的路径
参数值
原文地址:http://www.flexpasta.com/index.php/2008/03/15/getting-url-parameters-host-name-port-in-flex-actionscript/
package com.flexpasta.utils
{
import flash.external.ExternalInterface;
import mx.core.Application;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
public class HTTPUtil
{
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------
/**
* @private
*/
public function HTTPUtil()
{
super();
}
/**
* Returns the current url that the swf player lives in
*
*/
public static function getUrl():String
{
return ExternalInterface.call("window.location.href.toString");
}
/**
* Returns the current host name.
* example: http://www.flexpasta.com/?x=1&y=2 would return www.flexpasta.com
*/
public static function getHostName():String
{
return ExternalInterface.call("window.location.hostname.toString");
}
/**
* Returns the current protocol, such as http:, https:, etc
*
*/
public static function getProtocol():String
{
return ExternalInterface.call("window.location.protocol.toString");
}
/**
* Gets the current port for the url
*/
public static function getPort():String
{
return ExternalInterface.call("window.location.port.toString");
}
/**
* Gets the context following the base of the url
* Example http://www.flexpasta.com/test?x=1&y=2 would return /test
*/
public static function getContext():String
{
return ExternalInterface.call("window.location.pathname.toString");
相关文档:
最近遇到了flex 的安全沙箱问题,找了很多资料发现不是都是和我,我的程序需要socket连接,而大多数讲的都是跨域文件读取的。我先把两种方法都总结出来:
跨域文件读取
方法一:在目标服务器上布署crossdomain.xml文件(我用的此方法很管用,放上就没问题了) 需要远程服务根目录定义有crossdomain.xml文件,如下:
<?x ......
研究E4X与Flex的关系,所以打算总结一下,有说的不对的地方,还请大家多多原谅。
一、最简单模式:Flex通过httpservice和dataProvider进行数据传输
Xml格式如下:
<?xml version="1.0" encoding="utf-8" ?>
<Result>
<NodeA>value1</NodeA>
<NodeB>valve2</NodeB>
…&he ......
本文共两个文件:translate.mxml 和 mapmarking.xml
1、translate.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="librar ......
服务器端代码,amfphp的services目录下建立readData.php文件,代码如下
<?php
class ReadDB
{
function getData()
&nb ......
本帖最后由 flashyiyi 于 2009-2-22 23:18 编辑
最终我决定还是用“隐藏”这个不是很合适的词。mx_internal是一个自定义命名空间,至于“命名空间”到底是什么就不在这里说了。总之,当我们在代码头部写上:
use namespace mx_internal
(如果是.AS文件,需要手动import mx.core.mx_internal,注 ......