宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

[AS3]as3.0连接数据库的实例源代码

2016-10-13 00:16:48 点击量:8 标签: 收藏本文

1.配置php环境

2.启动flex builder

3,new flex project,为project命名为php,再在服务器类型中选择php , 设置的web root(本机web目录)和root url(http地址) , 然后选择data->create application from database  在对话框中选择project为php   点 "new",配置连接名称,然后点next,配置好host url, database name, user name, password 在返回“choose data source” 选择好表名和主键

4 flex 3会自动创建一个与表同名的.mxml文件

as代码:

  1. #include "netservices.as" 
  2.    netservices.setdefaultgatewayurl("http://yourserver.com/flashservices/gateway.php"); 
  3.    gw = netservices.creategatewayconnection(); 
  4.    catalogremote = gw.getservice("catalog", this); 
  5.    catalogremote.getproducts(); 
  6.  
  7.    getproducts_result = function(result) { 
  8.    _root.products_results = result; 
  9.    } 

PHP代码

  1. class catalog { 
  2. var $products_array = array(); 
  3.  
  4. function catalog() { 
  5. $this->methodtable = array ( 
  6. "getproducts" => array ( 
  7. "description" => "get list of products", 
  8. "access" => "remote", 
  9. "arguments" => "" // arguments could be optional, not tested 
  10. ); 
  11. function getproducts() { 
  12. return $this->products_array; 

 

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室