Loading images and then resizing them.

  • DrGonzo
  • Beginner
  • Beginner
  • DrGonzo
  • Posts: 36

Post 3+ Months Ago

Hi all,

I have a file upload function working nicely, using the new fileReference class. I then takes the image file & downloads it to a Movie clip using loadMovie.
The problem is, that when I try to manipulate the image further - i.e applying a transformation matrix - it won't respond to anything.
i'm trying to use some code (written by http://www.senocular.com - if you haven't seen his stuff, i'd recommend a look - v.good) that gives the user a 'free transform' ability on the loaded image. I can get the code to work, when I apply it to an image that has been converted to a movie clip and is already on the stage, but not when the image is loaded into the clip using my upload/download function.
I've tried using the MovieClipLoader class, but I can't get that to even load the image. I think my problem there, is that the file name is only defined once the file has been uploaded. i.e:

Code: [ Select ]
//works
function downloadImage(file:Object):Void {
imageHolder.loadMovie("./uploaded/" + file);
}

//Doesn't work
var imageHolder:MovieClipLoader = new MovieClipLoader();
var imageHolderListener:Object = new Object();
imageHolder.addListener(mclListener);

function downloadImage(file:Object):Void {
 imageLoader.loadClip("./uploaded/" + file);
}
  1. //works
  2. function downloadImage(file:Object):Void {
  3. imageHolder.loadMovie("./uploaded/" + file);
  4. }
  5. //Doesn't work
  6. var imageHolder:MovieClipLoader = new MovieClipLoader();
  7. var imageHolderListener:Object = new Object();
  8. imageHolder.addListener(mclListener);
  9. function downloadImage(file:Object):Void {
  10.  imageLoader.loadClip("./uploaded/" + file);
  11. }


I'm going crazy over this one - apologies if this post doesn't make sense - I think I might have melted a vital part of my brain...

Any ideas most welcomed... i'm going to get a stiff drink...

Thanks,

DrGonzo
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

check first if the path for the file that you're loading is correct.
next make sure the image is a format that Flash knows (nonprogresive jpeg or gif). If these are correct .... then i dont know right now what it is, but i can give it a try and test it myself.
  • DrGonzo
  • Beginner
  • Beginner
  • DrGonzo
  • Posts: 36

Post 3+ Months Ago

Yeah, the path is correct, as it works when using loadMovie. The path I use is exactly as shown above, 'file' is a variable that is named earlier in my code.

The file type is also OK, I have tested it with .gif & nonprogressive .jpg formats, but it should work with .png & progressive .jpg formats now, as flash 8 has added this feature. When I use loadMovie it works with .png and prgressive .jpg files.

I've got it almost working now, or at least I have narrowed down the problem. It seems that You can select the movie clip when it is empty, and that shows the free transform box, if you then load an image the free transform stays, and you can manipulate the image. The problem is, that if you load an image first, you can't call up the free transform box - no matter where you click.

If you go to http://www.tshirtsetc.co.uk/10.html you will see what I mean (I have drawn a static box to show where the MC is and please note that file sizes are limited to 512kb at the mo, due to our hosts, we are moving very soon...).

If you do feel like having a test of it yourself, I can send you the source files on MSN or somthing.

Thanks,

DrGonzo.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

ye, i seen the problem.
also i notice that there's a problem when uploading images ... it doesnt always show them (especially upload the an image, then i refresh the browser and upload the image again). I think that the problems comes when you try to set the width and height of the movieclips, maybe you need to wait until the ._width is > 0 ... i know i had this problem too before, if i set the width before complete loading and processing, nothing shows up. But if i wait untill the ._width of the movie is bigger than 0, then everything worked just fine.
So, you'll need in onEnterFrame to stay untill the loadedImageMC._width > 0 This is just my thought, maybe something else. You can add my msn contact and we can talk ... though i prefer yahoo messenger :D
  • DrGonzo
  • Beginner
  • Beginner
  • DrGonzo
  • Posts: 36

Post 3+ Months Ago

Hi Ice,
Thanks so much for taking the time to look at this.
Using the if ._width > 0 idea was good, but I couldn't get it to work. It did make me think of using a percentage counter to do it and then trying

if (percentage.text >= 100) ...

That diddn't work either (I think I did it wrong though...)

I have now found a work around - I made a button to apply the transformation filter, which the user has to press once the image is uploaded. Not at all perfect, but I can work from here...

Thanks again,

DrGonzo.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.