I’ve added global references and a property “reference” in BaseUI (and ElementUI).
As I’m explaining in the tutorial, an ElementUI need a reference to set the position and the size of a DisplayObject. By default, the stage is the reference, set with the property of the ElementUI class “onStage”. If the property onStage is set to false, the reference is the parent of the DisplayObject.
This is the basic behavior of BaseUI.
You can now specify any reference in the ElementUI class. The property “reference” can be set with a DisplayObjectContainer (Stage, Sprite, MovieClip, etc) and has priority on the onStage property:
var element:ElementUI = baseUI.add(mySprite); element.reference = mySpriteContainer;
I’ve also added the same properties to the BaseUI class, they are what we can call a “global default reference”. If you set the onStage property or the reference property of the BaseUI class (not the ElementUI class), when you add a new element in the BaseUI class, those properties will assign the same values to the ElementUI instance created. It just mean if you have 50 ElementUI instances and you want to set the reference property or the onStage property on all those instances, just use the BaseUI ones before adding the DisplayObject:
var baseUI:BaseUI = new BaseUI(this); baseUI.reference = mySpriteContainer; // or baseUI.onStage = false; var element1:ElementUI = baseUI.add(mySprite); // the reference is mySpriteContainer var element2:ElementUI = baseUI.add(mySprite); // the reference is mySpriteContainer var element3:ElementUI = baseUI.add(mySprite); // the reference is mySpriteContainer
If you need to reset the reference:
element.reference = null;
As usual, I’ve updated the BaseUI main page.