Jump to content
Larry Ullman's Book Forums

Necuima

Members
  • Posts

    359
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by Necuima

  1. Hi Larry,

     

    I am trying to learn about ajax features in Flex and am in chapter 8. The examples look good!

     

    I have created and populated the database (MySQL) and have tested the php script getEmployees.php in my browser and it works fine. I can see that it has created the XML response data OK.

     

    But when I try and run the application from within FlashBuilder as per page 251 (CTRL+F11) nothing happens. I created the new flex project as a windowed application - could that be the problem? I also tried to run it in debug mode (F11) but also nothing happens that I can see.

     

    As always, any advice will be muchly appreciated.

     

    Thanks, Necuima.

     

    P.S., I have now created the app as not a windowed application and it ran perfectly. Can I make changes so that it will work as a windowed app? If so, what do I need to change?

     

    Again, any advice will be appreciated.

  2. Hi again, Larry,

     

    I was wondering if the Flash windowed application could be used to select the directories as per its current functionality, and then this directory information passed over to a modified PHP script for it to do the actual image resizing? Can this be done in an AJAX sort of way (via localhost, as a remote hosted PHP script would probably be too slow due to the uploading and downloading of all the image files)? Ideally, the user would only see the windowed application user interface (mx: Form) as at present, with the 'work' being done behind the scenes via PHP/localhost, and when that was all done, a message to that effect given to the user via the windowed application form display. Would there be Flash security model implications?

     

    Any suggestions/advice will be most welcomed.

     

    Thanks, Necuima.

  3. Hi Larry,

     

    Well, my PC is 'back on the air' again thankfully!

     

    You are right - I was able to re-jig the code so that the for loop was not needed in the same context. Many thanks for the suggestion.

     

    The application just cycles through every jpg image file in a selected input directory and resizes them (down) and writes the downsized images out with the same file name but in the selected output directory.

     

    But the quality of the downsized images isn't great! I have the same function in a PHP script using GD and the image quality is much better for similar sized image files.

     

    Any suggestions to improve the image quality in the windowed application?

     

    Many thanks again in anticipation,

     

    Cheers from Oz.

  4. Hi Larry,

     

    I am getting more and more confused with this - one might say hopelessly befuddled!

     

    Here's part of my logic flow code:

     

     

    // now go through the files in the input directory and resize them if they are jpg image files

     

    var inContents:Array;

    inContents = dirin.getDirectoryListing();

    // creates an array of file objects - one for each file in the directory

     

    for (i = 0; i < inContents.length; i++)

    {

     

    // Alert.show(inContents.nativePath);

    nayme = inContents.name; // the i index disappears when I post this????

    Alert.show(

    "Nayme = " + nayme);

     

    if (nayme.substr(-4, 4) == ".jpg" || nayme.substr(-5, 5) == ".jpeg")

    {

    // we have a file name that indicates that the file is a jpg file

    Alert.show(

    "About to process " + nayme);

     

    // processing goes here....(removed for the example)

    p++;

    // counts the number of images processed

    }

     

    else

    {

    // not a jpg file suffix

    Alert.show(

    "Skipped " + nayme);

    s++;

    // counts the number of files not processed

    }

    }

    // end for loop

     

     

     

     

    But the weird thing that I cannot understand is that the 'About to process' and 'Skipped' Alert.shows show BEFORE the 'Nayme = name' Alert.show. It's like it is backwards. This dis-order of sequential processing is, I think, behind part of the larger problem I am having with this code, but I'd like to solve each bit at a time.

     

    Maybe Flex is the wrong facility to use for this application which is primarily a batch operation?

     

    Your or others who may be able to help's advice will be much appreciated.

     

    Thanks, Necuima.

  5. Hi Larry & Jason,

     

    As mentioned above, I am quite new to Flash but I am trying to use Flash Builder to generate a windowed application that reads all the files in a directory, does some processing on them, and writes the changed files out to another directory.

     

    But it seems that I need a mix of synchronous functions and asynchronous functions and I'm getting in a muddle as to how to handle this.

     

    I have some logic which enables the user to select the input directories and the output directories and that works fine.

     

    Then I have a button to start the processing logic and that starts it off OK.

     

    The logic flow is..

     

    . delete all files in the output directory (works OK)

    . use getDirectoryListing to build an array of File objects, one for each file in the input directory (they are jpg image files)

    . then I want to use a for loop to loop through each file, resize the jpg image and then write the resized image out

     

    - reading the first input file synchronously works fine.

    - but then I need to use the loader class to load the just-read file which is now a bytearray, but loadbytes is asynchronous.

    - I wrote an event listener OK which fires up an 'onloadcomplete' function when the loader has finished loading, BUT I don't want any other processing to continue until the onloadcomplete function has done it's logic.

    - And then I want to go back to the point just after the loader function was called and continue synchronous processing, i.e., back through the for loop to process the next jpg image file.

     

    Is this possible?

     

    Any advice will be muchly appreciated. Thanks in anticipation, Necuima.

  6. Hi Larry,

     

    As you know, I am a complete beginner with Flex, but what I've seen of your book so far has been very helpful. But I am keen to try something probably before I've gone far enough into the book, and it is more AIR focused than web focused, but maybe you or someone can help me.

     

    All I'm trying to do so far is to enable the user to select a directory from the PC file system that the app is running on. In Flash Builder, I have the following:

     

     

    <?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">

     

    <fx:Script>

    <![CDATA[

     

    var file:File = new File();

    file.addEventListener(Event.SELECT, dirSelected);

    file.browseForDirectory(

    "Select a Directory");

     

    function dirSelected(e:Event):void {

     

    trace(file.nativePath);

    }

    ]]>

     

    </fx:Script>

    </s:WindowedApplication>

    Flash Builder is giving me several errors which I don't understand:

     

    On the addEventListerner line of code two errors are showing - 'access of undefined property dirSelected' and 'access of undefined property file'

    For the following line (file.browserForDirectory) the error that shows is 'access of undefined property file'.

     

    Any help will be appreciated, and thanks in anticipation.

     

    Cheers, Necuima

×
×
  • Create New...