Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.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
Php UDK Scaleform 4 AS3跨域URL请求是否可能?_Php_Actionscript 3_Http_Unreal Development Kit_Scaleform - Fatal编程技术网

Php UDK Scaleform 4 AS3跨域URL请求是否可能?

Php UDK Scaleform 4 AS3跨域URL请求是否可能?,php,actionscript-3,http,unreal-development-kit,scaleform,Php,Actionscript 3,Http,Unreal Development Kit,Scaleform,我想通过一个在线Mysql数据库、Scaleform 4(AS3)和PHP,通过向我的Web服务器发送HTTP请求,发布我的UDKGame并获得高分。不幸的是,考虑到以下文档,我认为这可能是不可能的: 我尝试从我的GFx电影播放器发送一个URLRequest,但它似乎不起作用。以下是我在第1帧中用于GFx电影播放器的AS3代码: getScore(); function getScore():void { //var url:String = "http://myserver.com/getS

我想通过一个在线Mysql数据库、Scaleform 4(AS3)和PHP,通过向我的Web服务器发送HTTP请求,发布我的UDKGame并获得高分。不幸的是,考虑到以下文档,我认为这可能是不可能的:

我尝试从我的GFx电影播放器发送一个URLRequest,但它似乎不起作用。以下是我在第1帧中用于GFx电影播放器的AS3代码:

getScore();

function getScore():void {
//var url:String = "http://myserver.com/getScore.php";
    var request:URLRequest = new URLRequest(url);
    var requestVars:URLVariables = new URLVariables();
    requestVars.foo = "bar";
    request.data = requestVars;
    //request.method = URLRequestMethod.POST;
    //Security.allowDomain("myserver.com"); 
    //var context:LoaderContext = new LoaderContext();
    //context.securityDomain = SecurityDomain.currentDomain

    var urlLoader:URLLoader = new URLLoader();
    urlLoader = new URLLoader();
    urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
    urlLoader.addEventListener(Event.COMPLETE, loaderCompleteHandler, false, 0, true);
    urlLoader.load(request);

    }

function loaderCompleteHandler(e:Event):void {
    trace(e.target.data);
    Object(this).response.text= "response:"+e.target.data;

}

有没有什么方法可以实现我的目标,而无需编写.dll或使用手动TCP连接到我的Web服务器

不幸的是,UDK(4.0.16)附带的Scaleform没有内置任何网络支持。您必须让UDK通过dll绑定或其他方式解决这部分问题。Scaleform 4.2增加了网络支持,但该版本的Scaleform尚未完全集成到UDK中。不过,它正处于集成过程中,希望我们很快就能看到它。

事实上,SF4.0不支持这一点。SF4.2可能有,并且只有UE3许可证持有人可以通过Epic的Perforce depot使用

您可以在unrealscript中执行此操作。然而,使用dll或TCP连接有点过分。使用。这里有一个直接来自UDK提供的源样本的示例。它非常简单,您可以将其精简到只需几行代码即可调用Web服务所需的严格级别

/**
 * Simple function to illustrate the use of the HttpRequest system.
 */
exec function TestHttp(string Verb, string Payload, string URL, optional bool bSendParallelRequest)
{
    local HttpRequestInterface R;

    // create the request instance using the factory (which handles
    // determining the proper type to create based on config).
    R = class'HttpFactory'.static.CreateRequest();
    // always set a delegate instance to handle the response.
    R.OnProcessRequestComplete = OnRequestComplete;
    `log("Created request");
    // you can make many requests from one request object.
    R.SetURL(URL);
    // Default verb is GET
    if (Len(Verb) > 0)
    {
        R.SetVerb(Verb);
    }
    else
    {
        `log("No Verb given, using the defaults.");
    }
    // Default Payload is empty
    if (Len(Payload) > 0)
    {
        R.SetContentAsString(Payload);
    }
    else
    {
        `log("No payload given.");
    }
    `log("Creating request for URL:"@URL);

    // there is currently no way to distinguish keys that are empty from keys that aren't there.
    `log("Key1 ="@R.GetURLParameter("Key1"));
    `log("Key2 ="@R.GetURLParameter("Key2"));
    `log("Key3NoValue ="@R.GetURLParameter("Key3NoValue"));
    `log("NonexistentKey ="@R.GetURLParameter("NonexistentKey"));
    // A header will not necessarily be present if you don't set one. Platform implementations
    // may add things like Content-Length when you send the request, but won't necessarily
    // be available in the Header.
    `log("NonExistentHeader ="@R.GetHeader("NonExistentHeader"));
    `log("CustomHeaderName ="@R.GetHeader("CustomHeaderName"));
    `log("ContentType ="@R.GetContentType());
    `log("ContentLength ="@R.GetContentLength());
    `log("URL ="@R.GetURL());
    `log("Verb ="@R.GetVerb());

    // multiple ProcessRequest calls can be made from the same instance if desired.
    if (!R.ProcessRequest())
    {
        `log("ProcessRequest failed. Unsuppress DevHttpRequest to see more details.");
    }
    else
    {
        `log("Request sent");
    }
    // send off a parallel request for testing.
    if (bSendParallelRequest)
    {
        if (!class'HttpFactory'.static.CreateRequest()
            .SetURL("http://www.epicgames.com")
            .SetVerb("GET")
            .SetHeader("Test", "Value")
            .SetProcessRequestCompleteDelegate(OnRequestComplete)
            .ProcessRequest())
        {
            `log("ProcessRequest for parallel request failed. Unsuppress DevHttpRequest to see more details.");
        }
        else
        {
            `log("Parallel Request sent");
        }
    }
}


/** Delegate to use for HttpResponses. */
function OnRequestComplete(HttpRequestInterface OriginalRequest, HttpResponseInterface Response, bool bDidSucceed)
{
    local array<String> Headers;
    local String Header;
    local String Payload;
    local int PayloadIndex;

    `log("Got response!!!!!!! Succeeded="@bDidSucceed);
    `log("URL="@OriginalRequest.GetURL());
    // if we didn't succeed, we can't really trust the payload, so you should always really check this.
    if (Response != None)
    {
        `log("ResponseURL="@Response.GetURL());
        `log("Response Code="@Response.GetResponseCode());
        Headers = Response.GetHeaders();
        foreach Headers(Header)
        {
            `log("Header:"@Header);
        }
        // GetContentAsString will make a copy of the payload to add the NULL terminator,
        // then copy it again to convert it to TCHAR, so this could be fairly inefficient.
        // This call also assumes the payload is UTF8 right now, as truly determining the encoding
        // is content-type dependent.
        // You also can't trust the content-length as you don't always get one. You should instead
        // always trust the length of the content payload you receive.
        Payload = Response.GetContentAsString();
        if (Len(Payload) > 1024)
        {
            PayloadIndex = 0;
            `log("Payload:");
            while (PayloadIndex < Len(Payload))
            {
                `log("    "@Mid(Payload, PayloadIndex, 1024));
                PayloadIndex = PayloadIndex + 1024;
            }
        }
        else
        {
            `log("Payload:"@Payload);
        }
    }
}
/**
*简单的函数来说明HttpRequest系统的使用。
*/
exec函数TestHttp(字符串谓词、字符串有效负载、字符串URL、可选bool BSENDPALLELEQUEST)
{
本地HttpRequestInterface R;
//使用工厂创建请求实例(处理
//根据配置确定要创建的正确类型)。
R=类“HttpFactory”.static.CreateRequest();
//始终设置一个委托实例来处理响应。
R.OnProcessRequestComplete=OnRequestComplete;
`日志(“创建请求”);
//您可以从一个请求对象发出多个请求。
R.SetURL(URL);
//默认动词是GET
if(Len(动词)>0)
{
动词(动词);
}
其他的
{
`log(“没有动词,使用默认值。”);
}
//默认有效负载为空
如果(Len(有效载荷)>0)
{
R.SetContentAsString(有效载荷);
}
其他的
{
`日志(“未给出有效载荷”);
}
`日志(“创建URL请求:@URL”);
//目前无法区分空键和不存在的键。
`日志(“Key1=“@R.GetURLParameter(“Key1”));
`日志(“Key2=“@R.GetURLParameter(“Key2”));
`日志(“Key3NoValue=“@R.GetURLParameter”(“Key3NoValue”);
`日志(“NonexistentKey=“@R.GetURLParameter(“NonexistentKey”);
//如果未设置标头,则不一定存在标头。平台实现
//在发送请求时可能会添加内容长度之类的内容,但不一定
//可以在标题中找到。
`日志(“NonExistentHeader=“@R.GetHeader”(“NonExistentHeader”);
`日志(“CustomHeaderName=“@R.GetHeader”(“CustomHeaderName”);
`日志(“ContentType=“@R.GetContentType());
`日志(“ContentLength=“@R.GetContentLength());
`日志(“URL=“@R.GetURL());
`日志(“Verb=“@R.GetVerb());
//如果需要,可以从同一实例进行多个ProcessRequest调用。
如果(!R.ProcessRequest())
{
`日志(“ProcessRequest失败。取消抑制DevhtPrequest以查看更多详细信息。”);
}
其他的
{
`日志(“已发送请求”);
}
//发送一个并行测试请求。
if(bSendParallelRequest)
{
如果(!class'HttpFactory'.static.CreateRequest()
.SetURL(“http://www.epicgames.com")
.SetVerb(“GET”)
.SetHeader(“测试”、“值”)
.SetProcessRequestCompleteDelegate(OnRequestComplete)
.ProcessRequest())
{
`日志(“并行请求的ProcessRequest失败。取消对DevhtPrequest的抑制以查看更多详细信息。”);
}
其他的
{
`日志(“发送并行请求”);
}
}
}
/**要用于httpresponse的委托*/
函数OnRequestComplete(HttpRequestInterface原始请求、HttpResponseInterface响应、bool bDidSucceed)
{
本地数组头;
本地字符串头;
本地字符串有效载荷;
本地int有效负载指数;
`日志(“获得响应!!!!!!!成功=“@bDidSucceed”);
`日志(“URL=“@OriginalRequest.GetURL());
//如果我们没有成功,我们就不能真正信任有效负载,因此您应该始终检查这一点。
如果(响应!=无)
{
`日志(“ResponseURL=“@Response.GetURL());
`日志(“响应代码=“@Response.GetResponseCode());
Headers=Response.GetHeaders();
foreach标头(标头)
{
`日志(“标题:@标题);
}
//GetContentAsString将复制有效负载以添加空终止符,
//然后再次复制它以将其转换为TCHAR,因此这可能是相当低效的。
//这个调用还假设负载现在是UTF8,因为它真正确定了编码
//与内容类型相关。
//你也不能相信内容的长度,因为你并不总能得到一个。你应该这样做
//始终信任您收到的内容有效负载的长度。
Payload=Response.GetContentAsString();
如果(Len(有效载荷)>1024)
{
有效载荷指数=0;
`日志(“有效载荷:”);
while(有效载荷指数