Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 16:55
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash 8 (Moderators: Jorge Solis, ..:: Mazhar Hasan ::.., Andresss)
| | |-+  After Uploading Image how do I get the Height Width Automatically?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: After Uploading Image how do I get the Height Width Automatically?  (Read 1037 times)
Jaylada
Seasoned Programmer
***
Posts: 144



View Profile WWW Email
« on: 02/27/10, 14:43 »

using your upload image example below (Which works great by the way), once the file is uploaded, I need to grab the original height and width automatically.
Any place I've tried to put that code, its not able to get it after it completes the download.
I thought I used the OnComplete code correctly but so far its not working, it just gets the height and width of the object just prior to download is finished.

Thanks for your help



_______________________________________________________
//Allow this domain Buttons 2
System.security.allowDomain("http://localhost/");
import flash.net.FileReference;
// The listener object listens for FileReference events.
var listener:Object = new Object();
var VAR1:String=_root.neededVAR;

// When the user selects a file, the onSelect() method is called, and
// passed a reference to the FileReference object.
listener.onSelect = function(selectedFile:FileReference):Void {
   
   temp1=_root.tempName;
  //clean statusArea and details area
  statusArea.text = details.text = ""
  // Flash is attempting to upload the image.
  statusArea.text += "Attempting to upload " + selectedFile.name + "\n";
  // Upload the file to the PHP script on the server.
   selectedFile.upload("UL.php?temp1="+temp1);

};

// the file is starting to upload.
listener.onOpen = function(selectedFile:FileReference):Void {
  statusArea.text += "Uploading " + selectedFile.name + "\n";
};
//Possible file upload errors
listener.onHTTPError = function(file:FileReference, httpError:Number):Void {
   imagePane.contentPath = "error";
   imagePane.content.errorMSG.text = "HTTPError number: "+httpError +"\nFile: "+ file.name;
}

listener.onIOError = function(file:FileReference):Void {
   imagePane.contentPath = "error";
   imagePane.content.errorMSG.text = "IOError: "+ file.name;
}

listener.onSecurityError = function(file:FileReference, errorString:String):Void {
   imagePane.contentPath = "error";
   imagePane.content.errorMSG.text = "SecurityError: "+SecurityError+"\nFile: "+ file.name;   
}

// the file has uploaded

listener.onComplete = function(selectedFile:FileReference):Void {
  // Notify the user that Flash is starting to download the image.
  statusArea.text += "Upload finished.\nNow downloading " + selectedFile.name + " to player\n";
  //Show file details
  details.text = ""
  for(i in selectedFile) details.text +="<b>"+i+":</b> "+selectedFile+"\n"
  // Call the custom downloadImage() function.
  downloadImage(selectedFile.name);
};

var imageFile:FileReference = new FileReference();
imageFile.addListener(listener);

uploadBtn2.onPress = uploadImage;
imagePane.addEventListener("complete", imageDownloaded);

// Call the uploadImage() function, opens a file browser dialog.
function uploadImage(event:Object):Void {
  imageFile.browse([{description: "Image Files", extension: "*.jpg;*.gif;*.png;*.tif"}]);
}

// If the image does not download, the event object's total property
// will equal -1. In that case, display am error message

function imageDownloaded(event:Object):Void {
////I've ATTEMPTED TO PUT HEIGHT WIDTH ASSIGNEMENT HERE, that doesn't work
  if(event.total == -1) {
    imagePane.contentPath = "error";   
  }

 
}

// show uploaded image in scrollPane
function downloadImage(file:Object):Void {
  imagePane.contentPath =  "./Products/files/" + file;
  loadMovie("./files/"  + file, this.CombinedImages2.placeholder);

}
Logged
Jaylada
Seasoned Programmer
***
Posts: 144



View Profile WWW Email
« Reply #1 on: 02/27/10, 19:38 »

Ignore........

I was able to get it to work using the percentage load method check and assigning the variables at that time.

(found in: Topic: finding the end of an external loaded swf )
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!