http://www.actionscript.org/forums/showthread.php3?p=755388#post755388
Wednesday, June 11, 2008
Controll a ViewStack from a ComboBox
Tuesday, May 6, 2008
Hello World (Flex, PHP, Weborb)
Your adobe mxml files for flexbuilder are being stored in ~/workspace/iSports/src/
Your php files containg the classes that will interface with flex are in /var/www/weborb/Services/
The file that helps link php and flex so that they can talk to each other is in /var/www/weborb/Weborb/WEB-INF/flex/remoting-config.xml
So we want an application that will display "Hello World!"
Let's start with the php:
Now we need to make this object a 'source' and give it a 'destination' in flex through weborb:
After appending the preceding lines we can move on to the flex development. Let's open Eclipse, select our iSports project and then open iSports/src/iSports.mxml
(~/workspace/iSports/src/iSports.mxml is the exact location)
When first attempting this I had an error because I had actually forgotten to append
to the compiler options in the project properties.
Then I got a "Send Failed" Error. But since my SampleFlexToPHPProject worked I just right-click copied and then pasted the entire project with a new name, cleared my browser cache, and copied my code into the new copied project, deleted the old one, and renamed the new one to the old one.
Your php files containg the classes that will interface with flex are in /var/www/weborb/Services/
The file that helps link php and flex so that they can talk to each other is in /var/www/weborb/Weborb/WEB-INF/flex/remoting-config.xml
So we want an application that will display "Hello World!"
Let's start with the php:
/var/www/weborb/Services/iSportsWelcome.php
<?php
class iSportsWelcome {
public function getMsg()
{
// Create an object
$msg = new WelcomeMsg();
// Set the value of the properties
$msg->msg = "Hello World!";
// This this the object that we want to pass to flex
return $msg;
}
}
class WelcomeMsg {
// Nothing to do here but define the propeties of our object
public $msg;
}
?>
Now we need to make this object a 'source' and give it a 'destination' in flex through weborb:
/var/www/weborb/Weborb/WEB-INF/flex/remoting-config.xml
<destination id="iSportsWelcomeDestination">
<properties>
<source>iSportsWelcome</source>
</properties>
</destination>
(~/workspace/iSports/src/iSports.mxml is the exact location)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="onCreationComplete()">
<mx:Script>
<![CDATA[
import mx.rpc.remoting.*;
import mx.controls.*;
import mx.rpc.events.*
private var php_iSportsWelocme:RemoteObject; // Our php class will be a 'remote' object
public function onCreationComplete():void
{
php_iSportsWelocme = new RemoteObject();
php_iSportsWelocme.destination = "iSportsWelcomeDestination"; // the link we set up through weborb
php_iSportsWelocme.getMsg.addEventListener("result", onResult); // listens to getMsg
php_iSportsWelocme.addEventListener("fault", onFault); // if there is any error in this class
getInfo();
}
public static function onFault(event:FaultEvent):void
{
Alert.show(event.fault.faultString, 'Error');
}
private function onResult(event:ResultEvent):void
{
var flex_msgObject:Object = event.result; // the php return object is passed to flex
var flex_msgText:String = flex_msgObject.msg; // the string is taken from the new object
lblMsg.text = flex_msgObject.msg;
}
private function getInfo():void
{
lblMsg.text = "Working... (or maybe not)...";
php_iSportsWelocme.getMsg();
}
]]>
</mx:Script>
<mx:Panel x="10" y="10" width="329" height="189" layout="absolute" title="Info Service Example">
<mx:Label x="10" y="10" id="lblMsg" text="Current user:"/>
</mx:Panel>
</mx:Application>
When first attempting this I had an error because I had actually forgotten to append
-services /var/www/weborb/Weborb/WEB-INF/flex/services-config.xml
to the compiler options in the project properties.
Then I got a "Send Failed" Error. But since my SampleFlexToPHPProject worked I just right-click copied and then pasted the entire project with a new name, cleared my browser cache, and copied my code into the new copied project, deleted the old one, and renamed the new one to the old one.
Creating a project
Now it's time to get to work!
In Eclipse on the right in Flex Navigator
Our project has been created in
Now
And edit /var/www/weborb/iSports-debug/weborb.php so to include '../' in the paths like this:
Now we're ready to roll.
Open Eclipse
File > New > Project
Flex Builder > Flex Project
Project name: iSports
Application server type: PHP
Next
Web root: /var/www/weborb
Root URL: http://localhost/weborb
Validate Configuration
Finish
In Eclipse on the right in Flex Navigator
right-click iSports > Properties
Select Flex Compiler
In 'Additional compiler arguments' append '-services /var/www/weborb/Weborb/WEB-INF/flex/services-config.xml' to the existing text.
OK
Our project has been created in
/var/www/weborb/iSports-debug/
Now
cp /var/www/weborb/weborb.php /var/www/weborb/iSports-debug/
And edit /var/www/weborb/iSports-debug/weborb.php so to include '../' in the paths like this:
require_once("../Weborb/ORBHttpHandler.php");
require_once("../Weborb/Util/Cache/Cache.php");
Now we're ready to roll.
Installing LAMP, Eclipse Europa, Flexbuilder 3, Weborb
Flex is a relatively new quasi open-source technology based on Adobe flash. It allows the developer to create a "website" in flash, trusting that the end user is one of the 94% of all users that has Flash 9 installed and avoiding all of the common hassles of browser incompatibility.
Aside from a standard LAMP server (MAMP and WAMP will work just as well), we'll get a few developer tools that will make life easy:
Eclipse is found @: http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/
Students get FlexBuilder 3 for Free @: http://www.flexregistration.com/
Weborb is available @: http://www.themidnightcoders.net/downloadcenter/
Assuming that we have an Ubuntu box we can
and although you may not want gallery2, it's an easy way to install a LAMP server with the common apache, php, and mysql packages that we'll need.
Ubuntu 8.04 doesn't come with Eclipse Europa in the repo, but that's okay, you can untar it into your home directory and it works just fine. But first you need to get java (I recommend sun's version)
Next we need to install WebORB. Download it and then untar into
If it worked you should find a pretty page at
Aside from a standard LAMP server (MAMP and WAMP will work just as well), we'll get a few developer tools that will make life easy:
Eclipse is found @: http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/
Students get FlexBuilder 3 for Free @: http://www.flexregistration.com/
Weborb is available @: http://www.themidnightcoders.net/downloadcenter/
Assuming that we have an Ubuntu box we can
sudo apt-get install gallery2
and although you may not want gallery2, it's an easy way to install a LAMP server with the common apache, php, and mysql packages that we'll need.
Ubuntu 8.04 doesn't come with Eclipse Europa in the repo, but that's okay, you can untar it into your home directory and it works just fine. But first you need to get java (I recommend sun's version)
sudo apt-get install sun-java6-jreIf you untar eclipse in your home directory you can open it for the first time with
sudo update-java-alternatives -s java-6-sun
~/eclipse/eclipseAssuming that it's working, close it out and procede with the flexbuilder installation with is pretty self explanitory. Open eclipse again and if flexbuilder installed correctly you should see:
Help > About Adobe Flex Builder Linux...However, the Linux version of flexbuilder doesn't have design view so it's pretty much useless and you'll probably want to design your interfaces on OS X instead.
Next we need to install WebORB. Download it and then untar into
/var/www/Double check to make sure that you follow this http://www.themidnightcoders.com/weborb/php/gettingStarted.shtm
If it worked you should find a pretty page at
http://localhost/weborb
Subscribe to:
Comments (Atom)