Communication from php to as3 in AIR

Gidday guys
I have an AIR desktop app that uploads a csv file to the server. Php parses the csv through several different stages (one script containing different parsing processes).
Php sends back a 'print' status to say if the process succeeds or not.
What I'm wondering - is it possible to send back print statements throughout the script's processing? So a print statement after process 1, after process 2 etc? Or would I have to split the single script into multiple processes?
I set up multiple print statements in different sections of the php script, but it sends all them after the entire script has processed.
Cheers

Close - there are several for-loops, but rather than a percentage update during the loops, I just want to send a var back after each loop is done.
I use these listeners to display a progress bar while the file is uploading, and check in AS3 for when event.bytesLoaded == event.bytesTotal, and when it does turn off the progress bar and display a generic animated progress image. I figured I could then fire back vars in between each php loop which I could filter in AS3 using switch to display the appropriate message - Stage 1, Stage 2 etc.
myFile.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, completeFunc,false,0,true);
myFile.addEventListener(IOErrorEvent.IO_ERROR, displayErrorMessage);
myFile.addEventListener(ProgressEvent.PROGRESS, uploadProgress);

Similar Messages

  • Passing variables from PHP to AS3

    I am trying to get variables retrieved from a MySQL database
    by a PHP script into my ActionScript 3.0. script. To test I have
    created a simple instance of dynamic text called date_txt, and put
    the AS3 code below into the actions layer:
    All I want to do now is replace the hardcoded date values
    with variables passed from the PHP script (also shown below).
    Can anyone suggest a VERY simple way of passing the PHP
    variables $tgt_year, $tgt_month and $tgt_day into the AS3 code and
    let me know what modifications I need to make to the PHP to make
    the variables available to Flash?
    Thanks, Will

    Hi dzedward,
    I tried the code you posted at
    http://forums.flashgods.org/viewtopic.php?f=41&t=98
    with a little problem. Why is it that the value from event.data
    after complete loading has the value of the entire script of PHP
    script?
    At first, I have this error:
    The markup in the document following the root element must be
    well-formed.
    I replace the following codes: ########
    XML.ignoreWhitespace = true;
    var theResult:XML = new XML(event.target.data);
    var lastName = theResult.client.lname;
    With this one: ########
    trace(event.target.data);
    and has this output: #########
    <?Php
    echo "<?xml version=\"1.0\"?><clients>";
    echo "<client><lname>test
    sdfsaf</lname></client>"
    echo "</clients>";
    ?>
    instead of this output: #########
    <client><lname>test
    sdfsaf</lname></client>
    Please help me out.
    Thank you

  • I just got the iPhone 5S.  I am able to RECEIVE air drops from people, but I can't send anything via Air Drop.  I doesn't seem to be communicating with others.  I have Air Drop to communicate with my contacts, but it isn't working.  :(  Help!

    I just got the iPhone 5S.  I am able to RECEIVE air drops from people, but I can't send anything via Air Drop.  I doesn't seem to be communicating with others.  I have Air Drop to communicate with my contacts, but it isn't working.    Help!

    iOS: Use AirDrop to wirelessly share content

  • Moving contacts from Blackberry Pearl to Macbook Air

    Hi,
    I still have a Blackberry Pearl as my phone but have just upgraded to a Macbook Air as my laptop (from using a PC).
    Any advice on how I move my contacts from the Pearl to the Air ?
    And will I be able to regularly synch the two (as I did with my old PC)?
    Cheers, Baz

    Hi and Welcome to the Community!
    Refer:
    KB19148 How to synchronize organizer data in Microsoft Office for Mac between the BlackBerry smartphone and a Mac computer using BlackBerry Desktop Software
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Special characters in String variable sent from php.

    Hello. Assuming that I send some String variable from php into flash:
    AS3:
    var MyImportedString:String;
    var variables_page_text:URLVariables = new URLVariables();
    var varSend_page_text:URLRequest = new URLRequest("MyPHP.php");
    varSend_page_text.method = URLRequestMethod.POST;
    varSend_page_text.data = variables_page_text;
    var varLoader_page_text:URLLoader = new URLLoader;
    varLoader_page_text.dataFormat = URLLoaderDataFormat.VARIABLES;
    varLoader_page_text.addEventListener(Event.COMPLETE, var_comp_page_text);
    varLoader_page_text.load(varSend_page_text);
    function var_comp_page_text(event:Event):void {
        MyImportedString =  event.target.data.MyVariable;
    php:
    <?php
    header('Content-Type: text/html; charset=utf-8');
    $MyString = "some tekst &";
    print "MyVariable=" . $MyString;
    ?>
       I've noticed that the special character '&' residing inside String, throws an error:  #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
      My first thought was, it has something to do with html entities, but other entities (like <> or ") don't throw any error. Besides, the use of php functions like htmlentities(); or html_entity_decode(); doesn't make any difference in this case:
    print "MyVariable=" . htmlentities($MyString);
    or
    print "MyVariable=" . html_entity_decode($MyString);
      I've also noticed that characters like '%', '^', '+' don't show up at all;
      What does it mean? Any ideas?
      Reagards.

    Thank You 'moccamaximum'.
    Ok. So here is the solution (php function posted by 'moccamaximum' does the trick):
    AS3:
    var MyImportedString:String;
    var variables_page_text:URLVariables = new URLVariables();
    var varSend_page_text:URLRequest = new URLRequest("MyPHP.php");
    varSend_page_text.method = URLRequestMethod.POST;
    varSend_page_text.data = variables_page_text;
    var varLoader_page_text:URLLoader = new URLLoader;
    varLoader_page_text.dataFormat = URLLoaderDataFormat.VARIABLES;
    varLoader_page_text.addEventListener(Event.COMPLETE, var_comp_page_text);
    varLoader_page_text.load(varSend_page_text);
    function var_comp_page_text(event:Event):void {
        MyImportedString =  event.target.data.MyVariable;
         trace(MyImportedString);        // Output:  some text &%^+
    php:
    <?php
    header('Content-Type: text/html; charset=utf-8');
    $MyString = "some text &%^+";
    print "MyVariable=" . flash_encode($MyString);
    function flash_encode($string){
         $string = rawurlencode(utf8_encode($string));
         $string = str_replace("%C2%96", "-", $string);
         $string = str_replace("%C2%91", "%27", $string);
         $string = str_replace("%C2%92", "%27", $string);
         $string = str_replace("%C2%82", "%27", $string);
         $string = str_replace("%C2%93", "%22", $string);
         $string = str_replace("%C2%94", "%22", $string);
         $string = str_replace("%C2%84", "%22", $string);
         $string = str_replace("%C2%8B", "%C2%AB", $string);
         $string = str_replace("%C2%9B", "%C2%BB", $string);
         return $string;
    ?>

  • How to execute one .exe file with as3 in air ?

    Hi
    How to execute one .exe file with as3 in air?
    I want do this work without fscommand .
    plize help me .

    itsdhanasaraa wrote:
    But as this a web application ... By using Runtime i'm getting some probs ..
    Let me guess, you want your web application to run a program on the client and to your surprise that's not working?
    Ain't gonna happen.
    its taking more time to execute .... that's y is there any other option to execute .exe file other than Runtime.getRuntime().exec("filename");Write proper English and you may be taken more seriously.
    1) it's not "taking more time to execute", whatever that's supposed to mean.
    2) there's no other way to execute something. Not that you should every use even that way anyway
    3) whenever you start thinking of executing external programs from Java, start thinking of not using Java in the first place.

  • What is the best way to pass a var from php to a swf to swf

    Hi,
    Whats the best most correct or professional (less chances of error or most efficient) way of sending a var from php to a swf container and then to a swf that is loaded with the loader class from the container???
    Thanks

    Hi Kglad thanks for the answer,
    Yes using AS3, I think I didnt give u enough info though.
    The thing is the php file is actually the index file which has the first swf lets call it conatiner.swf embeded and conatiner.swf then calls the other swf lets call it main.swf by using URLloader. So I dont think I can user URLloader on the index.php file, and I cant put the code in another .php file and call it because I need data from the index.php file specifically.
    Any ideas?
    I know I can use flash vars for the first step of the index.php to container.swf but im trying to avoid it cause im not so familiar with it or embedding and theres two diferent embedding methods im using depending on the site and im probably going to have to change them again later on cause im still having an issue.
    Thanks

  • Server site php and As3 data

    Hi,
    I am new in php coding. I want to get image data from php and also display in flash.
    I want to know... how to read and display imagejpeg( $imgData ); from php.
    I am able to get php data in flash through below method...
    /* AS3 */------------------
    var src:String = "pic.jpg";
    var width:String = "250";
    var height:String = "250";
    var urlReq:URLRequest = new URLRequest(src);
    var urlLoader:URLLoader = new URLLoader();
    var urlVar:URLVariable = new URLVariable();
    urlVar.src= src;
    urlReq.mehtod = URLRequestMethod.POST;
    urlReq.data = urlVar;
    urlLoader.load ( urlReq );
    urlLoader.addEventListener(Event.Complete, doneProcFnc)
    function doneProcFnc(ev:Event):void{
          trace ( "data access from php done" );
    /* PHP */
    $src = $_POST [ 'src' ];
    $wd = $_POST [ ' width' ];
    $ht = $_POST [ ' height' ];
    /*  this function will create one black color area for croping refence */
    $cropImg = imagecreatetruecolor ( cropImageWd, cropImageHt );
    /* this function will reproduce particular image required width and height without reducing the image quality */
    imagecopyresampled ( cropImage , sourceImage, destX , destY, sourX, sourY, ect... );
    imagejpeg( $imgData ) ;
    Now, here the problem comes. I don't know how to display that imagejpeg data into flash.
    I need help.
    Thanks.

    Thanks.
    No.No.No. I am not loading image from folder.
    step1 : I m sending some image information to php (src , width , height)
    step2 : PHP code will take that information
    step3 : PHP code will crop that particular image (some calcution for quality)
    step4 : PHP code will generate some image data that is /* imagejpeg( $imgData ) */ and return back to flash
    step5 : Now the problem occur, how can i take that image data in flash or what form
    Possibilities :
    ? should i get image data as text format and it needs to be encoded (like jpeg encoder)
    ? i don't know i already try jpegencoder but i did not get anything
    var src:String = "pic.jpg";
    var width:String = "250";
    var height:String = "250";
    var urlReq:URLRequest = new URLRequest(src);
    var urlLoader:URLLoader = new URLLoader();
    var urlVar:URLVariable = new URLVariable();
    urlVar.src= src;
    urlReq.mehtod = URLRequestMethod.POST;
    urlReq.data = urlVar;
    urlLoader.load ( urlReq );
    urlLoader.addEventListener(Event.Complete, doneProcFnc)
    function doneProcFnc(ev:Event):void{
              trace ( "data access from php done" + ev.target );
            // imagejpeg( $imgData )
    /* PHP */
    $src = $_POST [ 'src' ];
    $wd = $_POST [ ' width' ];
    $ht = $_POST [ ' height' ];
    /*  this function will create one black color area for croping refence */
    $cropImg = imagecreatetruecolor ( cropImageWd, cropImageHt );
    /* this function will reproduce particular image required width and height without reducing the image quality */
    imagecopyresampled ( cropImage , sourceImage, destX , destY, sourX, sourY, ect... );
    imagejpeg( $imgData ) ;

  • I bought a movie from itunes on my mac air and now I can't find it.

    I bought the movie Beautiful Creatures from iTunes on my Mac Air. I was in the middle of downloading it, when iTunes crashed and I had to reopen it. When I did, the movie was gone and so was the currently downloading option. I spent $20 on this movie and it seems the only option is to buy it again. I could really use some help! Thanks

    Click Store > Check for Available Downloads on iTunes' menu.

  • I'm trying to print  an Ancestry document from an iPad 2 using air print onto a Canon 5350 (one of the printers ok'd by Apple) I am unable to change the print orientation from portrait to landscape.  That is I change it in printer settings but no use.

    I'm trying to print an Ancestry document from an iPad 2 using air print.  The printer is a Canon MG5350 (on the Apple approved list) I have no difficulty printing but only in portrait format.  I've tried changing printer preferences from my computer but even though the Canon accepts the changes it will not print landscape - can anyone advise please?

    Hi,
    How do you connect the printer to the XP machine ? If USB, you need to make that machine as a Print server. Please try this:
       http://techtips.salon.com/make-windows-computer-pr​int-server-11914.html
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • I have an Air running Mountain Lion. I also have a digital point-and-shoot camera, but have never downloaded any images from the camera to this Air. If I connect the camera to the Air, what might I expect? Will connecting the camera to the Air by a cable

    I have an 11" Air with lots of remaining capacity running Mountain Lion. I also have a digital point-and-shoot camera. I have never downloaded images from the camera to this Air. However, if I just connect the camera to the Air's USB port, with the camera's available cable, and the Air is open, will a program like ImageCapture or iPhoto, auomatically come up, and I can begin to download wanted images? Or, will this sort of connection delete or fry everything on the Air? Do I need any other software on board? Will current Apple onboard programs allow me to download images from my camera and not destroy everything else?

    Answered. Thanks.

  • How can I sync apps from my iTunes on Macbook Air without syncing apps from the iPad 2 to my Macbook Air?

    How can I sync apps from my iTunes on Macbook Air without syncing apps from the iPad 2 to my Macbook Air? (As my Macbook Air is only 64GB and my iPad is 64GB and that my Macbook Air only has 40 GB left...) Or is there no other way but to sync apps from iTunes to iPad without syncing apps from iPad to iTunes(it says Backing Up , then it says Converting files to iTunes, then it shows the name of the app on the bottom...)

    Yes, sign in with the same Apple ID as your stolen one in the new iPod Touch.

  • I cannot get my 1st generation iPod Nano to sync my new downloads from itunes on my macbook air.  Is this possible or not?

    I cannot get my 1st generation iPod Nano to sync my new downloads from itunes on my macbook air.  Is this possible or not?

    Are you noticed that there are replacement program for iPod Nano 1st gen?
    I've had replace my iPod nano 1st with 8 Gb iPod Nano 6th gen last year.
    Check this out --> http://www.apple.com/support/ipodnano_replacement/

  • I have a new iMac running iTunes 10.4 in OS 10.6.8, and a new Mac Air running iTunes 10.4 in Lion.  I was able to transfer all my music etc. from the iMac onto the Air, but cannot figure out how to get the Playlists from the iMac to the Air.  iTunes Help

    I have a new iMac running iTunes 10.4 in OS 10.6.8, and a new Mac Air running iTunes 10.4 in Lion.  I was able to transfer all my music etc. from the iMac onto the Air, but cannot figure out how to get the Playlists from the iMac to the Air.  iTunes Help says File >Library >Export playlist and choose XML, or to save a copy of all your playlists, File > Library > Export Library, "the Exported info is saved in XML format."  Then it says, "to import an iTunes playlist, File > Library > Import Playlist".  Now I am assuming I do that import part on the Air, but when I try it doesn't recognize anything that can be imported - what am I missing??? Aside from a clue...

    Thanks, Jim, for taking the time, but the reply is unfortunately vague in the exact area of my confusion!  "you need to copy that file to your new computer..."  Well, the Import/Export instructions make it seem as if the two computers should be able to communicate this file thru wifi, but that's the linkage I can't seem tocreate with Import/Export.  Should I instead email a copy to myself (thats what applecare suggested)?  Copy it to and from a thumb drive?  But then place the file where?  And the article was helpful, but should I be trying to move the Library file or the Library.xml file (as iTunes Help suggests)?  Sorry to be so clueless about it...I suppose I buy Apple in the hopes of not having to think about this stuff, which approach seems not to be serving me well. Thanks again for your time!

  • Window Server communications from outside of session allowed for root

    Hi ,
    When I am running the following program, i got the exception as
    49:wasp.corp.apple.com_kevinli:/ngs/app/giat/src/java/chart> java MyFrame
    kCGErrorRangeCheck : Window Server communications from outside of session allowed for root and console user only
    Exception in thread "main" java.lang.InternalError: Can't connect to window server - not enough permissions.
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1503)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:834)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
    at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
    at java.awt.Component.<clinit>(Component.java:506)
    at MyFrame.<clinit>(MyFrame.java:6)
    import java.awt.*;
    import javax.swing.*;
    public class MyFrame
    public static JFrame f = new JFrame();
    public static void main(String[] args)
    JFrame.setDefaultLookAndFeelDecorated(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Add the ubiquitous "Hello World" label.
    JLabel label = new JLabel("Hello World");
    f.getContentPane().add(label);
    //Display the window.
    f.pack();
    f.setVisible(true);
    Please send a reply on this.
    with regards,
    Mohan

    Seth,
    you may also install the latest update (10.4.6) using the combo file from apple.com.
    Mihalis.
    Dual G5 @ 2GHz   Mac OS X (10.4.6)  

Maybe you are looking for

  • Dubbed from Vhs tape - won't play in iMac

    Wishing to get them onto a DVD, I had some 8mm home movie films transferred to videotape, which I then dubbed onto a disk using a friend's Toshiba recorder/player.  When I insert that disk into my iMac in hopes of editing the content it and making a

  • Firefox 25 advises an update's available-then says "up to date"

    1st - is there a way to set # of search results per page? Don't see it in acct settings. Too few results / page & takes too long to go from pg to pg. I don't have dial up any more.:) This is 1st time I've ever seen this. Update notifies me Fx 25.0.1

  • Problem compiling a  file which utilises a class I've created

    I am experimenting with creating my own classes. I've created my own class and I'm able to compile it. When I try to compile my test file to test the class I get a "cannot resolve symbol" error referring to where my class name is in the test file. Th

  • IDOC to EDI Conversion

    Hi, I am New to EDI-IDocs,We have a requirement over here to send the iDocs from SAP to Non-SAP sys(JCAPS). Need step-by-step details to convert the iDoc to  EDI format. Helpfull Answers will b Rewarded. Regards Giridhar Reddy

  • Problem about Beoplayer.

    Hello: I got a problem with the process of submitt the beoplayer. I tried to make a new account. After I typed all the informations and click "Submitt". Then It goes like this: I don't understand why it goes like this. I tried use "Run as an Administ