2011-03-08 88 views
1

嗨,我是新来flex, 我想用flex曲线图来显示存储在mysql表中的数据。任何人都可以建议我如何做到这一点与Flex作为用户界面和MySQL作为数据库,我不知道如何调用.php文件在flex从MySQL查询。我想显示一些数据的时间v/s温度连接到MySQL使用PHP中的flex

我写了一个php文件来查询数据从mysql,但我的flex程序无法连接到mysql,有没有我需要更新的任何配置。我正在使用XAMPP

+0

你知道HTTPService吗? http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/http/mxml/HTTPService.html您还可以配置您的后端:右键单击项目 - >属性 - > Flex服务器,但我尚未与此属性一起工作。 – hering 2011-03-08 15:32:24

回答

1

一般来说,没有额外的配置需要使其工作,因为她在评论中表示,HTTPService将满足您的需求。这里有您需要做什么:

private var myCollection:ArrayCollection; 

public function creationComplete(event:Event):void 
{ 
    var myService:HTTPService = new HTTPService(); 
    myService.url = "myscript.php" 
    myService.method = "POST"; 
    myService.addEventListener(ResultEvent.RESULT, resultHandler); 
    myService.send(); 
} 

public function resultHandler(event:ResultEvent):void 
{ 
    if(event.result..entries is ArrayCollection) 
     myCollection = event.result..entries; 
    else if(event.result..entries is Object) 
     myCollection = new ArrayCollection(event.result..entries) 
} 

我假设你添加监听到该服务呼叫住在创造完整的调用创建功能齐全任何控制。我还假设你有(php生成)xml结构,如:

<entry> 
    <entries>1</entries> 
    <entries>2</entries> 
</entry> 
+0

要注意,如果您看不到任何内容,请将侦听器添加到FaultEvent.FAULT字符串的HTTPService,如果您从服务器获得除了正常消息之外的其他信息,您将收到消息。 – shaunhusain 2011-03-08 16:15:09