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

How to make objects appear and then disappear with buttons...

Guest
Nov 20, 2009 Nov 20, 2009

Hi everyone,

Im currently try to construct a flash presentation that will have several different buttons on the same stage, and each button when clicked will make particular objects appear on the stage. Then once each button is clicked again it will make the particular objects connected to it disappear from the stage. Each button and the objects it makes appear / disappear is seperate from all the other buttons actions.

I would greatly appreciate anyone who could help me construct the actionscript for this presentation as im finding it quite complicated to have several things going off on the same stage at the same time. Im currently working in Flash CS4 actionscript3.

The closest example i have seen to the program i would like to create can be found using the following link...http://steffne.deviantart.com/art/Create-your-own-fastfood-meal-138790878

However my program would be simpler, e.g. clicking the bun in the program just simply adds the bun to the screen, it doesnt scroll through different types of bun.

Thank you for you help with this

Ben

TOPICS
ActionScript
9.3K
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

correct answers 1 Correct answer

LEGEND , Nov 20, 2009 Nov 20, 2009

An easy way to toggle the visibility of objects is to make the "visible" property equal to what it is currently not.  This is done using the "!" operator ... (exclamation point)

Here's an example of a button named btn coded to make a movieclip named mc change its current visible status:

function show_hide_MC(evt:MouseEvent):void {

     mc.visible = !mc.visible;

}

btn.addEventListener(MouseEvent.CLICK, show_hide_MC);

Translate
LEGEND ,
Nov 20, 2009 Nov 20, 2009

An easy way to toggle the visibility of objects is to make the "visible" property equal to what it is currently not.  This is done using the "!" operator ... (exclamation point)

Here's an example of a button named btn coded to make a movieclip named mc change its current visible status:

function show_hide_MC(evt:MouseEvent):void {

     mc.visible = !mc.visible;

}

btn.addEventListener(MouseEvent.CLICK, show_hide_MC);

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
Guest
Jan 10, 2014 Jan 10, 2014
LATEST

Is there anyway you can increment and decrement a counter using this technique as it does not seem to work when I do it this way-

function show_hide_MC(evt:MouseEvent):void {

     mc.visible = !mc.visible;

     (Counter = 0) = (Counter = 1);

}

btn.addEventListener(MouseEvent.CLICK, show_hide_MC);

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