Groups | Blog | Home
all groups > flash actionscript > june 2005 >

flash actionscript : Hardcoding doLayout() in *.AS file


Snoooopy
6/20/2005 7:19:34 PM
Problem:
Currently the script (*.as file) is usefull for square or Portrait photographs
but when a 'Landscape' image is used, the code is using the width of the image
(770 in the xml file) as the vertical height of the display area.

IE: The image is 770 x 440. The display area being created, by the script in
the *.as file, is 770 x 770

I have tried for 2 days to override (hardcode) but am not having any luck.
(And am only sending myself mad ).

Hope the explaination is acurate enough.....

The working example is at http://www.lumieres.com.au/latest/index.html and the
problem is evident in the fact there is a proportional gap above and below the
image as the image is siting in an area 770x770 and not 770 x 440.




//SIMPLE VIEWER v1.7

#include "modLoaderClass.as"
#include "tween.as"

STRIPPED.....

//get data from XML
_global.gImageMaxDim = int(gXMLRoot.attributes.maxImageDimension);
// maxImageDimension is set at 770 in XML file.
// It is this that is being used to set the height of the image area to 770
(When I actually want it at 450)


STRIPPED.......



////////////////
// RESIZE
///////////////
function doLayout(){

trace("doLayout");

if (gStageWidth == undefined){
stageWidth = Stage.width;
stageHeight = Stage.height;
}else{
stageWidth = gStageWidth;
stageHeight = gStageHeight;
}

trace("stage width: " + stageWidth);

//calculate display area
//-------------------
if (navPosition == "left" || navPosition == "right"){
displayWidth = stageWidth - (stageGutter*3) - gThumbAreaWidth;
displayHeight = stageHeight- (stageGutter*2);
}else{
displayWidth = stageWidth - (stageGutter*2) ;
displayHeight = stageHeight- (stageGutter*3) - gThumbAreaHeight;
}
//get min of width/height
if (displayWidth < displayHeight){
displayDim = displayWidth;
}else{
displayDim = displayHeight;
}
// get min of disp dim and XML max dim
MaxDisplayDim = gImageMaxDim + imageBorderWidth*2;

if (MaxDisplayDim < displayDim){
displayDim = MaxDisplayDim;
}

displayDim = Math.floor(displayDim);

UIWidth = displayDim+gThumbAreaWidth + stageGutter;
UIHeight = displayDim+gThumbAreaHeight + stageGutter;

//set coords
switch (navPosition) {
case "top":
thumbAreaY = Math.floor((stageHeight - UIHeight)/2);
displayAreaY = Math.floor(thumbAreaY + gThumbAreaHeight);
displayAreaX = Math.floor((stageWidth - displayDim)/2);
thumbAreaX = Math.floor((stageWidth - gThumbAreaWidth)/2) +
gThumbAreaWidth;
break;
case "bottom":
displayAreaY = Math.floor((stageHeight - UIHeight)/2);
displayAreaX = Math.floor((stageWidth - displayDim)/2);
thumbAreaY = Math.floor(displayAreaY + displayDim);
thumbAreaX = Math.floor((stageWidth - gThumbAreaWidth)/2) +
gThumbAreaWidth;
break;
case "left":
displayAreaY = Math.floor(0);
thumbAreaX = Math.floor((stageWidth - UIWidth)/2 + gThumbAreaWidth);
thumbAreaY = Math.floor((stageHeight - gThumbAreaHeight)/2);
displayAreaX = Math.floor(thumbAreaX + stageGutter);
break;
default:
displayAreaY = Math.floor((stageHeight - displayDim)/2);
thumbAreaX = stageWidth - Math.floor((stageWidth - UIWidth)/2);
thumbAreaY = Math.floor((stageHeight - gThumbAreaHeight)/2);
displayAreaX = Math.floor(thumbAreaX -( stageGutter+displayDim+
gThumbAreaWidth));
}

gmcThumbArea._x = thumbAreaX;
gmcThumbArea._y = thumbAreaY;

gmcDisplayArea._x = displayAreaX;
gmcDisplayArea._y = displayAreaY;
gmcDisplayArea._width = displayDim;
gmcDisplayArea._height = displayDim;





******************* //THIS ABOVE IS WHAT I HAVE BEEN ADJUSTING. TO NO
AVAIL.....

STRIPPED BELOW THIS
.:}x-=V!P=-x{:.
6/20/2005 8:06:37 PM
Snoooopy
6/20/2005 8:35:22 PM
Thanks for taking a look but no not fixed......

On the link, you will notice that the image sits vertically central. I am
trying to remove the space above and below it.

If you go to the lnk and resize the window you will se the image resizes and
remains proportionally in the middle. The code is using the width (770 in xml
file) as the hieght.

Need to override the code that is creating the square stage.
AddThis Social Bookmark Button