从 FLEX 转换为 PHP

发布于 2025-01-01 07:11:35 字数 1460 浏览 3 评论 0原文

AS3 代码

<fx:Declarations>
    <!-- this is the RemoteObject  used to make the RPC calls -->
    <mx:RemoteObject id="myRemote" destination="MyService" source="MyService"
       endpoint="http://localhost/amfphp/gateway.php"                
            showBusyCursor="true"/>

</fx:Declarations>

protected function button1_clickHandler(event:MouseEvent):void
{
    var aut:VOAuthor;  // value object class
    aut = new VOAuthor();
    aut.id_aut = 3;
    aut.fname_aut = "test";
    aut.lname_aut = "123";
    myRemote.saveData(aut);
}

接收 PHP 代码

public function saveData($author) 
{
   $mysql = mysql_connect("localhost", "mx112", "xxxxxx");          
   mysql_select_db("flex360");      
   $query = "INSERT INTO authors (fname_aut, lname_aut) VALUES ('".$author->fname_aut."', '".$author->lname_aut."')";          
   $result = mysql_query($query);                 
   return $author;
}


<?php
class VOAuthor {   
 public $id_aut;    
 public $fname_aut;    
 public $lname_aut;        
 var $_explicitType="org.corlan.VOAuthor";}
?>

Flex 网络监视器响应:原始视图

{lname_aut=123, _explicitType=org.corlan.VOAuthor, fname_aut=test, id_aut=3}

,但如果我在 php 代码末尾执行此操作,

 return $author->lname_aut;

网络监视器响应为 NULL,

那么问题是我可以打印数组,但如何将数组转换为已知的 php 类型? 5天后,我终于找到了使用amfphp的flex和mysql,有人可以帮忙吗?

AS3 code

<fx:Declarations>
    <!-- this is the RemoteObject  used to make the RPC calls -->
    <mx:RemoteObject id="myRemote" destination="MyService" source="MyService"
       endpoint="http://localhost/amfphp/gateway.php"                
            showBusyCursor="true"/>

</fx:Declarations>

protected function button1_clickHandler(event:MouseEvent):void
{
    var aut:VOAuthor;  // value object class
    aut = new VOAuthor();
    aut.id_aut = 3;
    aut.fname_aut = "test";
    aut.lname_aut = "123";
    myRemote.saveData(aut);
}

Receving PHP code

public function saveData($author) 
{
   $mysql = mysql_connect("localhost", "mx112", "xxxxxx");          
   mysql_select_db("flex360");      
   $query = "INSERT INTO authors (fname_aut, lname_aut) VALUES ('".$author->fname_aut."', '".$author->lname_aut."')";          
   $result = mysql_query($query);                 
   return $author;
}


<?php
class VOAuthor {   
 public $id_aut;    
 public $fname_aut;    
 public $lname_aut;        
 var $_explicitType="org.corlan.VOAuthor";}
?>

Flex network monitor response : Raw view

{lname_aut=123, _explicitType=org.corlan.VOAuthor, fname_aut=test, id_aut=3}

but If I do this at the end of the php code

 return $author->lname_aut;

network monitor response is NULL

so the problem is I can print the array but how to cast tht array to a known php type ?
After 5 days I finnaly figured out flex and mysql using amfphp any one please help ?

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

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

发布评论

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

评论(2

滴情不沾 2025-01-08 07:11:35

如果您使用 amfphp 和 Flash,则必须注册您的 VO:

import org.corlan.VOAuthor;
// ...
registerClassAlias("org.corlan.VOAuthor", VOAuthor);

只有这样 php 才能识别您从 ActionScript 发送的对象。

if you are using amfphp and Flash you have to register your VOs:

import org.corlan.VOAuthor;
// ...
registerClassAlias("org.corlan.VOAuthor", VOAuthor);

only then does php recognize the objects you're sending it from ActionScript.

栖迟 2025-01-08 07:11:35

是的,您需要注册您的类,另一种方法是在 Flex VO 声明中使用元数据标记。

package VO
{
    [RemoteClass(alias="org.corlan.VOAuthor")]
    public class VOAuthor
    {
        private var id_aut   : int;
        public var fname_aut : String;
        public var lname_aut : String;
...

希望有帮助,

罗杰。

附言。可以在这里找到更详细的解释(对我有帮助):http://www.brentknigge。 com/?q=node/499

Yes you need to register your class, and an alternative is to use the metadata tag in the Flex VO declaration.

package VO
{
    [RemoteClass(alias="org.corlan.VOAuthor")]
    public class VOAuthor
    {
        private var id_aut   : int;
        public var fname_aut : String;
        public var lname_aut : String;
...

Hope that helps,

Roger.

PS. A more detailed explanation (that helped me) can be found here: http://www.brentknigge.com/?q=node/499

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