A Flash Developer Resource Site

Page 1 of 4 1234 LastLast
Results 1 to 20 of 66

Thread: resize image on load

  1. #1
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156

    resize image on load

    I'm loading some jpg files and need to know if I can resize the images when I load them? For instance, if the image is 320X240 can I resize it to 180X120? I want to scale the image and make it a thumbnail. Thank you for the help.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  2. #2
    Junior Member
    Join Date
    Jul 2007
    Posts
    25
    you can use the movieclip width and height properties

  3. #3
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    I'm loading into a clip that I have in the library that is already sized but it doesn't really work. I could try sizing it again with AS once it's attached but I don't think that's going to make a difference


    Yeah, I just traced the width of the mc and it give me the width I'm trying to resize to, not the with of the image inside.
    Last edited by mneil; 07-31-2007 at 05:36 PM. Reason: oops, wrong post
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  4. #4
    Junior Member
    Join Date
    Jul 2007
    Posts
    25
    well IE is saying the php file doesn't exist...

  5. #5
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    Yeah, sorry about that. That is another post that I have on a completely unrelated problem. It pertains to what I'm doing but has nothing to do with the size of my pics. My post above explains.

    Here's my code if you care to take a gander.

    Code:
    var x:XML = new XML();
    x.ignoreWhite = true;
    
    var urls:Array = new Array();
    var whatPic:Number;
    
    x.onLoad = function(){
    		
    		var photos:Array = this.firstChild.childNodes[0].childNodes;//first child is vehicleInfo firstChild.fisrtChild=Vehicle1Pics childNodes are the photo tags
    		
    		for(i=0; i<photos.length; i++){
    			var m:MovieClip = _root.createEmptyMovieClip("subV"+i,i);
    			m._x = 46*(i+1);
    			m._y = 92*(i+1);
    			urls.push(photos[i].attributes.url);
    			m.loadMovie(urls[i]);
    		
    		};
    		m._width = 96;
    		m._height = 72;
    		holder.loadMovie(urls[0]);
    		price.text = urls[10];
    		vehicleMake.text = urls[11];
    		info.text = unescape(urls[12]);
    		whatPic = 0;
    }
    x.load("http://www.webmakerx.net/Images/Sites/Site8783/Document/usedSpecials2.xml");
    Last edited by mneil; 07-31-2007 at 05:53 PM.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  6. #6
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    flash only cares about the path to the picture and the size of the mc it doesn't care about the content of the picture....you have to use the bitmap class to resize the picture by resampleing the pixels otherwise flash will just stretch and distort the image ....when you resize and resample the image its called cropping
    ~calmchess~

  7. #7
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    Oh, duh! I've recently been playing with the bitmap class with Tweens. Thanks, I'll get this sorted out now!
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  8. #8
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    hey let me know how your progress goes and maybe i can help there are some advanced concepts we can add to your picture resize scripts after we get going ...i've been meaning to do this very thing for awhile now so if you want to work on it with me that would be great i have a few books here that will be helpful ....ask questions and i will try to find the answer no question is too stupid.
    ~calmchess~

  9. #9
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    that sounds great. Right now I haven't got too far. What I've got going is a major change in how I update pictures for work. I work for a car dealership and we have these used car specials every week that I put out. I take 5 pics of 5 cars, so 25 pics. But then I have to resize all of them in photoshop and make 2 of each so I end up with 50 pics. 25 thumbs and 25 full size. Then I edit an xml sheet to put these pics into my swf that way I don't have to open it. But, I've changed that to get the info through php. When you go to the site the swf gets a php file that reads a directory on the server and then send the pics to flash. It sorts them and puts them on. I'm going to make this very dynamic so it might be a large project to go around. This so far all works. I then only want to have to upload the 25 full size pics, and have flash resize them. Then with that I'll have flash create empty movie clips depending on the amount of pics that need to go in the swf and have them spaced dynamically and load the full size into the holder mc on release. This way I can take 12 pictures of a car if I want and have flash figure out that there are more pics and place them accordingly. Right now it's just too much work to do all that but once I get this done it will be a piece of cake.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  10. #10
    Junior Member
    Join Date
    Jul 2007
    Posts
    25
    Problem of that method is bandwidth. People will be downloading large images when they should be downloading small images.

  11. #11
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    lollerskates bandwidth is not an issue many websites use large and small photos it all depends on they type of photo being used and how many KB it is.....mneil lets not worry about bandwidth issues right now lets just get things moving with the resize and resample in flash....did you know that flash can upload pictures too? php is not the only way even though php does have its benefits.
    ~calmchess~

  12. #12
    Junior Member
    Join Date
    Jul 2007
    Posts
    25
    if you have a large photo and are displaying it as a fraction of the size, it is a waste of bandwidth. fact.

  13. #13
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    lollerskates you have included your 2 cents now either help us or move on.
    ~calmchess~

  14. #14
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    yeah, But I've kind of got that solved. I don't load all 50 pics in at once. In my original model I have 5 swf's, on for each vehicle. I cued(however you spell that) them and only loaded the image as the thumbnail was loaded in. That way the user only loaded what they wanted to see. So, even though this new way is bigger, what I'm planning on doing now is to still only load the images that are needed for that car. I'll load the images one after the other and resize them as they come in to make the thumbnail. Also, I'll add a little delay at the beginning to mask the slowness of the file(a preloader to check for at least 3 loaded images). The users that are interested in the specials I'm assuming will look at every picture of the vehicle. So, I'll preload to a screen with 5 smaller pics of these cars; the user can click the car and it will redirect them to that cars page that has been loading, and as long as there are 3 pics on that page the user will proceed without pause. And, I won't really put 12 pictures of cars up. Plus the full size pics are only about 10k each.


    I know flash can do it on its own. But, flash can't read folder contents and urls of pictures, php can. I use flash to load the files that php tells it to. So there is no editing of the swf ever once it's uploaded. Everything is handled dynamically. If I load the picture to the server in the particular folder it appears in the swf automatically. The only thing I have to do for it to work is add a number like 1 2 3 4 5 at the end of the filename so that when flash sorts it it will be in an order that I can predict so that flash knows what page to put it on.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  15. #15
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    mneil I think your idea and concept are solid and you should really continue to explore resizing pics with flash after you get that code perfected a whole lot of doors and ideas will open for you....pictures are an absolute integrial part of websites....if you want to use php along with your flash by all means feel free to make a hybrid flash site.
    ~calmchess~

  16. #16
    Junior Member
    Join Date
    Jul 2007
    Posts
    25
    Sure, I'll help. What would you like help with? I can help you with the definition of "cropping" - it's not about resizing and resampling, it's about trimming an image. I could also let you know that you need php (or some other server side technology) to read from folders to upload an image. Is there anything else you want help with? A comment like "bandwidth is not an issue" is ridiculous. Not an issue for who?

  17. #17
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    listen lollerskates i have 1,202 posts and you have 10 i have alot more exsperience and definately know what i'm talking about so post some code that is realted to this project or bugger off
    ~calmchess~

  18. #18
    Junior Member
    Join Date
    Jul 2007
    Posts
    25
    unless you own this forum i would really appreciate it if you would stop telling me to leave. i was pointing out that loading in a large image at a much smaller size pretty much goes against the 'rules' of making websites. i'm not saying people have to abide by these rules but they are there for a reason.

    why are you so aggressive?

    your number of posts does not give any indication as to the quality of your advice. any idiot can post lots on forums. calm down yeah?

  19. #19
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    Okay, I've been working on this for a bit now and I think I'll upload a swf for a preview. I've got the resizing working. I've got to clean it up still. And right now I'm reading from xml, which I think I might just keep it that way and use php to update the xml with some fancy flash cms. That way should make the parsing of info a little cleaner and efficient since I'm going to need all the extra speed I can get. What I've got now uploads the files on a blank stage at one size and makes a smaller one underneath at another size. The resampling doesn't seem to be real hard on bandwith but it is definitely cpu intensive. The reason this doesn't take much longer than the way I was doing it before is because I had to load the full images in the other way too. Plus, as I mentioned, my target audience is going to look at all the pictures because of interest.

    I understand where you're coming from loller, and I understand the difference between cropping and re-sampling pixels. I'm a designer by profession; I just got into programming awhile ago and have always liked it. So that being said; do you know of any way to trim some of the file size off once it's loaded or as it's resampling. My bitmaps are at 32 ppi and look good there, but of course the thumbs can be smaller, they don't have to look real good anyway. I want to get this done, but I want to do it right, so I need help making a weird method of adding pictures as effecient as possible. Any ideas would help.

    Oh, and right now my original pics are 400px wide so I'm resizing each image twice right now, but I won't be in the end, which should help speed this up slightly.
    Last edited by mneil; 10-11-2007 at 06:52 PM.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  20. #20
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    wonderful you are keeping up with me .....the trick is to crop the picture from the middle and resample the picture so that it is clear.....just removing pixels from the center without destroying the image that way you don't cut off and ear as easily ..this is the advanced concept that i was speaking of earlier.
    ~calmchess~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center