Link to home
Start Free TrialLog in
Avatar of madoxp
madoxp

asked on

Getting An Image Upload Scrollpane To Appear Within Movieclip

Good evening,
I am presently attempting to get an image uploading flash functioning. The idea is the user would be able to upload an image, then print it. I found a great image upload tutorial over at http://www.flash-db.com/Tutorials/upload/

Now the only wall I've run into is getting that scrollpain to also appear within the Movie Clip utilized for printing purposes. Below is the code as scene in the tutorial. Any guidance is appreciated. Thank you

-T
//Allow this domain
System.security.allowDomain("http://localhost/");
import flash.net.FileReference;
// The listener object listens for FileReference events.
var listener:Object = new Object();
 
// 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 {
  //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("upload.php");
};
 
// 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[i]+"\n"
  // Call the custom downloadImage() function.
  downloadImage(selectedFile.name);
};
 
var imageFile:FileReference = new FileReference();
imageFile.addListener(listener);
 
uploadBtn.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"}]);
}
 
// 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 {
  if(event.total == -1) {
    imagePane.contentPath = "error";	
  }
}
 
// show uploaded image in scrollPane
function downloadImage(file:Object):Void {
  imagePane.contentPath =  "./files/" + file;
}
 
stop()

Open in new window

Avatar of madoxp
madoxp

ASKER

This is pretty time sensitive, any assistance would be appreciated :)

-T
Avatar of madoxp

ASKER

Okay... so I just need to get that second pane duplicated... not sure how to get the script above to send the image to it in "PrintBox" movie clip. Please help :(

-T
SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

aneeshchopra,
thank you for your reply... if you look on line 70 of the code I posted above, I already have this aspect. So right now what is happening is you click the UPLOAD button, it uploads the image to server, then immediately downloads it and places it into that scrollpane.

What I need to happen is for the action script to send that image to the scrollpane within a movieclip on the stage. I dont know what I need to add before the

imagePane.contentPath =  "./files/" + file;

to send it into imagePane in the specified movie clip. Thank you for the lead though... :)

-T
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

I'm sorry, I dont understand, linkageID?

-T
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

Ack, i wish i could edit my prior comment... I'm sorry, i don't quite understand what you mean by linkageid? also I think their may be a bit of a disconnect between the structure of the movie, your solution and my gap of knowledge.

The file is set up with one movie, PrintBox which is the movie clip which will be printed. On the stage, outside of that movie clip is where the code from the original post exists. i want that to send the uploaded/selected image into PrintBox.

I thank you for you help thus far :)


-T,
Avatar of madoxp

ASKER

left out from last comment, ImagePane is the instance name of the scrollpane where the uploaded image appears.

-T
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

Yes/No... Within the PrintBox movieClip, i want the image to appear... yet there will be additional information that prints on that page... there for the image needs to be contained within a box within PrintBox. This is why I was trying to send the uploaded image to an object, imagePane (the scrollpane), contained within PrintBox.

Not sure how clear that is... Sorry, I know i'm difficult

-Tim
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

aneeshchopra, would you like me to upload my file for examination?

-T
Avatar of madoxp

ASKER

Ack, you replied as I did so... i'm sorry, where does that code go?

-T
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

Okay, I put the code on an actions layer in Scene 1 > PrintBox... i'm getting action script errors. I'm not entirely sure what you are saying by executing after upload :/

-T
Avatar of madoxp

ASKER

This all occurs within one frame.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

Alright, looks like no errors (a plus), but when activating the print out, the image doesn't appear.

So close, I can feel it :)

-T
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

I'm sorry, please find attached file. Thank you for review

http://timmason.net/upload/demo_print_and_upload.zip

-T
Avatar of madoxp

ASKER

aneeshchopra,

curious to know if you received the files or not. Explaination on what is included is a folder for where the files get dumped to, a php file which includes uploading mechanics and the fla itself.

-T
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

aneeshchopra, thank you for taking a look. I folllowed up with what you listed, it still doesn't appear to print the image on the print out. Did you get it to work?

-T
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madoxp

ASKER

Ah! My bad, I didn't catch the

trace("file:"+file);

at the end... I thank you for your help. i believe I can call this solved. Thank you! <3

-T
Avatar of madoxp

ASKER

You were amazing help. Thank you so much :)