Skip to main content
Inspiring
November 19, 2012
Answered

hide buttons outside the for-loop

  • November 19, 2012
  • 1 reply
  • 878 views

Hi,

I'm trying to hide listbuttons on fullscreen mode. But hiding only the last one.

how can i hide total buttons on fullscreen mode.

function playlistLoaded(e:Event):void {

          xmlPlaylist = new XML(urlLoader.data);

          //trace(xmlPlaylist.vid[0].@src);

    for (var i:int=0;i<xmlPlaylist.vid.length();i++) {

                              var listbutton:Button = new Button();

                              listbutton.x = 482;

                              listbutton.y = i * 19 + 1;

                              listbutton.width = 197;

                              listbutton.height = 20;

                              listbutton.label = xmlPlaylist.vid.attribute("desc");

                              listbutton.name = xmlPlaylist.vid.@src+"__"+i;

                              listbutton.addEventListener(MouseEvent.CLICK, playVidlist);

                              addChild(listbutton);

          }

}

//==================FullScreen SetUp ========================

//===========================================================

controlBar.fullscreen_btn.addEventListener(MouseEvent.CLICK, fullscreenOnClicked);

controlBar.normal_btn.addEventListener(MouseEvent.CLICK, fullscreenOffClicked);

stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullscreen);

function fullscreenOnClicked(e:MouseEvent):void

{

     stage.displayState = StageDisplayState.FULL_SCREEN;

}

function fullscreenOffClicked(e:MouseEvent):void

{

     stage.displayState = StageDisplayState.NORMAL;

}

function onFullscreen(e:FullScreenEvent):void

{

     if (e.fullScreen)

     {

         controlBar.fullscreen_btn.visible = false;

         controlBar.normal_btn.visible = true;

         //listbutton.visible = false;

         removeChild(listbutton);

         controlBar.x = (Capabilities.screenResolutionX - 480) / 2;

         controlBar.y = (Capabilities.screenResolutionY - 116);

         vidDisplay.height = (Capabilities.screenResolutionY);

         vidDisplay.width = vidDisplay.height * 4 / 3;

         vidDisplay.x= (Capabilities.screenResolutionX - vidDisplay.width) / 2;

     }

     else

     {

         controlBar.fullscreen_btn.visible = true;

         controlBar.normal_btn.visible = false;

         //listbutton.visible = true;

         addChild(listbutton);

         controlBar.x = 0;

         controlBar.y = 244;

         vidDisplay.width = 480;

         vidDisplay.height = 360;

     }

This topic has been closed for replies.
Correct answer Ned Murphy

One way to accomplish it would be to place all of the Button objects inside a container object (MovieClip or Sprite) and then make the container visible/invisible with just one line of code.

Otherwise, just like you used a loop to create the buttons, you need a loop to hide each one.  If you store each Button in an array as you create them, then you can use that array to loop thru them all and turn them visible/invisible individually.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
November 19, 2012

One way to accomplish it would be to place all of the Button objects inside a container object (MovieClip or Sprite) and then make the container visible/invisible with just one line of code.

Otherwise, just like you used a loop to create the buttons, you need a loop to hide each one.  If you store each Button in an array as you create them, then you can use that array to loop thru them all and turn them visible/invisible individually.

Inspiring
November 19, 2012

Ok,

i place all of the Button objects inside a container it's working.

Thank you..

Ned Murphy
Legend
November 19, 2012

You're welcome