FLEX / PHP Interaction

Right now I have a tilelist with some stuff and I wanted to
know if it is possible to make it when a key is pressed it connects
to a php file updates something on the mysql db and then reloads
the tilelist with the newly updated information?

I have plenty of Flex/PHP examples using Remoting and AMFPHP,
SabreAMF or WebORB for PHP on my blog at
http://renaun.com/blog.
You can also use Flex's HTTPService or WebService components
to communicate to PHP.

Similar Messages

  • Flex Javascript interaction

    In my application, the Flex Javascript interaction works
    correctly only when I have a "alert" pop-up!!! I do not want the
    "alert" in my final application.
    Here is my code snippet:
    Javascript code:
    <script language = "JavaScript" type="text/JavaScript"
    charset="ISO_8859-1">
    var jsReady = false;
    function isReady()
    return jsReady; //to set up communication with Flex
    function pageInit()
    // Record that JavaScript is ready to go.
    jsReady = true;
    var newTerm="Flex"; //This is the input variable, right now
    its hard-coded
    alert(newTerm);//this alert causes trhe problem, I get to see
    the desired output with alert, but without alert, I get "Error on
    Page"
    getMyApp("test").myFlexFunction(newTerm);//call to Flex
    function
    function getMyApp(appName) //Function to find the type of our
    browser
    if (navigator.appName.indexOf ("Microsoft") !=-1)
    return window[appName];
    } else {
    return document[appName];
    </script>
    pageInit() is called onLoad in body tag==> possible cause
    of problem

    Hey Tracy! Thanks for replying!
    Here is the ExternalInterface code. I am working on Yahoo
    API. So you will find some API calls there.
    =========================
    [Bindable]
    public var question:Question;
    public function myFunc(s:String):void
    var keyword:String;
    params.results = 50;
    params.type = "resolved";
    searchService.searchQuestionsByTerm(s, params);
    private function setupCallbacks():void
    ExternalInterface.addCallback("myFlexFunction",myFunc);
    private function isContainerReady():Boolean
    var result:Boolean = ExternalInterface.call("isReady");
    return result;
    public function startUp():void //initial call made hwn the
    application starts
    var isAvailable:Boolean = ExternalInterface.available;
    trace(isAvailable.toString());
    if (ExternalInterface.available)
    var containerReady:Boolean = isContainerReady();
    if (containerReady)
    // If the container is ready, register the SWF's functions.
    setupCallbacks();
    else
    trace("External interface is not available for this
    container.");
    // Define the Event Listeners for the Answer Service
    searchService.addEventListener(AnswersResultEvent.QUESTIONS_SEARCH,
    questionsResult, false, 0, true);
    searchService.addEventListener(AnswersErrorEvent.ERROR_EVENT,
    showError, false, 0, true);
    =======================

  • Help!How can Flex+PHP+MSSQL(Microsoft) work together?

    I have already learned how to make Flex + PHP + MySQL work together.Simply by Zend AMF.
    But my company wants to use MSSQL(Microsoft) as the database.
    I also use the Zend AMF.
    But it returns the Fatal error: Uncaught exception 'Zend_Amf_Server_Exception' with message 'Handle error: Unable to writeObject output: Can not serialize resource type: mssql result 499' in C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php:631Stack trace:#0 C:\wamp\www\BQSB-debug\gateway.php(69): Zend_Amf_Server->handle()#1 {main} thrown in C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php on line 631
    How can I handle the error?
    Can Flex+PHP+MSSQL(Microsoft) work together by Zend AMF?
    Or there are other ways to make Flex+PHP+MSSQL(Microsoft) work together.
    Please help me, I am waiting online,thx.

    I am currently using Flex 4+Php+Zend with a MSSQL backend.
    I use the microsoft sql php driver to interface from PHP to MSSQL.  http://www.microsoft.com/sqlserver/2005/en/us/php-driver.aspx
    Hope that helps

  • Help with Flex - PHP - and SQL Server

    Good afternoon,
    I have been working on this problem for over a week and am at
    my wit's end. I am trying to create an application that will allow
    me and my fellow statisticians to share code easily. The
    technologies at my disposal are Flex, PHP and SQL Server 2005. The
    web server is IIS. I have downloaded and installed the PHP driver
    for SQL Server 2005 and am able to query the database and generate
    XML. The problem I'm having is that I can't return the XML from PHP
    to Flex.
    If I execute the php code in a web browser and view the
    source, it looks like XML. I can then cut and paste the exact same
    code into an xml file and read it in from the harddisk and the tree
    will populate. Can anyone please help me? I don't have flex builder
    so I it's hard for me to use trace and view what is going on.
    Thanks in advance,
    Eric Graves

    Thanks for the suggestion. I have tried every permutation of
    e4x path notation I can think of. You're right, you're not supposed
    to need the root level as that's supposed to be returned in the
    result. So you should only need to reference first level after the
    root. When I do this and launch the .SWF I get a completely empty
    tree.
    I think the problem lies somewhere in my understanding of
    what format Flex needs returned from a HTTPRequest. It's my
    understanding that it just needs to be XML. As far as I can tell,
    that's what I'm sending it. On the PHP side, does it have to be
    cast a special way? Everything I've seen just shows people using
    ECHO to output the XML data.

  • Flex-PHP application using LCCS

    I need to create an LCCS video/audio/text chat application which will be deployed on a website with PHP as back-end. Only 2 people can comunicate with each other. There are a few questions I have related to this:
    Do I need to create different rooms for each user chat as 2 users can chat at a time?
    Do I need to create these rooms on the fly using the PHP classes in LCCS SDK to enable dynamic room creations?
    How do I interact with Flex and these Rooms? Do I need to create some PHP services which after creating a room, send the data to Flex, which Flex uses to initiate the chat application?
    Any help would be appreciated and it would be good if someone can share URL to similar tutorial or example.

    Thanks to all those links and comments were really very helpful. Regarding the Wiki link, point 6.c and 6.d mentions that
    For each user and from your own system, get an user ID, a username, and an assigned role.
    Generate an authToken by passing the required parameters to getAuthenticationToken. The token is a unique, signed string created from the your shared secret, the user's ID and username, and their assigned role.
    Here we need to generate user ID and username on server side? Also how do I define roles using server side scripting?

  • Flex PHP Wizard Issues (Is Flex/PHP ready for prime time)

    I have been designing a website using Flex. I thought of using Flex form many reasons, but one was to reduce the number of languages used in the development process. I am going to be hosting at Godaddy so I thought  I would try PHP. I normally would use Java, but Flex seems to want Enterprise Beans and Java Remote Objects which cost to much and would probably not work on Godaddy. I started out with MAMP on a Apple computer and have design 60% of my application, when I started noticing as the database go larger, I started getting communication errors with the MAMP version of mysql. So I installed MySQL and and started using Apache and PHP that comes with OSX. The communication errors are increased.
    Any suggestions? I am at the point, if I can find a proven programmer, with GoDaddy/Flex/MySQL/PHP and Java experience to help answer some question, I think I can come up with contract dollars.
    First question is Flex ready? or is this an issue with PHP?

    have moved this thread from the ADDT forums to the Flex Data Services forums

  • Flex/PHP deployment problem

    Hello there,
    After a lot of researches and copy/paste on Google, I finally decide to create a topic here, that means I am totally desperate.
    I have a dev environment on a Windows platform with Apache/PHP/MySQL and Flash Builder 4. I am using the Zend Framework in order to communicate  with PHP classes in Action Script. Locally, all work perfectly, PHP works and content is correctly updated in my Flex apps.
    But I have a problem in the production environment. I have Lighttpd with PHP (FastCGI) and ZendFramework correctly installed on a Linux environment.
    I just export my Flex app to a release build, I modify the amf_config.ini. And I am sure my configuration is correct.
    When ZendFramework is not found, I have the error : Send failed Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://www.xxxx.xx/gateway.php'. It is not my problem, ZendFramework is correctly installed for me (it is just to tell you that I dont have this error).
    But my actual problem is, even if ZendFramework is correctly working and all seems to be good, I have the error (that I do not success to fix) :
    Class "xxxxxx" does not exist: Plugin by name 'xxxxxx' was not found in the registry; used paths: : /xxxxxx/www/services/
    The path is correct, my services are in the "services" folder, but Zend does not find the classes.
    I have to do some other actions in order to deploy my apps? I do not understand why its working in local (Win) and not in production (Linux). I test on a local environment on Linux, I have the same error. Maybe I have to modify something in the configuration of the project (like urls or classes calls...), I do not know...
    Can you help me?
    Thanks a lot.
    Regards.
    Sam

    Any ideas, this has been a pain in my side all weekend... been moving files and reinstalling things right left and centre!!
    is it a Zend issue or Flash?
    This needs to be resolved as its a key function in their demo!!!

  • Issues with Error #2048 on deployed Flex/PHP Web Application

    Hello,
    I'm testing out Flash Builder for PHP and I'm running into the following error when deploying to a web servers:
    Send failed
    Channel.Security.Error error Error #2048 url: 'http://testsite.dreamhosters.com/LocatorPHP/public/gateway.php'
    I have looked though documentation and tutorials without any luck.  My application works great on the local Zend Server setup but as soon as I jump to a remote web server I get problems.
    Here's what I've tried:
    1) crossdomain.xml in web root
    2) amf_config.ini updated so zend framework on server and gateway.php are reachable (connecting to gateway.php directly gives me no errors)
    3) attemped to change the flex server option in my project but Flash Builder for PHP will not allow me to change this, so I had to change my php service.as endpoint entry to the gateway.php on the webserver
    Is there a log that can help me troubleshoot the error?
    Thanks in advance.

    Any solution I have just ran into the same issue. App works perfect on localhost phpmyadmin as soon I change everything to our public server ERROR#2048
    I have tried same as above no results.
    After countless hours of searching this worked for me!!!!
    http://forums.adobe.com/thread/674871

  • Best way to retrieve/store date Flex PHP MySQL?

    Hi All,
    I have a question about storing/retrieving a date-field from the MySQL database, using Flash Builder 2 & Zend AMF.
    This is as much as I know:
    MySQL Database stores date in this format: yyyy-mm-dd hh:mm:ss
    And Flex will not recognise that as a "date", instead it will suggest this value is an "object".
    With "Configure return type", I can manually set this field to "date", but it will not work retrieving of updating the date as MySQL will not understand the standard date-format it'll receive,
    I guess, the best solution would be if I could tell the MySQL Server how the standard date-format should be, but I have not found this option. Can anyone confirm this?
    The remaining options are:
    Format the date in the SQL-query
    Format the date in the PHP-function sending/retrieving
    Format the date in Flex, befor assigning it to a date-field...
    Can someone tell me the BEST practice to handle date-objects? I guess it's the date_format function in MySQL....
    I'm trying to build an app with over 3200 fields, shared over 60 tables, of which many are date-fields.
    Would be awesome if I could just use SELECT * FROM myTable, and all would be fine with date-fields and all...
    Any tips?

    I'm confused. This is what I have:
    On my MySQL database, I've created a VIEW with the query that I need. I thought it'd generally be efficient to create views for every 'Form' that I need.
    This is my VIEW v_person
    SELECT p.`person_id`, p.`name`, p.`lastname`, DATE_FORMAT(p.`birthdate`,'%d/%m/%Y %r') as birthdate
    FROM person p
    Now I have a simple table v_person returning
    person_id
    name
    lastname
    birthdate
    0
    John
    Doe
    null
    1
    Jane
    Did
    23/08/1976 12:00:00 AM
    2
    Juno
    Doh
    01/04/2001 12:00:00 AM
    "Great! Now I can set up my query once, returning the date in whatever format Flex likes."
    Not.
    This is the standard generated PHP function to get information by ID. This works fine.
         public function getV_personByID($itemID) {
              $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where person_id=?");
              $this->throwExceptionOnError();
              mysqli_bind_param($stmt, 'i', $itemID);          
              $this->throwExceptionOnError();
              mysqli_stmt_execute($stmt);
              $this->throwExceptionOnError();
              mysqli_stmt_bind_result($stmt, $row->person_id, $row->name, $row->lastname, $row->birthdate);
              if(mysqli_stmt_fetch($stmt)) {
                   return $row;
              } else {
                   return null;
    This is the standard generated Form in Flex:
    One note to make when using RETURN TYPE,
    is that in when I use person_id=0 , I can change "birthdate type" from OBJECT to DATE, because date is null.
    When I use person_id=1 , I CAN'T change "birthdate type" as it defaults to "STRING".
    Since I want to use a dateField in my Form, I changed birthdate type to "DATE". (Even though I now understand that return type IS in fact a string)
    <fx:Script>
         <![CDATA[
              import mx.controls.Alert;
              import mx.formatters.DateFormatter;
                   protected function button_clickHandler(event:MouseEvent):void
                   getV_persontestByIDResult.token = vpersontestService.getV_persontestByID(parseInt(itemIDTextInput.text));
         ]]>
    </fx:Script>
    <fx:Declarations>
              <vpersontestservice:VpersontestService id="vpersontestService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
         <s:CallResponder id="getV_persontestByIDResult" result="v_persontest = getV_persontestByIDResult.lastResult as V_persontest"/>
         <valueObjects:V_persontest id="v_persontest" person_id="{parseInt(person_idTextInput.text)}" />
         <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <mx:Form defaultButton="{button}">
         <mx:FormItem label="ItemID">
              <s:TextInput id="itemIDTextInput"/>
         </mx:FormItem>
         <s:Button label="GetV_persontestByID" id="button" click="button_clickHandler(event)"/>
    </mx:Form>
    <mx:Form>
         <mx:FormHeading label="V_persontest"/>
         <mx:FormItem label="Birtdate">
              <mx:DateField id="birthdateDateField" selectedDate="@{v_persontest.birthdate}" />
         </mx:FormItem>
         <mx:FormItem label="Last name">
              <s:TextInput id="lastnameTextInput" text="@{v_persontest.lastname}"/>
         </mx:FormItem>
         <mx:FormItem label="First name">
              <s:TextInput id="nameTextInput" text="@{v_persontest.name}"/>
         </mx:FormItem>
         <mx:FormItem label="person_id">
              <s:TextInput id="person_idTextInput" text="{v_persontest.person_id}"/>
         </mx:FormItem>
    </mx:Form>
    Works great! Except that it can't handle the date field:
    TypeError: Error #1034: Type Coercion failed: cannot convert "10/21/1984 12:00:00 AM" to Date.
         at com.adobe.serializers.utility::TypeUtility$/assignProperty()[C:\perforceGAURAVP01\depot\flex\ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\TypeUtility.as:534]
         at com.adobe.serializers.utility::TypeUtility$/convertToStrongType()[C:\perforceGAURAVP01\depot\flex\ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\TypeUtility.as:497]
         at com.adobe.serializers.utility::TypeUtility$/convertResultHandler()[C:\perforceGAURAVP01\depot\flex\ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\TypeUtility.as:371]
         at mx.rpc.remoting::Operation/http://www.adobe.com/2006/flex/mx/internal::processResult()[E:\dev\trunk\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:316]
         at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\trunk\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:313]
         at mx.rpc::Responder/result()[E:\dev\trunk\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
         at mx.rpc::AsyncRequest/acknowledge()[E:\dev\trunk\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
         at NetConnectionMessageResponder/resultHandler()[E:\dev\trunk\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:547]
         at mx.messaging::MessageResponder/result()[E:\dev\trunk\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:235]
    Somehow SOMETHING wants to convert "10/21/1984 12:00:00 AM" to Date.
    Where does it fail? I feel like I'm SO close, but making a faceplant right before the finish.
    ok.
    I'm by no means an expert, so let me know if I'm doing something wrong, but this is how I'd expect it to work.
    Can someone tell me how I should use a dateField instead? Where should I make the stringToDate and dateToString conversion?

  • Adobe flex vs Interactive adobe forms

    Hi, I have used SAP Interactive adobe forms extensively. We used to use Web dynpro java or web dynpro abap to develop adobe related applications. In the meanwhile I would like to understand how adobe flex forms are different when compared to interactive adobe forms. Also I would like understand if the development environment remains the same if we use adobe flex instead of interactive adobe forms. And are there any special licensing requirements?
    thanks
    anantharam

    I would recommend Googling about this ;)

  • Adobe Flex + PHP (Using Data Transfer Object pattern in amf)

    hello
    i'am using amf to connect my flex application to the php back end,but i want to use DTO(DataTransferObject), i haven't enough info about this pattern.
    can you introduce me a reference or have you any suggestion?
    thanks for your attention
    Uniqe_max (amin shahnazary)

    here is another way of doing it
    http://www.youtube.com/watch?v=1n1uHQAP18Q
    http://www.youtube.com/watch?v=fQsCBk9tvkQ

  • Flex/PHP problem lastResult does not work correctly

    hi flex community,
    I am trying to develope a small login but I am still new to flex. It's based a little bit on the tutorial "Flex Test Drive: Build an application in an hour". I have a mysql database where the username and the password are stored in.
    My Flex file looks like this:
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                xmlns:s="library://ns.adobe.com/flex/spark"
                                xmlns:mx="library://ns.adobe.com/flex/mx"
                                xmlns:loginservice="services.loginservice.*"
                                currentState="Login"
                                width.Login="719" height.Login="606"
                                width.Main="975" height.Main="700" xmlns:valueObjects="valueObjects.*">
         <fx:Script>
              <![CDATA[
                   import mx.controls.Alert;
                   import mx.events.FlexEvent;
                   protected function buttonLogin_clickHandler(event:MouseEvent):void
                        loginResult.token = loginService.login(username.text, password.text);
                        trace(vOLogin.username);
                        trace(vOLogin.password);
                        trace(vOLogin.valid)
                        /*if (vOLogin.valid == true) {
                             currentState = "Main";
              ]]>
         </fx:Script>
         <s:states>
              <s:State name="Login"/>
              <s:State name="Main"/>
         </s:states>
         <fx:Declarations>
              <valueObjects:VOLogin id="vOLogin" />
              <s:CallResponder id="loginResult" result="vOLogin = loginResult.lastResult[0] as VOLogin"/>
              <loginservice:LoginService id="loginService"
                                               fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                               showBusyCursor="true"/>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
         </fx:Declarations>
         <s:TextInput id="username" includeIn="Login" x="118" y="37" width="107"/>
         <s:TextInput id="password" includeIn="Login" x="118" y="88" width="107" displayAsPassword="true"/>
         <s:Label includeIn="Login" x="20" y="38" width="84" height="22" text="Benutzername:"
                    textAlign="right" verticalAlign="middle"/>
         <s:Label includeIn="Login" x="20" y="88" width="84" height="22" text="Passwort:"
                    textAlign="right" verticalAlign="middle"/>
         <s:Button id="buttonLogin" includeIn="Login" x="22" y="143" width="195" label="Login"
                     click="buttonLogin_clickHandler(event)"/>
    </s:WindowedApplication>
    and my 2 php Files look like this:
    VOLogin.php
    <?php
    class VOLogin {
         public $id;
         public $valid;
         public $msg;
          public $username;
          public $password;
         public $versionnumber;
    ?>
    And this is my LoginService.php file:
    <?php
    require_once('VOLogin.php');
    require_once('config.php');
    //$foo = new LoginService();
    //var_dump($foo->login("heinz", "heinz"));
    class LoginService {
    * Retrieve all the records from the table
    * @return an array of VOBenutzer
    * @param string $username
    * @param string $password
    public function login($username, $password) {
        $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
        mysql_select_db(DATABASE_NAME);
        $SQL = "select * from flex where username='".$username."' and password='".$password."'";
        $r = mysql_query($SQL);
        if(mysql_num_rows($r) == 1) {
            $row = mysql_fetch_object($r);
            $tmp = new StdClass();
            $tmp->id = $row->id;
            $tmp->valid = true;
            $tmp->msg = "Login Ok";
            $tmp->username = $row->username;
            $tmp->password = $row->password;
            $tmp->versionnumber = $row->versionnumber;
            $output[] = $tmp;
        }else {
            $tmp = new StdClass();
            $tmp->id = 0;
            $tmp->valid = false;
            $tmp->msg = "Benutzername oder Passwort falsch";
            $tmp->username = $username;
            $tmp->password= $password;
            $tmp->versionnumber = 0;
            $output[] = $tmp;
        return $output;
    ?>
    My actual problem is that I have to press 2 times on the button to get the correct trace information. With the help of the search function I found this thread:
    http://forums.adobe.com/thread/259280
    I am not sure if I have the same problem. If yes where should I put the eventhandler? I would be very happy for every useful answer.
    Greetings
    flexx0r

    Here is a good article on how the % key works.
    It is working as designed. It just isn't what you are expecting. It just isn't designed for Engineers.
    http://blogs.msdn.com/b/oldnewthing/archive/2008/01/10/7047497.aspx

  • Using Flex/PHP to Display MYSQL data and Images

    Does anyone have any good examples of using Flex 3 in conjunction with PHP to display data and images from a mysql database? I've searched a lot and it seems hard to find this combination. I have manged to create a login system using this which allows users to login via usernames and passwords that are stored in my mysql database (Grizzz helped me out a lot with this).
    But I now want to create a product selection in the site with the categories down the left hand side and the products related to these categories displayed in the other panel once each of these products are clicked. The guy I'm making it for wants to be able to add and delete categories as well as add and delete products so obviously it needs to be done using php and mysql. I'm looking for something similar to the way the online shop is laid out in the following example:-
    https://www.whitestonecheese.co.nz/Radshop/bin/Whitestone.html
    Thanks for any suggestions.

    To solve this problem I had to use labelFunction.  The working line was this:
    <mx:DataGridColumn headerText="Description" labelFunction="dataGrid_labelFunc"  dataField="messageDetail"/>
    The function looks like this:
    private function dataGrid_labelFunc(item:XML, col:DataGridColumn):String {
         var qN:QName = new QName(vm, col.dataField);
         return item[qN].text();

  • Flex & PHP - Send email attachment

    I'ld like for my visitor to be able to send an email to a friend with the creation from my application as an attatchment (so like a screencap of the creation). I can get Flex and PHP to communicate and send an email, but I can't get the image to send. It sends an attachment that is 2o or less and can't be opened (of course !).
    I don't get an error return from my application
    I found these posts linked below which helped me, but I still don't get how to pass the image from Flex to PHP.
    Saving entire Flash document as JPEG to email as an attachment
    Sending an E-mail with attachment with PHP from Flex
    Here is my code from Flex :
    private function sendMail():void{
                var _nomSTF:String = nomSTF.text;
                var _emailSTF:String = emailSTF.text;
                var _emailFriendSTF:String = emailFriendSTF.text;
                var _sujetSTF:String = sujetSTF.text;
                var _messageSTF:String = messageSTF.text;
                //IMAGE
                var fr:FileReference = new FileReference();
                var encoder:PNGEncoder = new PNGEncoder();
                var screenshotData:BitmapData = new BitmapData(conteneurDeMonImage.width, conteneurDeMonImage.height, true, 0xFFFFFF);
                screenshotData.draw(conteneurDeMonImage);
                //var outputData:ByteArray = encoder.encode(screenshotData);
                //var base64:Base64Encoder = new Base64Encoder();
                var png:PNGEncoder = new PNGEncoder();
                byteArray = png.encode(screenshotData);
                //base64.encodeBytes(outputData);
                //FIN IMAGE
                var evValidMail:ValidationResultEvent = emailSTFValidator.validate();
                var evValidMailFriend:ValidationResultEvent = emailFriendSTFValidator.validate();
                var evValidName:ValidationResultEvent = nomSTFValidator.validate();
                if (evValidMail.type == ValidationResultEvent.VALID
                    && evValidName.type == ValidationResultEvent.VALID
                    && evValidMailFriend.type == ValidationResultEvent.VALID){
                    emailService.send({senderName: _nomSTF, senderEmail:_emailSTF, emailFriendSTF: _emailFriendSTF,
                        emailSubject:_sujetSTF, emailMessage: _messageSTF, file : byteArray});
                } else {
                    resultLabel.text="There are Form errors";
                    resultLabel.setStyle("styleName", "invalid");
            private function emailResultSTF():void{
                Alert.show("Votre message a bien été envoyé");
                containerSendToFriend.visible = false;
    <fx:Declarations>
        <s:HTTPService id="emailService" url="src/mail.php" method="POST"
                        resultFormat="xml" useProxy="false"
                        result="emailResultSTF()"
                        fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail + '\n' + event.message.toString())"/>
    </fx:Declarations>
    And here's my PHP code :
    $fileatt_type = "application/octet-stream";
    $fileatt_name = "baignoireElyseeConcept.png";
    $sender_name =  $_POST['senderName'];
    $email_from = $_POST['senderEmail'];
    $email_subject = $_POST['emailSubject']; 
    $email_message = $_POST['emailMessage']; 
    $email_to = $_POST['emailFriendSTF'];
    $headers = 'From:'.$sender_name.'<'.$email_from.'>';  
    $data= $_POST['file'];
    $semi_rand = md5(time());  
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";  
    $headers .= "\nMIME-Version: 1.0\n" .  
                "Content-Type: multipart/mixed;\n" .  
                " boundary=\"{$mime_boundary}\"";  
    $email_message = "This is a multi-part message in MIME format.\n\n" .  
                    "--{$mime_boundary}\n" .  
                    "Content-Type:text/html; charset=\"utf-8\"\n" .  
                   "Content-Transfer-Encoding: 7bit\n\n" .  
    $email_message . "\n\n";  
    $email_message .= "--{$mime_boundary}\n" .  
                      "Content-Type: {$fileatt_type};\n" .  
                      " name=\"{$fileatt_name}\"\n" .
                      "Content-Transfer-Encoding: base64\n\n" .  
                     $data . "\n\n" .  
                      "--{$mime_boundary}--\n";  
    $mailsend = mail($email_to, $email_subject, $email_message, $headers);
    Thanks for your help

    I've looked around for an answer for this for days and finally got it to work so here's how I did it (helped by a lot of ressources on the internet and specifically this one : http://j-query.blogspot.com/2011/02/save-base64-encoded-canvas-image-to-png.html)
    here's my Flex code for my image :
    var je:JPEGEncoder = new JPEGEncoder(100);
        var bd:BitmapData = new BitmapData(conteneurDeMonImage.width,conteneurDeMonImage.height);
        bd.draw(conteneurDeMonImage);
        var ba:ByteArray = je.encode(bd);
        var be:Base64Encoder = new Base64Encoder();
        be.encodeBytes(ba);
        var encodedData:String = be.toString();
                                            // Testing if my base64 is working in FLEX
                                            /*var byteArr:ByteArray;
                                            var B64dec:Base64Decoder = new Base64Decoder();
                                            B64dec.decode(encodedData);
                                            byteArr = B64dec.toByteArray();
                                            imageEnGrand.load(byteArr);*/
        emailService.send({senderName: _nomSTF, senderEmail:_emailSTF, emailFriendSTF: _emailFriendSTF, emailSubject:_sujetSTF, emailMessage: _messageSTF, file : encodedData});
    Here's my PHP code :
    $fileatt_type = "application/octet-stream";
        $fileatt_name = "test.jpg";
        $sender_name =  $_POST['senderName'];
        $email_from = $_POST['senderEmail'];
        $email_subject = $_POST['emailSubject']; 
        $email_message = $_POST['emailMessage']; 
        $email_to = $_POST['emailFriendSTF'];
        $headers = 'From:'.$sender_name.'<'.$email_from.'>';  
        $data = $_POST['file'];
        $data = str_replace('data:image/png;base64,', '', $data);
        $data = str_replace(' ', '+', $data);
        $img_data = base64_decode($data);
        $png = chunk_split(base64_encode(($img_data)));
        $semi_rand = md5(time());  
        $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";  
        $headers .= "\nMIME-Version: 1.0\n"."Content-Type: multipart/mixed;\n"." boundary=\"{$mime_boundary}\"";  
        $email_message =
                                                "This is a multi-part message in MIME format.\n\n".
                                                "--{$mime_boundary}\n"."Content-Type:text/html; charset=\"utf-8\"\n".
                                                "Content-Transfer-Encoding: 7bit\n\n".$email_message."\n\n";
        $email_message .= "--{$mime_boundary}\n" .  
                          "Content-Type: {$fileatt_type};\n" .  
                          " name=\"{$fileatt_name}\"\n" .
                          "Content-Transfer-Encoding: base64\n\n" .  
                         $png . "\n\n" .  
                          "--{$mime_boundary}--\n";  
        $mailsend = mail($email_to, $email_subject, $email_message, $headers);
    I hope it helps someone who has the same problem as me !

  • Flex + amfphp vs. flex +php&xml

    Here's the deal. I hear how great amfphp is, and how much
    easier it is to develop flex applications with a PHP back end by
    using amfphp, but I don't understand it at all. On the other hand,
    I DO understand how to use POST in Flex to make PHP mysql queries,
    convert the results into xml and then use the xml in flex. It seems
    SO straightforward and easy to understand compared with
    understanding everything going on in amfphp, but I can see that it
    will be a pain to do all the coding to get what I want done doing
    it that way. So is it worth it to figure out amfphp and flex
    remoting, or should I just churn out the code using what I know?
    I want to do things the smart way, but I looked at a couple
    amfphp tutorials and I have absolutely no clue what is going on. I
    feel like I have wasted the whole night, and not learned anything,
    while I could have been working on the code to do it with xml. The
    explanations in those tutorials seem to assume a HUGE amount of
    knowledge that I don't have, and I can't really find tutorials that
    explain things in newbie language. Plus, I don't even know what
    other tutorials I should look at and understand before I even start
    to understand the amfphp tutorials, so I'm not sure the amount of
    time its going to take for me to learn everything I need.
    To top it all off, I don't really even get what the benefit
    is... Look at the code below from one tutorial -
    http://www.sephiroth.it/tutorials/flashPHP/flex_remoteobject/page003.php.
    Aside from the fact that I barely understand what is going on, just
    how is this easier than outputting xml?

    Maybe this will help explain...
    http://blogs.adobe.com/mikepotter/2006/07/php_and_flex_js.html
    Scott

Maybe you are looking for