1 Reply Latest reply on Sep 2, 2009 2:27 PM by DeyBwah

    Newbie Question (checking to see if a component exists on displayList via addChild)

    DeyBwah

      Hi everyone,

       

      I'm trying to create an "if" conditional statement that checks to see if a component already exists via addChild().

       

      So for example...

      public function sharingVisible(event:Event):void {

        if (v_sharingurl) {

          if (......) { // Need conditional syntax that checks if sharingBookmarks has already been added to displayList via addChild().

            sharingBookmarks.embedHeight = Application.application.height;

            sharingBookmarks.embedWidth = Application.application.width;

            sharingBookmarks.embedCID = Application.application.clipID;

            sharingBookmarks.embedSharingurl = Application.application.v_sharingurl;

            sharingBookmarks.visible = true;

          } else {

            addChild(sharingBookmarks);

            sharingBookmarks.embedHeight = Application.application.height;

            sharingBookmarks.embedWidth = Application.application.width;

            sharingBookmarks.embedCID = Application.application.clipID;

            sharingBookmarks.embedSharingurl = Application.application.v_sharingurl;

            sharingBookmarks.visible = true;

          }

       

        }

      }

       

      Thanks all,

      DK

        • 1. Re: Newbie Question (checking to see if a component exists on displayList via addChild)
          DeyBwah Level 1

          Hi all,

           

          Figured out the syntax below..

           

          if (contains(sharingBookmarks)) {

                sharingBookmarks.embedHeight = Application.application.height;

                sharingBookmarks.embedWidth = Application.application.width;

                sharingBookmarks.embedCID = Application.application.clipID;

                sharingBookmarks.embedSharingurl = Application.application.v_sharingurl;

                sharingBookmarks.visible = true;

          } else {

                addChild(sharingBookmarks);

                sharingBookmarks.embedHeight = Application.application.height;

                sharingBookmarks.embedWidth = Application.application.width;

                sharingBookmarks.embedCID = Application.application.clipID;

                sharingBookmarks.embedSharingurl = Application.application.v_sharingurl;

                sharingBookmarks.visible = true;

          }

           

          Hope that helps other newbies out there.

          DK