07-10-2009, 01:26 AM
|
#1 (permalink)
|
|
The Visitor
Join Date: Jul 2009
Posts: 3
Thanks: 1
|
How use PHP to read image files from a folder and display them in Flex 3 tilelist.
Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
PHP :
PHP Code:
<?php
//Open images directory
$imglist = '';
$dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
//List files in images directory
while (($file = $dir->read()) !== false)
{
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
echo "filename: " . $file . "\n";
}
$dir->close();
?>
FLEX 3 :
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.events.ItemClickEvent;
import mx.rpc.events.ResultEvent;
public var image:Object;
private function resultHandler(event:ResultEvent):void
{
image = (event.result);
ta1.text = String(event.result);
}
private function faultHandler(event:FaultEvent):void
{
ta1.text = "Fault Response from HTTPService call:\n ";
}
]]>
</mx:Script>
<mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
<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:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
<mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
</mx:Application>
Thanks. Need help as soon as possbile. URGENT.
Tags - added by codefreak - Note from mod: please read,
Prettifying Pasted Code on TalkPHP
Thank you, and have a nice day.
Last edited by codefreek : 07-10-2009 at 06:48 AM.
Reason: TAGS - has been added - http://www.talkphp.com/lounge/4563-prettifying-pasted-code-talkphp.html
|
|
|
|