Skip to content
Harbs edited this page Nov 10, 2017 · 4 revisions

Contents

Transferring Beads

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

Another Tip Here

Lorem ipsum.Back to top

Clone this wiki locally