-
Notifications
You must be signed in to change notification settings - Fork 116
Tips
It is possible to transfer beads from one component strand to another, but it must be done at the right point within the strand life cycle.
Consider the Royale Panel component. The Panel is a composite component that uses a Container to hold the contents of the Panel. When you right something like:
<js:Panel>
<js:beads>
<js:VerticalLayout />
</js:beads>
<js:Label text="Label inside the Panel" />
<!-- more items -->
</js:Panel>
The effect is that the label and the rest of the Panel's contents are vertically aligned. What actually happens is the VerticalLayout bead is transferred from the Panel to the Container that ultimately holds the Label and other elements.
One way to do this is within the View bead for the outer component, in this case, in the PanelView bead. The process is pretty simple:
In the strand setter function, locate the bead on the strand you want to transfer and remove it from the beads array:
var host:UIBase = UIBase(_strand);
var transferLayoutBead: IBeadLayout;
if (host.beads != null) {
for(var i:int=host.beads.length-1; i >= 0; i--) {
if (host.beads[i] is IBeadLayout) {
transferLayoutBead = host.beads[i] as IBeadLayout;
host.beads.splice(i, 1);
}
}
}
After the View bead creates the sub-component (Container for the Panel), add the transferring bead to the sub-component. You must do this BEFORE adding the sub-component to the strand via addElement.
if (!contentArea) {
contentArea = new Container();
if (transferLayoutBead != null) contentArea.addBead(transferLayoutBead);
// continue creating the contentArea
}
Add the sub-component to the strand. Now that the sub-component has the bead in its list, it will not supplant that with a bead pre-defined for the sub-component in the sub-component's style definition. Back to top
Lorem ipsum.Back to top
Apache®, Apache Royale, Royale™, and the Royale logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries.