Saturday, November 14, 2009

Testing AMFPHP

1. Create a php class 'HelloWorld.php' with the following code



class HelloWorld
{
    function HelloWorld()
    {
        $this->methodTable = array
        (
            "say" => array
            (
                "access" => "remote",
                "description" => "Pings back a message"
            )
        );
    }

    function say($sMessage)
    {
        $message['message'] = mysql_escape_string( $sMessage );
        return $message;
    }
}
?>




2. Save 'HelloWorld.php' to 'services' folder within your 'amfphp' folder on your webserver ( e.g. '/www/amfphp/services/HelloWorld.php' )




3. Create an Adobe Flex web application with following code and run it




<?xml version="1.0" encoding="utf-8"?>

creationComplete="{this.init()}"
xmlns:mx="http://www.adobe.com/2006/mxml" 
layout="absolute">


import mx.controls.Alert;
private function init():void
{
var myService:NetConnection = new NetConnection ();
myService.connect("http://elimworks.com/amfphp/gateway.php");
var responder:Responder = new Responder( onDataReturned );
     myService.call("HelloWorld.say",  responder , "Hello World" );
}

private function onDataReturned( data:Object ):void
{
Alert.show( data.message , 'Message', Alert.OK );
}
]]>




You should get an Alert pop with the message "Hello World" once you've built and run the application.


Installation Instructions for AMFPHP


I recently attempted to install AMFPHP on my host site. After a few failed attempts, I succeeded. So I decided to document the entire process. If you have any questions, please feel free to email me.

Prerequisite:

  1. A host site ( e.g. 'http://yourhostsite.com' )
  2. You need a webserver with PHP4 ( > 4.3.0 ) or PHP5 installed on it.
  3. Access permission to the Web Root folder ( e.g. 'public_html/www' ).



Install AMFPHP on your webserver

  1. Download a fresh zip file of AMFPHP into a particular destination on your computer . ( e.g. 'C:\AMFPHP' )     Download
  2. Unzip the file within the destination ( e.g. 'C:\AMFPHP\amfphp-1.2.6')
  3. Copy the 'amfphp' folder located in 'C:\AMFPHP\amfphp-1.2.6' into the root folder of your webserver ( e.g. '/www' )
  4. Now we have /www/amfphp
  5. Open up a browser and navigate to http://yourhostsite.com/amfphp/gateway.php'
  6. If AMFPHP has been successfully installed on your web server, you will get a message 'amfphp and this gateway are installed correctly. You may now connect to this gateway from Flash.'.


    Monday, October 26, 2009

    Adobe Flex: Expanding Control Box / Hiding-Showing Control Panel

    Adobe Flex: Expanding Control Box / Hiding-Showing Control Panel



    Wednesday, October 14, 2009

    Using AlivePDF in an online Flex application

    Using AlivePDF in an online Flex application


    Tuesday, October 13, 2009

    Adobe Flex - Sorting an ArrayColleciton by Date

    Adobe Flex - Sorting an ArrayColleciton by Date

    /**
    * @params data:Array
    * @return dataCollection:Array
    **/
    private function orderByPeriod(data:Array):Array
    {
    var dataCollection:ArrayCollection = new ArrayCollection(data);//Convert Array to ArrayCollection to perform sort function


    var dataSortField:SortField = new SortField();
    dataSortField.name = "period"; //Assign the sort field to the field that holds the date string


    var numericDataSort:Sort = new Sort();
    numericDataSort.fields = [dataSortField];
    dataCollection.sort = numericDataSort;
    dataCollection.refresh();
    return dataCollection.toArray();
    }


    Bundled Deployment of Adobe AIR applications in Windows using NSIS (Nullsoft Scriptable Install System) - Single Step Method

    Bundled Deployment of Adobe AIR applications in Windows using NSIS (Nullsoft Scriptable Install System) - Single Step Method

    Using the script, we programmatically launch the bundled runtime installer that we created using Adobe AIR bundled runtime installer

    Single Step Method

    !define PRODUCT_NAME "SP 2009"
    !define PRODUCT_VERSION "2.1.0"
    !define PRODUCT_PUBLISHER "SP Group"
    Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
    Icon "C:\Inst\SP.ico"
    OutFile "SPInstaller.exe"
    Section -Prerequisites

    SetOutPath "C:\Inst"
    SetOverwrite ifnewer
    installProgram:
    MessageBox MB_YESNO "Install SP 2009?" /SD IDYES IDNO endInstall
    File "SP 2009 Installer.exe"
    ExecWait 'C:\Inst\SP 2009 Installer.exe'
    endInstall:
    SectionEnd

    Bundled Deployment of Adobe AIR applications in Windows - Using the Adobe AIR bundled runtime installer

    Bundled Deployment of Adobe AIR applications in Windows - Using the Adobe AIR bundled runtime installer

    ADOBE® AIR™ 1.5 Runtime Redistribution Instructions -http://help.adobe.com/en_US/AIR/1.5/air_runtime_redist/air_runtime_redist.pdf

    Adobe AIR Runtime Redistribution Instructions
    Once you have an Adobe® AIR™ Runtime Distribution License Agreement with Adobe® Systems Incorporated, you
    may redistribute the Adobe AIR installer and installer files.

    Obtaining permission to redistribute the runtime
    To obtain permission to redistribute Adobe AIR, read the Adobe AIR Runtime Distribution Agreement and apply for
    a license: http://www.adobe.com/products/air/runtime_distribution1.html
    Also, be sure to read the Adobe AIR FAQ page, which contains important information on the runtime distribution
    and license terms: http://www.adobe.com/products/air/runtime_distribution_faq.html
    Important: You may distribute Adobe AIR with your product only if you follow the Adobe AIR Runtime Distribution
    License Agreement application proces



    We start with the assumption that the Adobe AIR runtime has not been installed on the target machine that we intend on installing our Adobe AIR application.

    The AIR application we intend to install is called 'SP.air'


    We must therefore create a bundled installation package that must

    Install the Adobe AIR runtime on the target machine if not previously installed before proceeding to install the AIR application.
    Update the Adobe AIR runtime if the existing installation is an older version.
    Update the AIR application if the existing installation is an older version.
    Install the AIR application with a prerequisite that the Adobe AIR runtime is installed.


    This article shows us three different ways to go about creating a “windows based” bundled installation package for an AIR application.

    Using the Adobe AIR bundled runtime installer

    “”

    Step 1: Download the Adobe AIR bundled runtime installer from the download site.
    ( Mac: DMG file, Win: ZIP file)

    Step 2: Extract the contents of the file to a bundled runtime installer directory
    e.g. C:\Installer\

    Step 3: Rename the Adobe AIR installer to match the AIR application name.
    e.g. Adobe AIR Installer.exe is changed to “SPInstaller.exe”

    Step 4: Add the configuration file '.airinstall.cfg' to the bundled runtime installer directory.
    e.g. C:\Installer\.airinstall.cfg

    Step 5: Edit the airinstall.cfg to include the relative path to the AIR file to be installed
    e.g. if the AIR file is located in C:\Installer\AirApp\SP.air,
    we include the path “AirApp/SP.air” in the .airinstall.cfg file

    The contents of the bundled runtime installer directory can now be deployed on a CD, DVD, USB, or DMG. Double clicking the renamed installer file will launch the bundled runtime installer.


    We can only install one application at a time.