-
Senocuar's Layout Class issue, scaling image on resize
i've been running into weird problems regarding Senocular's Layout Class. It's a nice little framework to align and scale objects in a fluid layout, though.
Some images in the background (currentContainer) don't resize all the way to fit stage's height, and sometimes they get really small in a corner.
Code:
bgLayout = new Layout(currentContainer);
bgLayout.minHeight = 600;
bgLayout.maintainAspectRatio = true;
bgLayout.percentHeight = 1;
stageLayout.addChild(bgLayout);
stageLayout.draw();
each time the currentContainer mc gets a different bitmap images (with varying dimensions) on it, it gets assigned to bgLayout , whis is added to the stageLayout.
actually, do I need to do that ? Or maybe I should remove bgLayout from stageLayout before assigning it again?
Which are the best practices here?
Does anybody knows a class that do this job ?
Here is the context in which the code above finds itself:
Code:
private function onBackgroundLoaded(e:Event):void
{
switchContainers();
loader.getBitmap("bg").smoothing = true;
currentContainer.addChild(loader.getBitmap("bg"));
bgLayout = new Layout(currentContainer);
bgLayout.minHeight = 600;
bgLayout.maintainAspectRatio = true;
bgLayout.percentHeight = 1;
stageLayout.addChild(bgLayout);
stageLayout.draw();
TweenLite.to(currentContainer, 0.3, {alpha:1});
TweenLite.to(otherContainer, 0.3, {alpha:0, onComplete: cleanContainer});
loader.removeAll();
any help is greatly appreciated !
Last edited by ziriguidum; 04-08-2010 at 08:37 AM.
-
Senior Member
- The right of the People to create Flash movies shall not be infringed. -
-
i've been quite lazy, sorry.
i found a great little class here, by Julian Kussman:
http://juliankussman.com/blog/2009/0...-layout-class/
and added that to it:
Code:
// match stage dimensions;
$disp.width = _stage.stageWidth;
$disp.height = _stage.stageHeight;
if (_registeredObjects[$disp].fitStageHeight == true && _registeredObjects[$disp].fitStageWidth == true)
break;
// adjust proportionally to fill stage width or height;
if (_registeredObjects[$disp].fitStageHeight == true)
$disp.scaleX = $disp.scaleY
if (_registeredObjects[$disp].fitStageWidth == true)
$disp.scaleY = $disp.scaleX
else
( $disp.scaleX > $disp.scaleY ) ? $disp.scaleY = $disp.scaleX : $disp.scaleX = $disp.scaleY;
i want to implement also minWidth and minHeight and change the way the arguments are passed to be something more friendly like a tween call where i can pass args in no specfic order…and like "minWidth = false" instead of just true or false. maybe ...rest argument. hum..
ideas are welcome!
Last edited by ziriguidum; 04-08-2010 at 11:49 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|