A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Suggested dimensions?

  1. #1
    Member
    Join Date
    Jul 2002
    Posts
    92

    Suggested dimensions?

    so i have these rectangles for my pictures to load in. Now as most of you know not all pictures are rectangles that are longest lengthwise, some are longest heightwise, and some are squares. In my case, i have all my pictures load to this size:

    onClipEvent (data) {
    this._width = 150;
    this._height = 75;

    }


    which will stretch images and make some pictures viewable, until you expand them (which works perfectly to see them). However, i want to do some code like XP pictureviewer has, where if an image is too big it doesn't still stretch it fit your screen, itll scale it to the proper size. Is there a way to do this?

    Lets say its a picture of a person standing up. My way right now would strech the picture to almost beyond recoginition, can i make it so the picture will be 75px high, and the correct width, then just have blank area's to the left and right?

  2. #2
    Member
    Join Date
    Jul 2002
    Posts
    92
    also, when you click on an image you get this:

    on (press) {
    _root.fullh = getProperty("/size", _height);
    if (_root.fullh>=769) {
    _root.fullh = 768;
    }
    _root.fullw = getProperty("/size", _width);
    if (_root.fullw>=1025) {
    _root.fullw = 1024;
    }
    }

    where, size is the actual size of the movie clip loaded off screen, so flash knows how large to open the "expand" screen. But, is there a way to code this to where it can adjust for oddly shapped pictures? ie. 752x1200, because obviously the code i have no produces very wierd pictures.

  3. #3
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    the following code is what i use for resizeing pictures:

    Code:
    function resizeImage(img_inst, max_width, max_height){
    	if (img_inst._width>max_width || img_inst._height>max_height){					//if img_inst width or height is larger than max
    		var diffX:Number = img_inst._width - max_width;							//differnce between actual width and max_width
    		var diffY:Number = img_inst._height - max_height;
    		var scaleFactor:Number = diffX>=diffY ? max_width/img_inst._width : max_height/img_inst._height;	//set scalefactor depending on wich of height or widht is biggest differnce
    		img_inst._width = Math.floor(img_inst._width*scaleFactor);					//set new widht
        	img_inst._height = Math.floor(img_inst._height*scaleFactor);				//set new height
    	}
    	img_inst._x += (max_width - img_inst._width)/2;									//center img_inst
    	image._y += (max_height - img_inst._height)/2;
    	img_inst._alpha = 100;
    }
    that was to regard your first question.

    regarding you second question i'm not sure what you want to achive. pls elaborate.

  4. #4
    Member
    Join Date
    Jul 2002
    Posts
    92
    yea, the 2nd question is. Its an image gallery, so theres a thumbnail and when you click it it expands. when you rollover a thumbnail the fullsize image loads offscreen in "size" so flash can grab the width/height so when you click it the popup window will be the proper size(it kinda springs out at you). And so far i have it set to size things into a 1024x768 rectangle, which is fine for things like desktop images, but if you have a person who's image is 752x1200 or whatever i said, then it will expand the person all wrong, because it will be forcing to resize the person in the wrong dimensions.



    also, i'm still trying to get your code to work, its giving me trouble, i just paste it over the originial 2 lines of code i had right?

  5. #5
    Member
    Join Date
    Jul 2002
    Posts
    92
    ive tried many things but i cant seem to get it to work properly, it just shows the original image size

    does it still go within the onClipEvent (data) handlers?
    Last edited by BonzoHarry; 11-22-2004 at 12:00 AM.

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