How to make a document class visible through button click.
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Graphics;
/**
* ...
* @7111211 Alex
*/
public class Toggle extends MovieClip
{
private var button:MovieClip;
private var button2:MovieClip;
public var myClock:AnalogueClock;
public function Toggle():void
{
button = new MovieClip();
button.graphics.beginFill(0xFFCC00);
button.graphics.drawRect(0, 0, 80, 20);
button.graphics.endFill();
button.useHandCursor = true;
button.buttonMode = true;
button.mouseChildren = false;
button2 = new MovieClip();
button2.graphics.beginFill(0xCC0000);
button2.graphics.drawRect(0, 0, 80, 20);
button2.graphics.endFill();
button2.useHandCursor = true;
button2.buttonMode = true;
button2.mouseChildren = false;
button.addEventListener(MouseEvent.CLICK, buttonClickHandler);
button2.addEventListener(MouseEvent.CLICK, buttonClickHandler2);
this.addChild(button)
this.addChild(button2)
this.addChild(myClock)
}
public function buttonClickHandler(event:MouseEvent):void
{
this.button.visible = false;
this.button2.visible = true;
this.myClock.visible = false;
}
private function buttonClickHandler2(event:MouseEvent):void
{
this.button.visible = true;
this.button2.visible = false;
this.myClock.visible = true;
}
}
}
Comes up with an error saying the parameter child must be non-null, dont really know whats going on any help will be greatly appreciated
