Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ActionScript - Controls Show/Hide on MouseOver/MouseOut

New Here ,
Aug 12, 2015 Aug 12, 2015

Hi, all!

I currently have a simple play/pause button named "pp" with a two-frame structure as follows:

Frame 1:

              stop();

               btn_2.addEventListener (MouseEvent.CLICK, stopplaying);

function stopplaying(e:MouseEvent):void {

  MovieClip(root).stop();

  stop();

  gotoAndStop(2);
}

Frame 2:

stop();

btn_1.addEventListener (MouseEvent.CLICK, startplaying);

function startplaying(e:MouseEvent):void {

  MovieClip(root).play();

  play();

}

There's also a transparent square called "backpp" that triggers showing/hiding the play/pause button on mouseevents. The code looks like this:

var btn_1, btn_2;


pp.visible = false;

backpp.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);

backpp.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);

function mouseOver(e:Event):void {

    //show the buttons if they exist

    //if(btn_1) btn_1.visible = true;

    //if(btn_2) btn_2.visible = true;

  if(pp) pp.visible = true;

}

function mouseOut(e:Event):void {

    //hide the buttons if they exist

    //if(btn_1) btn_1.visible = false;

    //if(btn_2) btn_2.visible = false;

  if(pp) pp.visible = false;

}


So, my question: whenever I don't have the mouseevent code that shows/hides the playback controls, the controls work perfectly. When I do introduce the show/hide code, the controls show and hide perfectly, but the playback controls no longer function - they essentially become a dumby graphic. Any insight would be hugely appreciated!

TOPICS
ActionScript
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2015 Aug 12, 2015

the code you showed with all the comments does nothing to btn_1 and btn_2.

once you removed the if-statement comments, btn_1 and btn_2 won't be visible and clickable at the same time.  ie, they'll never work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2015 Aug 12, 2015

Sorry for the confusion. Those lines were from earlier iterations, and I simply forgot to remove them from the post. That section should read:

var btn_1, btn_2;

pp.visible = false;

backpp.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);

backpp.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);

function mouseOver(e:Event):void {

  if(pp) pp.visible = true;

}

function mouseOut(e:Event):void {

  if(pp) pp.visible = false;

}

Where, again, "pp"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2015 Aug 12, 2015
LATEST

use a mousedown for btn_1 and btn_2 listeners.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines