Is there any class like VBox, HBox etc. in Flash Pro CS5?
Fle开发者_JAVA百科x has great classes for manipulating with controls in multiscreen apps like VBox, HBox, VGroup etc. But my project is in Flash Proffesional CS5. Are there any way to use these features?
Out-of-the-box, no. You can't use the Flex framework without building as a Flex project; there's a lot of code in those classes that depends on running within other Flex containers.
If you just need code to stack children vertically or horizontally (without any measure/layout passes), then the code is pretty trivial. Here's some very preliminary code for a container that will stack children vertically with no layout passes.
public class VerticalContainer extends Sprite
{
public function VerticalContainer()
{ super(); }
override public function addChild(child:DisplayObject):DisplayObject
{
child.y = height;
return super.addChild(child);
}
}
There's no protection of the child's location, so anything that has a reference on it could move it around without the VerticalContainer knowing about it. There are lots of holes to fill here, but it's a primitive example of what you could do to write these components.
精彩评论