Monday, March 15, 2010
Thursday, March 4, 2010
Wednesday, February 10, 2010
Calling Flash Remote Service in Flash with Zend amf
Steps:
- Download Zend amf library and put it into your htdocs (www root) folder.
- Create a Gateway.php for connection
- Create your service using php
- Connect to service using ActionScript in TestService.fla
- Run the TestService.fla
Step 1:
- Download Zend amf library: http://framework.zend.com/download/amf
- Unzip and put the Zend folder into your htdocs folder
Step 2:
- Create a folder named “service” under htdocs.
- Create a Gateway.php under htdocs.
- Gateway.php:
<?phprequire('./Zend/Amf/Server.php');//require('./services/HowAreYou.php');$server = new Zend_Amf_Server();$server->addDirectory(dirname(__FILE__) .'/services/');//$server->setClass('HowAreYou');$response = $server->handle();echo $response;?>
Step 3:
- Create your remote service “HowAreYou.php” under “service” folder
- HowAreYou.php
<?phpclass HowAreYou{/** @param string $receiveMsg* @return string $replyMsg*/function sendStr($yourname){return "$yourname, 你好!";}}?>
Step 4:
- Write ActionScript in your TestService.fla file
- In TestService.fla
stop();var connection:NetConnection; // Initialize NetConnection Objectvar responder:Responder; // Initialize Responder Object//Construct Instanceresponder = new Responder(onResult, onFault); // Show Receive Dataconnection = new NetConnection;// Settingvar gateway:String = "http://localhost/Gateway.php";connection.connect(gateway); // Connect to Zend amf// Data Receievefunction onResult(Result:String):void {trace(Result);}// Failfunction onFault():void {trace("Connection Fail");}// Call Remoting Service's Method: (Class.Method, reaonder, parameter)connection.call("HowAreYou.sendStr",responder,"your_message");
Step 5:
- Test(Run) your TestService.fla
- you will receive “your_message,你好!” on the output window
Labels:
ActionScript,
AMF,
amfphp,
AS3,
Flash Remoting,
Setting,
Zend
Tuesday, February 9, 2010
解決 amfphp 中文字串亂碼問題
In your htdocs\amfphp\gateway.php
Comment this line of code:
//$gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1");
Add this line of code:
$gateway->setCharsetHandler( "utf8_decode", "UTF-8", "UTF-8" );
Wednesday, November 18, 2009
Monday, September 21, 2009
How to include .swc file into Flash CS4 project?
- Open the "Publish Settings" window (File->Publish Settings)
- Press the "Settings…" button right to the item "Script:"
- Select "Library path" tab and then you can include your .swc file or the folder contain the .swc file
Saturday, August 29, 2009
ActionScript 3.0 Tutorial Slide. Hope it helps
Coding Flash : ActionScript(3.0) Tutorial
I use this slide to give an ActionScript 3.0 Tutorial in the freshman training course of Intelligent Agent Laboratory in Department of Computer Science and Information Engineering of National Taiwan University.
FYI.
I use this slide to give an ActionScript 3.0 Tutorial in the freshman training course of Intelligent Agent Laboratory in Department of Computer Science and Information Engineering of National Taiwan University.
FYI.
Coding Flash : ActionScript(3.0) TutorialView more documents from PEI-YAO HUNG.
Subscribe to:
Posts (Atom)