<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sönke Rohde &#187; AMFPHP</title>
	<atom:link href="http://soenkerohde.com/category/amfphp/feed/" rel="self" type="application/rss+xml" />
	<link>http://soenkerohde.com</link>
	<description>Flash Platform (Flash, Flex, AIR) thoughts and examples</description>
	<lastBuildDate>Fri, 30 Dec 2011 16:15:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>AMFPHP on AIR Tutorial with MAMP</title>
		<link>http://soenkerohde.com/2008/06/amfphp-on-air-tutorial-with-mamp/</link>
		<comments>http://soenkerohde.com/2008/06/amfphp-on-air-tutorial-with-mamp/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 16:14:21 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=197</guid>
		<description><![CDATA[<p>I had a look at my 3 year old AMFPHP tutorial and thought about what all changed. ActionScript 2 was replaced by AS3, I moved from Flash to Flex and changed my OS from Windows to OS X. I have developed desktop apps in the past with SWF Studio and now Adobe AIR is the solution [...]]]></description>
			<content:encoded><![CDATA[<p>I had a look at my 3 year old <a href="http://soenkerohde.com/tutorials/amfphp/">AMFPHP tutorial</a> and thought about what all changed. ActionScript 2 was replaced by AS3, I moved from Flash to Flex and changed my OS from Windows to OS X. I have developed desktop apps in the past with SWF Studio and now <a href="http://www.adobe.com/products/air/">Adobe AIR</a> is the solution for cross platform desktop applications. Summary:</p>
<ul>
<li>AS2 -&gt; AS3</li>
<li>Flash -&gt; Flex</li>
<li>Windows -&gt; OS X</li>
<li>SWF Studio -&gt; Adobe AIR</li>
</ul>
<p>Due to these huge changes I wanted to see how <a href="http://amfphp.org">AMFPHP</a> fits into this environment and write a new tutorial.</p>
<p>First the setup up the local server. Instead of WAMP (Windows, Apache, MySQL, PHP) I am now using MAMP (M for Mac) which is the pendent on OS X:</p>
<ul>
<li>Download and install <a href="http://sourceforge.net/projects/mamp">MAMP</a> an Mac+Apache+MySQL+PHP bundle</li>
<li>Start the MAMP server: /Applications/MAMP/MAMP.app (Your browser should come up with a MAMP page saying your installation was successfully)</li>
<li>Download the latest <a href="http://sourceforge.net/project/showfiles.php?group_id=72483#files">AMFPHP</a> and put it into /Applications/MAMP/htdocs/amfphp (I used 1.9 beta 20080120)</li>
<li>Download the <a href="http://soenkerohde.com/downloads/AMFPHPonAir/MyService.php.txt">MyService.php.txt</a>, rename it to MyService.php and place it into /Applications/MAMP/htdocs/amfphp/services</li>
</ul>
<p>As a client we could choose Flex in the browser but I wanted to demonstrate AIR:</p>
<ul>
<li>Open Flex Builder and create a new AIR project called AMFPHPonAIR</li>
<li>The AMFPHPonAIR.mxml opens where you put this code (<a href="http://soenkerohde.com/downloads/AMFPHPonAir/AMFPHPonAIR.mxml.txt">download</a>):</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:WindowedApplication xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;vertical&quot;</span>
	creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">channels</span>.<span style="color: #006600;">AMFChannel</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">ChannelSet</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">FaultEvent</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
&nbsp;
			<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> lastResult:<span style="color: #0066CC;">String</span>;
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> cs:ChannelSet = <span style="color: #000000; font-weight: bold;">new</span> ChannelSet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #000000; font-weight: bold;">var</span> channel:AMFChannel = <span style="color: #000000; font-weight: bold;">new</span> AMFChannel<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;my-amf&quot;</span>, <span style="color: #ff0000;">&quot;http://localhost:8888/amfphp/gateway.php&quot;</span><span style="color: #66cc66;">&#41;</span>;
				cs.<span style="color: #006600;">addChannel</span><span style="color: #66cc66;">&#40;</span>channel<span style="color: #66cc66;">&#41;</span>;
				myService.<span style="color: #006600;">channelSet</span> = cs;
				myService.<span style="color: #006600;">hello</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;You&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onResult<span style="color: #66cc66;">&#40;</span>re:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> s:<span style="color: #0066CC;">String</span> = re.<span style="color: #006600;">result</span> as <span style="color: #0066CC;">String</span>;
				Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>s, <span style="color: #ff0000;">&quot;Remote Result&quot;</span><span style="color: #66cc66;">&#41;</span>;
				lastResult = s;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onFault<span style="color: #66cc66;">&#40;</span>fe:FaultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>fe.<span style="color: #0066CC;">message</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;Remote Error&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:TraceTarget fieldSeparator=<span style="color: #ff0000;">&quot;-&gt;&quot;</span> includeLevel=<span style="color: #ff0000;">&quot;true&quot;</span> includeCategory=<span style="color: #ff0000;">&quot;true&quot;</span> includeTime=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #66cc66;">/&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:RemoteObject id=<span style="color: #ff0000;">&quot;myService&quot;</span> result=<span style="color: #ff0000;">&quot;onResult(event)&quot;</span> fault=<span style="color: #ff0000;">&quot;onFault(event)&quot;</span>
        showBusyCursor=<span style="color: #ff0000;">&quot;true&quot;</span> destination=<span style="color: #ff0000;">&quot;AMFPHP&quot;</span> source=<span style="color: #ff0000;">&quot;MyService&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>mx:method <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;hello&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:RemoteObject<span style="color: #66cc66;">&gt;</span>
&nbsp;
    <span style="color: #66cc66;">&lt;</span>mx:HBox<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;message&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Yourself&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;say hello&quot;</span> click=<span style="color: #ff0000;">&quot;myService.hello(message.text)&quot;</span> <span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:HBox<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Last Result: {lastResult}&quot;</span> <span style="color: #66cc66;">/&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>The most important part is in the init function  where the remoting endpoint is set via ActionScript.<br />
Right-click the src/AMFPHPonAIR.mxml and choose Debug As-&gt; Adobe AIR Application</p>
<p>If all works right you should see something like this:</p>
<p><img src="http://soenkerohde.com/downloads/AMFPHPonAir/amfphponair.jpg" alt="AMFPHP on AIR" width="499" height="395" /></p>
<p>You can change the text in the TextInput control and click the button to send it to your server and the result is shown below the TextInput. Now that was easy I think! About 50 lines of code for a full AIR application which uses AMFPHP on the server side.</p>
<p>This example works but has no seperation of model,view and controller so I changed it to use the <a href="http://labs.adobe.com/wiki/index.php/Cairngorm">Cairngorm</a> micro-architecture. Download this <a href="http://soenkerohde.com/downloads/AMFPHPonAir/srcview/AMFPHPonAir.zip">example AIR application</a> (<a href="http://soenkerohde.com/downloads/AMFPHPonAir/srcview/index.html">sourceview</a>) and overwrite it into the src folder</p>
<p>The Cairngorm.swc should be in placed in the libs directory of your AIR project. Now let&#8217;s dive a bit in the code to understand the Cairngorm structure and how the RemoteObject configuration with the AMFPHP remoting gateway.</p>
<p>The AMFPHPonAIR.mxml is the main application MXML and you can right-click it to Run or Debug your AIR application. If you are not familiar with Cairngorm at all I recommend checking the <a href="http://labs.adobe.com/wiki/index.php/Cairngorm#Documentation_and_Samples">docs</a> as this is not a Cairngorm tutorial. If you have questions feel free to post a comment.</p>
<p>The main MXML is pretty short and instantiates only a TraceTarget, the FrontController, the Services (ServiceLocator) and the main view.</p>
<p>The creationComplete event goes into the init-function which dispatches a StartupEvent. Open the airamfphp/ctrl/FrontController.as on you see two events mapped to their commands. When the StartupEvent is dispatched the CairngormEventDispatcher calls the StartupCommand&#8217;s execute method with the event as the parameter.</p>
<p>Open the airamfphp/StartupCommand.as. The execute method gets called when the StartupEvent is dispatched. The ServiceLocator singleton maps to our business/Services.mxml because we instantiated it in out main MXML. The Services.mxml defines the RemoteObject which maps to the MyTestservice.php in the AMFPHP services directory. I added the method <em>setServer</em> to the ServiceLocator to set the remoting endpoint. This is pretty straight forward and is a replacement for the services-config.xml which can be compiled into the application (compiler flag -services service-config.xml). In real life the server settings should come out of an external configuration so you can switch from local dev to staging, production etc.</p>
<p>Going on in the StartupCommand you see that MyDelegate get&#8217;s instantiated and we call hello &#8220;You&#8221;. The delegate expects an IResponder as parameter and the command implements the IResponder interface meaning the methods result and fault. The delegate is standard Cairngorm so let&#8217;s finalize the command. For result and fault an Alert comes up which shows the server result of the call of MyService.hello(&#8220;You&#8221;).</p>
<p>The view/MainView.mxml shows a TextInput, Button and Label and when the button is pressed a HelloEvent with the text of the TextInput as parameter. The HelloEvent is mapped to the HelloCommand in the FrontController so open the HelloCommand to see what happens. We use the same delegate and fault-method and the result-method is changed to set the result within a bindable variable in the model/MyModelLocator singleton. This variable is bound to the Label&#8217;s text property so it shows up there after you pressed the button and the result is received from the server. That&#8217;s it!</p>
<p><br/><br />
If you want to use Flex in the browser instead of AIR simply create a new Flex project and change the root node from WindowedApplication to Application. The rest of the source should stay the same as we did not use any AIR API specific features.<br />
A big thanks to the guys who have taken over the AMFPHP project and to Patrick Mineault of course for this great peace of software!<br />
I would appreciate feedback if the detail level is to low or if your miss explanations on any parts so I can extend these parts.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2008/06/amfphp-on-air-tutorial-with-mamp/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>AMFPHP 1.0 released</title>
		<link>http://soenkerohde.com/2005/12/amfphp-10-released/</link>
		<comments>http://soenkerohde.com/2005/12/amfphp-10-released/#comments</comments>
		<pubDate>Mon, 26 Dec 2005 19:23:07 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/2005/12/26/amfphp-10-released/</guid>
		<description><![CDATA[<p>via Flashmagazine: AMFPHP 1.0 is officially released.
Anybody new to AMFPHP could follow [...]]]></description>
			<content:encoded><![CDATA[<p>via <a href="http://www.flashmagazine.com/1227.htm">Flashmagazine</a>: <a href="http://amfphp.org">AMFPHP</a> 1.0 is officially released.<br />
Anybody new to AMFPHP could follow my <a href="http://soenkerohde.com/tutorials/amfphp">tutorial</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2005/12/amfphp-10-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AMFPHP 1.0 milestone released</title>
		<link>http://soenkerohde.com/2005/06/amfphp-10-milesstone-released/</link>
		<comments>http://soenkerohde.com/2005/06/amfphp-10-milesstone-released/#comments</comments>
		<pubDate>Sun, 26 Jun 2005 09:31:00 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/2005/06/26/amfphp-10-milesstone-released/</guid>
		<description><![CDATA[<p>A new milestone for AMFPHP 1.0 is released and it should be the last release before the final 1.0.
Impressive!
Many thanks to the AMFPHP developer team!
The new improvements look awesome. I have been using the AMFPHP 0.9b for quite a while and all works promising.
The behaviour of NetConnection.Call.BadVersion, the nightmare of every AMFPHP user, was changed to [...]]]></description>
			<content:encoded><![CDATA[<p>A new milestone for <a href="http://www.5etdemi.com/blog/archives/2005/06/amfphp-10-milestone-1-released/">AMFPHP 1.0 is released</a> and it should be the last release before the final 1.0.<br />
Impressive!<br />
Many thanks to the <a href="http://amfphp.org">AMFPHP</a> developer team!<br />
The new improvements look awesome. I have been using the AMFPHP 0.9b for quite a while and all works promising.<br />
The behaviour of NetConnection.Call.BadVersion, the nightmare of every AMFPHP user, was changed to be more stable. Look at the <a href="http://www.5etdemi.com/blog/archives/2005/06/i-did-it-i-killed-netconnectioncallbadversion">Post of 51/2</a>.<br />
I hope I can test the new release in the coming week to see if my big app I am working on migrates flawless with the new release.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2005/06/amfphp-10-milesstone-released/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

