我可以重复使用 Actionscript 3 NetConnection 吗?

发布于 2024-11-12 23:10:38 字数 592 浏览 7 评论 0原文

这可能是一个菜鸟问题,但由于我是 Flash 和 AS3 的新手,所以它是...

我可以以某种方式重新使用 AS3 NetConnection 吗?

我正在尝试创建一个处理连接的 AMFPHP 类,以便每当我想要调用 AMFPHP 方法时都可以重新使用该初始连接。

这是迄今为止我的代码,

package com.utils
{
    public class amfphp 
    {
        private var gateway:String = "http://localhost/amfphp/gateway.php";
        private var connection:NetConnection = new NetConnection;

        private function con(gate:String, con:NetConnection):void {
            //connect to the gateway file
            con.connect(gate);
            return con;
        }
    }
}

提前感谢!

this is probably a noob question, but since I am new to Flash and AS3, here it goes...

Can I somehow re-use a AS3 NetConnection?

I am trying to create a AMFPHP class, that handles the connection, so I can re-use that initial connection whenever I want to make a call to a AMFPHP method.

Here is my code thus far,

package com.utils
{
    public class amfphp 
    {
        private var gateway:String = "http://localhost/amfphp/gateway.php";
        private var connection:NetConnection = new NetConnection;

        private function con(gate:String, con:NetConnection):void {
            //connect to the gateway file
            con.connect(gate);
            return con;
        }
    }
}

Thanx in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

漆黑的白昼 2024-11-19 23:10:38

没错,你的解决方案是可行的。我说的一件小事是因为你说你是 as3 的新手。您的函数无法返回连接对象,因为返回值设置为 void。

一切顺利。

塔马斯

That's right, your solution is workable. One little thing what I say because you said you are are new to as3. Your function can't return with the connection object, because the return value is set to void.

All the best.

Tamas

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文