fredag 20. november 2009

Menu and removal

I used the bottem up approch, i started whit making the start of the game a funciton, and then moved on to create a new menu. The new menu was a bit.....

I created the credit menu whit a back button, and kept the background from main menu and removed the rest.
When i wanted to go back to the main menu, the eventlistener needed a parameter, so i could not call it derectly, so i created a function in between that called it and removed credit elements.
This worked well, but a problem whit this method is that the menu music would have restarted every time i went back and forth between the menues.
so I tested to create a background on top of everything, to see if i could click on or see elements from the main menu "and i could not". this way i could create a menu on top of main menu, whitout removing it.

I created a removegame to remove the game elements when the game was lost, and call on the main menu.
i used the code:
while(numChildren > 0)
{
removeChildAt(0)
}
to remove most of the elements, then i used the same method to remove the objects innside the array's "whit pop".
after that i still got a error:
________________________
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at Script/update()
________________________
it is a hit test that, uses the hit test after the objects are removed.
and i fixet it whit using "break;" after the menu call

I went on to remove the event listeners
removeEventListener(MouseEvent.MOUSE_DOWN, Mouse_down);
but it dident remove the listener, so i used the code "stage." in front of it, because it helped when creating the event listener's "eaven tho i cant think of a logical reason why it shold help" but it did.

Ingen kommentarer:

Legg inn en kommentar