PDA

View Full Version : redimensioning sprite but not its children



ziriguidum
July 30th, 2009, 01:04 AM
Hi!

Is it possible to alter the width or height of a sprite dynamically without altering the width and height of its children ?

Even when I add children to a Sprite that had its dimensions altered dynamically, these children have their dimensions changed.

Could I do something like "sprite.resetScaleXandY" ?


menuArray[i].tab.width = subMenu.width;
menuArray[i].tab.height = 45 + subMenu.height;

menuArray[i].tab.addChild(subMenu);Here the subMenu gets resized and it shouldn't.

What do you suggest in this kind of situation?

Thanks in advance!

senocular
July 30th, 2009, 01:17 AM
All display objects represents a sum of their parts, or children. By definition, if you scale a display object, you're scaling everything that makes it up, i.e. it's children.

If you only want a certain part of a display object to be resized, then it would be that (those) part(s) that you would adjust, not the whole display object. So for example maybe your tab has a background image. If you want only that background image to scale and not everything within the tab (such as the submenu), then only scale the background image. Either that or keep the subMenu out of the tab ;)

ziriguidum
July 30th, 2009, 01:19 AM
helped a lot, thanks senocular!

ziriguidum
July 30th, 2009, 08:30 AM
that's actualy possible, using simple math. for example:

http://natejc.com/blog/

though i guess i better did it, in my case, by creating another movieclip "tab fill" that would be redimensioned.