Reputation: 365
I just started using the document class in flash cs6 today...
so I learned how to put things on the stage and remove it...but if I make a chain of it it doesn't really work and gives me an error here this is what I mean...
public var playbtn:SimpleButton;
public var loadbtn:SimpleButton;
public var backbtn:SimpleButton;
public function SkoolBook() {
playbtn = new play_button;
addChild(playbtn);
playbtn.x=200;
playbtn.y=200;
playbtn.addEventListener(MouseEvent.CLICK, playbutton);
function playbutton (MouseEvent) {
removeChild (playbtn);
loadbtn = new load1;
addChild(loadbtn);
loadbtn.x=500;
loadbtn.y=500;
loadbtn.addEventListener(MouseEvent.CLICK, loadbutton);
function loadbutton (MouseEvent) {
removeChild (loadbtn);
backbtn = new back_button;
addChild(backbtn);
backbtn.x=500;
backbtn.y=500;
}
}
so umm yah I just want a ssimple event that if I click on the play button that button disappears and the load button comes up..and if I click on the load button then my first stage comes up......
is there something here I am misunderstanding... why is this giving me an error?
can somebody please exaplin how to exactly carry out sequences in document class....
Upvotes: 0
Views: 163
Reputation: 6403
This should do it.
If not post the errors.
package{
import flash.events.MouseEvent;
public class SkoolBook{
public var playbtn:SimpleButton = new play_button();
public var loadbtn:SimpleButton = new load1();
public var backbtn:SimpleButton = new back_button();
public function SkoolBook() {
addChild(playbtn);
playbtn.x=200;
playbtn.y=200;
playbtn.addEventListener(MouseEvent.CLICK, playbutton);
}
public function playbutton (evt:MouseEvent) {
removeChild (playbtn);
addChild(loadbtn);
loadbtn.x=500;
loadbtn.y=500;
loadbtn.addEventListener(MouseEvent.CLICK, loadbutton);
}
public function loadbutton (evt:MouseEvent) {
removeChild (loadbtn);
addChild(backbtn);
backbtn.x=500;
backbtn.y=500;
// don't forget to add the backbtn function
//backbtn.addEventListener(MouseEvent.CLICK, XXXXXXXX);
}
}
Upvotes: 2
Reputation: 9821
You'll get errors from having MouseEvent
all alone in your function definitions:
function playbutton (MouseEvent)
Should be:
function playbutton (mEvent:MouseEvent)
This way, your function playbutton
has a name (mEvent
) to represent the instance of the MouseEvent
that is being passed into it. You'll have to do the same for function loadbutton (MouseEvent)
.
If you continue to get errors, please be more descriptive and include the error text so it's easier to help :]
Upvotes: 0