Escolar Documentos
Profissional Documentos
Cultura Documentos
nesianflexcom
mmunity.org
Flexx Training
Build a Simple Contact Managger using Zen
ndAMF
Firsst you need a Database pre
eparation
Databasse name : contacts
Table : u
user
USE contacts;
CREATE TABLE user (
id int(4
4) NOT NULL aauto_incremeent,
username varchar(1
12) NOT NULLL,
passwo
ord varchar(20) NOT NULL,,
PRIMARY KEY (id)
) ENGINE=MyISAM;
Table : ccontact
USE contacts;
CREATE TABLE `contaact` (
`name`` text,
`email` text,
`phonee` text
) ENGINE=MyISAM;
he Zend Framework on you
h installing th
Setup starts with ur PHP installation, Copy ““Zend” folder to your docu
ument root.
In the “htdocs” ffolder, create
e 3 php files : Index.php, Lo
ogin.php, and
d Contacts.ph
hp.
Index.php
<?p
php
incllude "Zend/A
Amf/Server.ph
hp";
incllude "Contactts.php";
incllude "Login.php";
myssql_connect( 'localhost', 'rroot', '' ); //yoou need to upddate the connection informattion for your sppecific databasse setup
http://indonesianflexcommunity.org
mysql_select_db( 'contacts' );
$server = new Zend_Amf_Server();
$server‐>setClass( "Contacts" );
$server‐>setClass( "Login" );
echo( $server‐>handle() );
?>
Login.php
<?php
class Login
{
public function Login() { }
public function cekLogin($username, $password)
{
$res = mysql_fetch_array(mysql_query("SELECT * FROM contacts.user WHERE username='$username' AND
password='$password' "));
if($res)
{
$login = 1;
}
else
{
$login = 0;
}
return $login;
}
}
?>
Contacts.php
http://indonesianflexcommunity.org
<?php
class Contacts
{
public function Contacts() { }
public function add( $name, $email, $phone )
{
$insert = sprintf( "INSERT INTO contact VALUES ( '%s', '%s', '%s')",
mysql_real_escape_string( $name ),
mysql_real_escape_string( $email ),
mysql_real_escape_string( $phone ) );
mysql_query($insert);
}
public function getContacts()
{
$contacts = array();
$res = mysql_query( 'SELECT * FROM contact' );
while( $contact = mysql_fetch_assoc($res) )
{
$contacts []= $contact;
}
return $contacts;
}
}
?>
you need to add a new file to the project called services‐config.xml
services‐config.xml
<?xml version="1.0" encoding="UTF‐8"?>
<services‐config>
<services>
http://indonesianflexcommunity.org
<service id="zend‐service" class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.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.channels.AMFChannel">
<endpoint uri="http://localhost/" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel‐definition>
</channels>
</services‐config>
With that file in the project, you now need to get its absolute location on disk. You can do that by right‐clicking the
services‐config.xml file name, then clicking Properties. The absolute path is shown as Location, as you can see in Figure 1
http://indonesianflexcommunity.org
Paste that absolute file path, then open the project properties. Click the Flex Compiler tab. From there, add services and
the file path to the additional compiler arguments. You can see that in Figure 2.
Example : ‐services "C:\Users\ifx\Documents\Flex Builder 3\ContactManager\src\services‐config.xml"
Now, create a Login panel
Login.mxml
http://indonesianflexcommunity.org
else
{
Alert.show('Gagal');
}
}
]]>
</mx:Script>
<mx:RemoteObject id="remoteLogin" destination="zend" source="Login">
<mx:method name="cekLogin" result="hasilLogin( event )"/>
</mx:RemoteObject>
</mx:TitleWindow>
Final part is main Application
Don’t forget to paste “flexlib.swc” to the libs folder on Adobe Flex builder 3.
http://indon
nesianflexcom
mmunity.org
Fun
n with Image
<?x
xml version="1.0" en
ncoding="utf-8"?>
<mx :mx="http://www.adob
x:Application xmlns: be.com/2006/mxml" la
ayout="abso
olute" >
<mx:Im
mage id="ga
ambar" x="169" y="99 gambar.png')">
9" source="@Embed('g
<mx:filter
rs>
<mx:
:DropShadowFilter di
istance="10"/>
<mx:
:BevelFilter/>
</mx:filte
ers>
<mx:showEf
ffect>
:Fade alphaFrom="0" alphaTo="1" duratio
<mx: on="1000"/>
>
</mx:showE
Effect>
<mx:hideEf
ffect>
:Fade alphaFrom="1" alphaTo="0" duratio
<mx: on="1000"/>
>
</mx:hideE
Effect>
</mx:Image>
<mx:HSlider x="2
248" y="50" maximum=
="250"
cha
ange="gambar.height=
=event.currentTarget
t.value" liveDraggin
ng="true"/>
>
<mx:HSlider x="1
10" y="44" minimum="
"0" maximum
m="360"
cha
ange="gambar.rotatio get.value" liveDragg
on=event.currentTarg ging="true" width="2
212"/>
<mx:CheckBox x="
"434" y="44" label="
"Visible"
cha
ange="gambar.visible
e=event.currentTarge
et.selected" selecte
ed="true"/>
>
<mx:Label x="248
8" y="18" text="Ukur
ran"/>
<mx:Label x="10"
" y="18" text="Rotas
si"/>
</m
mx:Application>
Thaank You !