/    Sign up×
Community /Pin to ProfileBookmark

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 [B]PHP[/B] file coding is like this:
<?php

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

?>

and [B]FLEX 3[/B]:
<?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.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ChunLauthorJun 24.2009 — 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:xampphtdocsimages";

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

//use the directory class
$imgs = dir("C:xampphtdocsimages");

//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>
Copy linkTweet thisAlerts:
@abdulrehmanJun 26.2009 — 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
Copy linkTweet thisAlerts:
@ChunLauthorJul 01.2009 — 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.
×

Success!

Help @ChunL spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...