www.webdeveloper.com
Results 1 to 4 of 4

Thread: Read and display images from folder dynamically using PHP and Adobe FLEX 3

  1. #1
    Join Date
    Jun 2009
    Posts
    3

    Read and display images from folder dynamically using PHP and Adobe FLEX 3

    Hello. I need help on coding for reading images from a folder using PHP and linking it to FLEX 3 to display it in a imageTileList. Urgent.

    currently my PHP file coding is like this:
    <?php

    $dirname = "./images/mypic";
    $images = scandir($dirname);
    foreach($images as $curimg)
    {
    echo "<IMG src='./images/mypic/$curimg'/>";
    };

    ?>

    and FLEX 3:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Canvas x="10" y="10" width="692" height="554">
    <mx:TileList x="44" y="116" width="604" height="175">

    <mx:Image id="img" source="{data.src}"/>

    </mx:TileList>

    </mx:Canvas>

    <mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>

    </mx:Application>

    This is the codes which is currently not completed and im stuck. I need some help thank you.

  2. #2
    Join Date
    Jun 2009
    Posts
    3
    Hello. I need help on coding for reading images from a folder using PHP and linking it to FLEX 3 to display it in a imageTileList. Urgent.

    currently my PHP file coding is like this:

    <?
    $imglist='';

    //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/
    // see that you don't forget about the "/" at the end

    $img_folder = "C:\xampp\htdocs\images";

    mt_srand((double)microtime()*1000);

    //use the directory class
    $imgs = dir("C:\xampp\htdocs\images");

    //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
    while ($file = $imgs->read() )
    {
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    $imglist = "$file";

    } closedir($imgs->handle);

    //put all images into an array
    $imglist = explode(" ", $imglist);
    $no = sizeof($imglist)-2;

    //generate a random number between 0 and the number of images
    $random = mt_rand(0, $no);
    $image = $imglist[$random];

    //display image
    echo "<img src= $image >";
    ?>

    and FLEX 3:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >

    <mx:RemoteObject id="myservice" fault="faultHandler(event)" showBusyCursor="true" source="flashservices.picture" destination="amfphp">
    <mx:method name="sayHello" result="resultHandler(event)" />
    </mx:RemoteObject>


    <mx:Script>
    <![CDATA[

    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;


    private function resultHandler(event:ResultEvent):void
    {


    }

    private function faultHandler(event:FaultEvent):void
    {

    ta1.text = "Fault Response from HTTPService call:\n ";
    }

    ]]>
    </mx:Script>

    <mx:Canvas x="10" y="10" width="692" height="554">


    <mx:TextArea x="201.5" y="282" width="289" height="133" id="ta1" editable="false"/>
    <mx:Button x="313" y="457" label="Button" id="b1" click="pic.send()"/>
    <mx:Button x="313.5" y="487" label="Pic" id="b0" width="64.5"/> <!-->click = "img.source = 'Assets/airbg.gif';"<-->

    </mx:Canvas>


    <mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
    <mx:HTTPService id="pic" url="{phpPicture}" method="POST"
    result="{resultHandler(event)}" fault="{faultHandler(event)}"/>



    </mx:Application>

  3. #3
    Join Date
    Jun 2009
    Posts
    1

    Post display imeages by loading it file data

    hello!
    i want to make a program in adobe flex which 1st reads the file and then display the imeages. the imeage id is assigned in the xml file which will be loded at complie time and then display imeage of specific id.

    the file must be loded int form of tree.

    its means that menu will be loded xml file in the form of a specific ID and the display imeage against its id.

    regard

    Edit by admin: no contact info permitted on the forum, thank you

  4. #4
    Join Date
    Jun 2009
    Posts
    3
    hey abdulrehman. I dun really understand what u say. My php file now is able to read images from folder. But im unable to display it in tilelist in Adobe FLEX 3.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles