Some Issues about skinnablecontainer in Gui

Source: Internet
Author: User

Create a uiasset

 var uiAsset = new egret.gui.UIAsset(); uiAsset.source = "bgImage";

Add uiasset to skinnablecontainer

 var container = new egret.gui.SkinnableContainer(); container.addElement(uiAsset);

After adding the container to the stage, the uiasset is not displayed. Why?

Now I checked the skinnablecontainer code and found that

public addElement(element:IVisualElement):IVisualElement {      return this._getCurrentContentGroup().addElement(element);}public _getCurrentContentGroup():Group {      if (this.contentGroup == null) {           if (this._placeHolderGroup == null) {                this._placeHolderGroup = new Group();                this._placeHolderGroup.visible = false;                this._addToDisplayList(<DisplayObject><any>this._placeHolderGroup);           }                this._placeHolderGroup.addEventListener(                    ElementExistenceEvent.ELEMENT_ADD, this._contentGroup_elementAddedHandler, this);                this._placeHolderGroup.addEventListener(                    ElementExistenceEvent.ELEMENT_REMOVE, this._contentGroup_elementRemovedHandler, this);                return this._placeHolderGroup;      }      else {           return this.contentGroup;            }}

The addelement of skinnablecontainer is added to _ placeholdergroup if there is no contentgroup by default, while the default value of placeholdergroup is false. If contentgroup is found in partadded, the children of placeholdergroup is placed in contentgroup.

If there is no contentgroup in the skin, the subitem of all addelement of skinnablecontainer will not be displayed..

We give the container a skin.

VaR Container = new Egret. gui. skinnablecontainer (); container. skinname = testskin; container. addelement (uiasset); // Skin Class testskin extends Egret. gui. skin {private contentgroup: Egret. gui. group; Public get skinparts () {return ["contentgroup"]} Constructor () {super ();} public createchildren (): void {super. createchildren (); var group = new Egret. gui. group (); this. contentgroup = group; this. addelement (Group );}}

There is a contentgroup in testskin, so that the uiasset will be displayed.

Some Issues about skinnablecontainer in Gui

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.