# Create a mneu with oop

**URL:** <https://forum.kirupa.com/t/create-a-mneu-with-oop/329619>\
**Category:** Uncategorized\
**Created:** [September 23, 2012, 2:54pm UTC](https://forum.kirupa.com/t/create-a-mneu-with-oop/329619 "2012-09-23T14:54:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mumeric](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mumeric](https://forum.kirupa.com/u/mumeric)\
**Post date:** [September 23, 2012, 2:54pm UTC](https://forum.kirupa.com/t/create-a-mneu-with-oop/329619/1 "2012-09-23T14:54:37Z")

</div>

Hey I need help with flash oop web designs I have look great on the internet and youtube but they are tough to find something. I need help bushel a menu that is made entirely of oop and not in the timeline.

problem with menu buttons are the only works if you are on the home button.  
I behvöer help so that all buttons are dysfunctional in every direction here is an example.

I’m on the home button and go to the about button to work, when I go back to the home button works they do not. the problem is for all those buttons only work if I am on the home button, so I have to go back all the time for them to work.

Here is the code I’m using right now for my buttons.

Button.as  
package {  
import flash.display.Shape;  
import flash.display.Sprite;  
import flash.events.MouseEvent;  
import flash.text.TextField;  
import flash.text.TextFormat;

```
public class Buttons extends Sprite {
	
	private var bgd:Shape;
	private var labelField:TextField;
	
	public function Buttons() {
		// constructor code
		bgd = new Shape();
        bgd.graphics.beginFill(0x0000FF, 2);
        bgd.graphics.drawRect(0, 0, 150, 40);
        addChild(bgd);

        labelField = new TextField();
        labelField.width = 200;
        labelField.height = 30;
        labelField.y = 5;
		labelField.x = -25;
        var format:TextFormat = new TextFormat();
        format.align = "center";
        format.size = 18;
        format.font = "Verdana";
        labelField.defaultTextFormat = format;
        addChild(labelField);

        addEventListener(MouseEvent.ROLL_OVER, onOver);
        addEventListener(MouseEvent.ROLL_OUT, onOut);

        mouseChildren = false;
        buttonMode = true;
    }
    public function setLabel(label:String):void {
        labelField.text = label;
    }
    private function onOver(e:MouseEvent):void {
        bgd.alpha = 0.8;
    }
    private function onOut(e:MouseEvent):void {
        bgd.alpha = 1;
	}

}

```

}

Main.as  
package {  
import flash.display.Shape;  
import flash.display.Sprite;  
import flash.events.MouseEvent;  
import flash.display.MovieClip;  
import flash.text.TextField;  
import flash.text.TextFormat;

```
public class Main extends MovieClip {
	
	//Pages Variabels
    private var homepage:Homepage;
	private var aboutPage:AboutPage;
	private var guestBook:GuestBook;
	private var bandsPage:BandsPage;
	private var contactPage:ContactPage;
	//Button Varaibles;
	private var homeButton:Buttons;
	private var aboutButton:Buttons;
	private var guestbookButton:Buttons;
	private var bandsButton:Buttons;
	private var newsButton:Buttons;
	private var contactButton:Buttons;
	
	
	

	public function Main() {
		// constructor code
		/ ********************************************* /
		/*Layout Design */
	    homepage = new Homepage();
		aboutPage = new AboutPage();
		guestBook = new GuestBook();
		bandsPage = new BandsPage();
		contactPage = new ContactPage();
		addChild(homepage);
		/ ********************************************* /

		/*Top meny */
		homeButton = new Buttons();
        homeButton.x = -93;
        homeButton.y = 110;
        homeButton.setLabel("Home");
        addChild(homeButton);
		homeButton.addEventListener(MouseEvent.CLICK, homeButtonClick);

```

aboutButton = new Buttons();  
aboutButton.x = 70;  
aboutButton.y = 110;  
aboutButton.setLabel(“About”);  
addChild(aboutButton);  
aboutButton.addEventListener(MouseEvent.CLICK, aboutButtonClick);

```
	//Top meny homeButton //homepage
	private function homeButtonClick(e:MouseEvent):void {
     }
	
	/ ******About Button Top Meny****** /
	private function aboutButtonClick(e:MouseEvent):void {
          //Pages
		  addChild(aboutPage);
		  removeChild(homepage)
		  //Button
		  addChild(homeButton);
		  addChild(aboutButton);
		  addChild(guestbookButton);
		  addChild(bandsButton);
		  addChild(newsButton);
		  addChild(contactButton);
    }
```
