Posts filed under 'Flex'
Image file upload in Flex with fixed size
hello guys this is some thing wht we use in almost every registration system which ask you for uploading the photo,in flex we can use this script whcih can restrict the size of image file and will upload the image on server….
the script goes like this.. everything is performed at client side.. so tht is better
public var fR:FileReference = new FileReference();
public var imageTypes:FileFilter = new FileFilter(“Images (*.jpg, *.jpeg, *.gif,
*.png)”, “*.jpg; *.jpeg; *.gif; *.png”);
public var image:Array = new Array(imageTypes);
public var request:URLRequest;
public function initApp():void
{
fR.addEventListener(Event.SELECT, selectHandler);
fR.addEventListener(Event.COMPLETE, completeHandler);
}
//call this function when you clck on browse button of your MXML
public function startUpload(eventObj:Event):void
{
registeredCtrl.photo.setFocus();
var success:Boolean = fR.browse(image);
request.url = “http://path to your folder on server”;
request.method = “POST”;
}
public function selectHandler():void
{
if(fR.size<=”size to be restricted”);
{
fR.upload(request, “file”, false);
}
}
public function completeHandler():void
{
//Action for further flow of program.
}
this is how we can upload image with size limitations in FLEX.
Add comment May 5, 2007
Flex-PHP using Httpservices
while loading data from PHP to Flex using http services….
flex code or http services will be as bellow
<mx:HTTPService id=”countryLoad” url=”{URL1}” showBusyCursor=”true” method=”POST” useProxy=”false” result=”regObj.countryLoad(event)” fault=”regObj.faultHandler(event)” >
</mx:HTTPService>
the function where the result will be obtian will be the array collection the code goes bellow
public function countryLoad(resultObj:Object):void{
var tempArray:ArrayCollection = resultObj.result.count.name as ArrayCollection;
registeredCtrl.country.dataProvider=tempArray;
//registeredCtrl.callcity();
init();
}
the PHP code where the complex object is send as array collection is given bellow
<?php
//header(“Content-Type: text/xml”);
$dbhost = ‘localhost’;
$dbusername = ‘root’;
$dbuserpassword = ”;
$default_dbname = ‘databasename’;
$link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
mysql_select_db(“databasename”,$link_id);
$query=”select code, name from country”;
$result=mysql_query($query);
$i=0;
$return=”<count>”;
while($row=mysql_fetch_array($result))
{
$contry[$i]=$row[0];
$i++;
$return.=”<name><label>”;
$return.=$row[1];
$return.=”</label><data>.$row[0].</data></name>”;
//echo $contry[i];
}
$return.=”</count>”;
echo $return;
?>
it is very easy to use the XML and HTTPSERVICES if you are begginer,
if object is complex use above method…
no need of serializing even just check it out and enjoy…
Add comment February 14, 2007