I have a program I'm putting together in FlashDevelop that will have several different windows, with buttons on the side of each window that allow the user to go from one window to the next. The windows will not be open at the same time- essentially the background just needs to be redrawn and features added or deleted. The buttons on the side of the windows will be the same.
Right now things work just fine, except that the bitmaps are being drawn from the top left corner of the button as opposed to the top left corner of the window. I asked this question a month ago and got an answer related to scenes. I've been busy and haven't had much time to work with this, but that does not seem to work. If I understand correctly, scenes are just different portions of the timeline. I am not using Flash, otherwise this would be simple- goToAndPlay.
What am I missing here? Should I be using the Stage or Document class? Code is below, at this point I'm just drawing a black rectangle but things work the same when I do bitmaps:
From Main:
songbutton = new SongButton;
addChild(songbutton);
songbutton.x = 680;
songbutton.y = 100;
From SongButton:
public class SongButton extends MusicPlay
{
public var songsYellow:Loader;
public var songsWhite:Loader;
public function SongButton(): void
{
songsYellow = new Loader();
songsYellow.load(new URLRequest("images/SongsYellow.jpg"));
songsWhite = new Loader();
songsWhite.load(new URLRequest("images/SongsWhite.jpg"));
addChild(songsWhite);
addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
addEventListener(MouseEvent.MOUSE_UP, mouseUp);
}
private function mouseOver(e:MouseEvent):void {
addChild(songsYellow);
}
private function mouseOut(e:MouseEvent):void {
addChild(songsWhite);
}
private function mouseUp(e:MouseEvent):void {
SetMusicScreen();
}
}
From MusicPlay:
public function SetMusicScreen():void
{
graphics.beginFill(0x0);
graphics.drawRect(0, 0, 800, 550);
graphics.endFill();
}
OK, I found a way to do this. Might not be the best way, but it turns out that I can put an addEventListener(MouseEvent.MOUSE_UP, gottaMouseUp) in the calling class, add a public variable in the button class that lets me know if the correct button has been clicked, and use that in the calling class to decide which button was clicked. I knew it was something simple like that....