开发者

How can i disable of resize MovieClip without resizing of its children (ActionScript3)

I'm creating a flash开发者_如何学运维 gallery (using flash for the first time) and found one problem. When I resize a (container) MovieClip it resizes the clip's children, so I can't resize them manualy to dimensions that I need.

How can I disable the resizing of the children of a movieclip?


Simple answer: You can't.

If you want to have a different behavior, you need to create your own mechanism for resizing (such as using a resize event listener to place the "child" MovieClips according to the container size, instead of adding them to the container's display list).


it's possible if you separate your container (let's call it a background) and its children (let's call them pictures) and place them inside a new (invisible) container sprite.

the background and pictures would all be children of the new container, so if you scale the new container then everything scales.

however, if you lock the background in at a zero child index (so it always appears behind the pictures) and make it a public property of the new container, you could scale it on it's own without also scaling the pictures since they would be siblings, not children.

since the pictures, background and container would be of the same class object, notifying the pictures when the background scaled (incase you wanted to implement a live layout) wouldn't even require a custom event, although you could create/dispatch/listen for one if you wanted.


this sounds like you have a design problem with what's inside of what. The whole point of the inherited scale is that when you place some items in a parent MC, and you start to scale the parent, ALL the children follow suit. Perhaps you need to create some non MC data object container within which to store your child MCs? Or make whatever it is you're scaling a sibling of the other items. Hard to say what you need without understanding your specific project goals. But at first glance, I'd look to move those (non resizeable) children to be their own elements.


myChild.scaleX = 1/myParent.scaleX;
myChild.scaleY = 1/myParent.scaleY;

or if the scale of the children isn't 100%, you could define their targetScale at initialisation or whenever it changes.

myChild.scaleX = myChild.targetScale/myParent.scaleX;
myChild.scaleY = myChild.targetScale/myParent.scaleY;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜