P. 1
Flex Training

Flex Training

|Views: 21|Likes:
Published by Tata Kartadibrata

More info:

Published by: Tata Kartadibrata on Oct 20, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





http://indon nesianflexcom mmunity.

org x Training  Flex Build a Simple Contact Manag ger using Zen ndAMF    st you need a Database pre eparation  Firs  Databas se name : contacts   Table : u user    USE contacts;  CREATE TABLE user (    id int(4 4) NOT NULL a auto_increme ent,    username varchar(1 12) NOT NULL L,    passwo ord varchar(20) NOT NULL, ,    PRIMARY KEY  (id)  ) ENGINE=MyISAM;    Table : c contact  USE contacts;  CREATE TABLE `conta act` (    `name` ` text,    `email` text,    `phone e` text  ) ENGINE=MyISAM;    h installing th he Zend Framework on you ur PHP installation, Copy “ “Zend” folder to your docu ument root.  Setup starts with folder, create e 3 php files : Index.php, Lo ogin.php, and d Contacts.ph hp.  In the “htdocs” f   Index.php  <?p php   incl lude "Zend/A Amf/Server.ph hp";  incl lude "Contact ts.php";   incl lude "Login.php";  mys sql_connect( 'localhost', 'r root', '' ); //yo ou need to upd date the connection informat tion for your sp pecific databas se setup   

  $login = 1.  .  $server‐>setClass( "Login" ).  ?>     Login.  $login = 0.php   <?php  class Login  {        public function Login() { }    public function cekLogin($username.http://indonesianflexcommunity. $password)  {          $res = mysql_fetch_array(mysql_query("SELECT * FROM contacts.  $server‐>setClass( "Contacts" ).org  mysql_select_db( 'contacts' ).          if($res)                    }  ?>    Contacts.php                    }  {    }  else  {    }  return $login.user WHERE username='$username' AND  password='$password' ")).  $server = new Zend_Amf_Server().  echo( $server‐>handle() ).

 '%s'.                      $res = mysql_query( 'SELECT * FROM contact' ).       public function getContacts()      {     $contacts = array().  mysql_real_escape_string( $email ). $phone )  {                   }  $insert = sprintf( "INSERT INTO contact VALUES ( '%s'.xml  <?xml version="1.  while( $contact = mysql_fetch_assoc($res) )    {    }  return $contacts.xml  services‐config.0" encoding="UTF‐8"?>  <services‐config>      <services>    .                                  ?>          }  you need to add a new file to the project called services‐config.http://indonesianflexcommunity.  mysql_query($insert).  mysql_real_escape_string( $phone ) ). $email. '%s')".  }  $contacts []= $contact.  mysql_real_escape_string( $name ).org  <?php  class Contacts  {   public function Contacts() { }                                                          public function add( $name.

AMFChannel">              <endpoint uri="http://localhost/" class="flex.RemotingService"  messageTypes="flex. You can do that by right‐clicking the  services‐config.xml file name.messaging.messages. as you can see in Figure 1      .http://indonesianflexcommunity.messaging.AMFEndpoint"/>          </channel‐definition>      </channels>  </services‐config>     With that file in the project.org          <service id="zend‐service" class="flex. The absolute path is shown as Location. you now need to get its absolute location on disk.channels.RemotingMessage">              <destination id="zend">                  <channels>                      <channel ref="zend‐endpoint"/>                  </channels>                  <properties>                      <source>*</source>                  </properties>              </destination>          </service>      </services>      <channels>          <channel‐definition id="zend‐endpoint" class="mx.messaging. then clicking Properties.messaging.endpoints.services.

result == 1) { Alert.google.org  Paste that absolute file path. then open the project properties. Click the Flex Compiler tab.text ).    Example : ‐services "C:\Users\ifx\Documents\Flex Builder 3\ContactManager\src\services‐config. txtpassword. } private function hasilLogin(event:ResultEvent): void { if(event. create a Login panel    Login.ResultEvent. } private function cekLogin( event:Event ) : void { remoteLogin. closeMe().com/2006/mxml" layout="absolute" width="242" height="148" title="Login" label="Login" horizontalCenter="0" verticalCenter="0" minHeight="200" minWidth="300" alpha="0. import mx.show('berhasil').cekLogin( txtusername.PopUpManager.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.Alert. You can see that in Figure 2.rpc.mxml  <?xml version="1.text.8" xmlns:flexlib="http://code.managers.removePopUp(this). private function closeMe():void { PopUpManager. From there.events.adobe.xml"    Now.http://indonesianflexcommunity. }   . import mx.com/p/flexlib/" > <mx:Script> <![CDATA[ import mx. add services and  the file path to the additional compiler arguments.controls.

adobe.text. }   .createPopUp(this.getContacts().text = ''." xmlns:mx="http://www. PopUpManager.add( txtName. [Bindable] public var popLogin:Login. import mx. Login.play().0" encoding="utf-8"?> <mx:Application pageTitle="Contacts" layout="absolute" creationComplete="onStartup().rpc.ResultEvent. } ]]> </mx:Script> <mx:RemoteObject id="remoteLogin" destination="zend" source="Login"> <mx:method name="cekLogin" result="hasilLogin( event )"/> </mx:RemoteObject> <flexlib:PromptingTextInput x="10" y="10" width="202" prompt="Username" id="txtusername"/> <flexlib:PromptingTextInput x="10" y="40" width="202" prompt="Password" id="txtpassword"/> <mx:ControlBar horizontalAlign="center" > <mx:Button label="Login" click="cekLogin(event)"/> <mx:Spacer width="72" height="2"/> <mx:Button label="Cancel"/> </mx:ControlBar> </mx:TitleWindow>  Final part is main Application  <?xml version="1.PopUpManager.show('Gagal').com/p/flexlib/"> <mx:Script> <![CDATA[ import mx. txtName. txtPhone.org  else { } Alert.events.centerPopUp(popLogin). } private function doAdd( event:Event ) : void { svcContacts.skins.getContacts(). private function showLogin():void { popLogin = Login(PopUpManager.text ). txtEmail. } private function doAddResult( event:ResultEvent ) : void { svcContacts.google. import mx.com/2006/mxml" xmlns:flexlib="http://code. } private function onStartup() : void { svcContacts.text = ''.managers.true)).text.halo. rtt. txtPhone. txtEmail.PopUpIcon.text = ''.http://indonesianflexcommunity.showLogin().

swc” to the libs folder on Adobe Flex builder 3.result.org  private function doContactsResult( event:ResultEvent ) : void { dg.              .http://indonesianflexcommunity.dataProvider = event. } ]]> </mx:Script> <mx:Rotate target="{popLogin}" id="rtt"/> <mx:RemoteObject id="svcContacts" destination="zend" source="Contacts"> <mx:method name="getContacts" result="doContactsResult( event )" /> <mx:method name="add" result="doAddResult( event )" /> </mx:RemoteObject> <mx:Panel width="500" height="400" layout="vertical" title="Contacts" paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5" horizontalAlign="center" horizontalCenter="0" verticalCenter="0"> <mx:DataGrid id="dg" width="100%" height="100%"> <mx:columns> <mx:DataGridColumn headerText="Name" dataField="name" /> <mx:DataGridColumn headerText="Email" dataField="email" /> <mx:DataGridColumn headerText="Phone" dataField="phone" /> </mx:columns> </mx:DataGrid> <flexlib:PromptingTextInput id="txtName" prompt="Name" width="250"/> <flexlib:PromptingTextInput id="txtEmail" prompt="Email" width="250"/> <flexlib:PromptingTextInput id="txtPhone" prompt="Phone" width="250"/> <mx:Button label="Add" click="doAdd( event )" /> </mx:Panel> </mx:Application>  Don’t forget to paste “flexlib.

http://indon nesianflexcom mmunity.value" liveDraggin ng="true"/> > <mx:HSlider x="1 10" y="44" minimum=" "0" maximum m="360" cha ange="gambar.currentTarget t.height= =event.adob be.0" en ncoding="utf-8"?> <mx x:Application xmlns: :mx="http://www.currentTarg get.png')"> <mx:filter rs> <mx: :DropShadowFilter di istance="10"/> <mx: :BevelFilter/> </mx:filte ers> <mx:showEf ffect> <mx: :Fade alphaFrom="0" alphaTo="1" duratio on="1000"/> > </mx:showE Effect> <mx:hideEf ffect> <mx: :Fade alphaFrom="1" alphaTo="0" duratio on="1000"/> > </mx:hideE Effect> </mx:Image> <mx:HSlider x="2 248" y="50" maximum= ="250" cha ange="gambar.selected" selecte ed="true"/> > <mx:Label x="248 y="18" text="Ukur 8" ran"/> <mx:Label x="10" y="18" text="Rotas " si"/> </m mx:Application>     Tha ank You !    .com/2006/mxml" la ayout="abso olute" > <mx:Im mage id="ga ambar" x="169" y="99 source="@Embed('g 9" gambar.value" liveDragg ging="true" width="2 212"/> <mx:CheckBox x=" "434" y="44" label=" "Visible" cha ange="gambar.currentTarge et.org Fun n with Image                  <?x xml version="1.rotatio on=event.visible e=event.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->