Overview Connect Flex with PHP (1a)

7 downloads 2110 Views 168KB Size Report
Flex 4 Introduction. Y.C. Wong. Client side. Server side. Browser. HTTPservice. Flash player xml xml php object or xml. Data tier. mySQL. Overview swf.
Flex 4 Introduction Y.C. Wong

Overview

Client side

Server side

Data tier

Browser HTTPservice

xml mySQL

xml

swf Flash player

HTTPservice object or xml

php

Connect Flex with PHP (1a) • 開啟 connectPHP.fxp • Goal: 顯示hello.php傳回的字串

none

• In helloPHP.mxml,  protected function resultHandler(event:ResultEvent):void { Alert.show(event.result.html.body as String, 'Message from PHP' ); } via help of debugger

• hello1.php First program

Connect Flex with PHP (1b) • 修改 helloPHP.mxml url="http://www.cs.pu.edu.tw/~ycwong/hello.php"  … protected function resultHandler(event:ResultEvent):void { Alert.show(event.result as String, 'Message from PHP' ); } …

• hello.php

Connect Flex with PHP (2) • Goal: 雙向通訊

POST xml.php xml

• In xmlPHP.mxml

Å deliver parameter-value pairs {titleInput.text} {instructorInput.text}

[Bindable] private var classes:XMLListCollection;  protected function resultHandler(event:ResultEvent):void { classes = new XMLListCollection(event.result.course); } Å watch express via debugger



(title, aaa) (instructor, bbb)

• In xml.php

Performance Improvement Client side

Server side

Data tier

Browser mySQL xml

1

Flash player

PHP class

Client side

Server side

Data tier

Browser AMFPHP, Zend PHP PHPservice Flash player

message in AMF (UTF-8)

2

PHP class

mySQL