Pages

Sunday, May 13, 2012

AMFPHP and MYSQL connection in AS3



AMFPHP is actionscript massage format php. it's easy to communicate with php.

This is the step for connect the amfphp.

private var gateway:String = "http://localhost/amfphp/gateway.php";
private var connection:NetConnection;
private var responder:Responder;




connection = new NetConnection;
responder = new Responder(onresult, onfault);
connection.connect(gateway);
connection.call("myphp.firstFun", responder, params1, params2);

here myphp is amfphp class name and firstFun is function name.
params1 and params2 is function params.

/** successful output responder **/

private function onresult(out:Object):void
{
trace("success output "+out);
}

/** error output responder **/
private function onfault(out:Object):void
{
trace("error output "+out);
}


...CHeeRS...


amfphp and mysql connection example source code is here


Develop the Android Mobile Application in as3 From FlashDevelop 4.0.1


FlashDevelop is a free and open source code editor for every Flash developer

FlashDevelop offers first class support for ActionScript (2 & 3) and HaXe development. Great completion & code generation, projects compilation & debugging, plenty of project templates, SWF/SWC exploration etc. FlashDevelop is also a great web developer IDE with source-control support (svn, git, mercurial), tasks/todo, snippets, XML/HTML completion and zen-coding for HTML.

This is the link for download FlashDevelop4.0.1 http://www.flashdevelop.org/community/viewtopic.php?p=43027

now How to Create the project in FlashDevelop4.0.1 for android mobile application:-

step1:
    
Select the New Project in tool menu Project panel.
Choose your Project type. example we are create now android mobile application so select AIR Mobile AS3 App. then type your project name and choose your project file path.


here i gave androidApp for project name.
then push the OK button your project will be create.

step 2:

In your left side have a project details menu.


Create your android certificate from CreateCertificate.bat in bat folder

Right Click the CreateCertificate.bat file and Execute that file.


 you show this popup and Press any key to continue after your certificate is ready.

you check the certificate in cert folder.


step 3:

your source main file is Main.as in src folder.


package 

{

import flash.desktop.NativeApplication;

import flash.events.Event;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.text.TextFieldAutoSize;
/**
* ...
* @author KUMARESH NRV
*/
public class Main extends Sprite 
{
private var tex:TextField = new TextField();
private var texFor:TextFormat = new TextFormat();
public function Main():void 
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.DEACTIVATE, deactivate);
// touch or gesture?
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
// entry point
texFor.size = 40;
texFor.color = 0x643654
tex.defaultTextFormat = texFor;
tex.autoSize = TextFieldAutoSize.CENTER;
tex.text = "hello android";
tex.x = (stage.stageWidth / 2)-tex.width/2;
tex.y = stage.stageHeight / 2;
addChild(tex);
}
private function deactivate(e:Event):void 
{
// auto-close
NativeApplication.nativeApplication.exit();
}
}
}

Step 4:

How to create the .apk file from this one.

Execute the PackageApp.bat file form in your Right side Project Details panel


 then you show this popup. and type your Choice Number  for output file type.
here we want android apk file so we give 1  and ENTER for to continue.


Now your .apk file is create in dist folder.

Enjoy Guys... Create your Application in your Favourite android mobile.



...CHeeRS...


Saturday, May 12, 2012

Join Room in SmartFoxServer 2X



sfs.send( new JoinRoomRequest("The Lobby") );


The server will in turn respond with one of the following events:
  • SFSEvent.ROOM_JOIN, if the operation is successful
  • SFSEvent.ROOM_JOIN_ERROR, if an error occurred
As usual we will need to register the events in our main SmartFox class instance to be
notified of the result of the join operation. This is the full ActionScript 3 code
required to handle both cases (very similar for other languages).
This code is usually executed during the application initialization:

var sfs:SmartFox = new SmartFox();
sfs.addEventListener(SFSEvent.ROOM_JOIN, onJoin);
sfs.addEventListener(SFSEvent.ROOM_JOIN_ERROR, onJoinError);


This code is executed after a successful login:


sfs.send( new JoinRoomRequest("The Lobby") );


And these are the event listeners:



public function onJoin(evt:SFSEvent):void
{
    trace("Joined Room: " + evt.params.room.name);
}
public function onJoinError(evt:SFSEvent):void
{
    trace("Join failed: " + evt.params.errorMessage);
}