PDA

View Full Version : add child and stage events



brndn
December 29th, 2008, 05:56 PM
Hi all
so my issue is that when my stage is resized one of my attached library items. Is side the document class called myMenu is not repositioning itself after the resize event is being called once the stage resizing event occurs.

cheers for any pointers brndn

function resizer(event:Event = null):void{
circleMenu.y = stage.stageHeight/2;
myMenu.y = stage.stageHeight/2;
}

function LOADMENU():void
{

var newMenuHolder:MenuHolder = new MenuHolder();
var myMenu = addChild( newMenuHolder);;

myMenu.y = stage.stageHeight/2;
myMenu.x = 240;

}

creatify
December 29th, 2008, 06:52 PM
this should be throwing an error - is it?

you're initalizing var mymenu with another function, you need to declare that as a class property.

.ral:cr
December 30th, 2008, 04:37 AM
in your place, i would extend MenuHolder with Sprite so you can use x and y on it.
then:


var myMenu = new MenuHolder();
addChild( myMenu);

brndn
December 30th, 2008, 04:45 AM
makes sense creatify
does not seem to be throwing an error either, odd.
anyway ill try that.

cheers

brndn
December 30th, 2008, 04:54 AM
in your place, i would extend MenuHolder with Sprite so you can use x and y on it.
then:

Cheers for the idea.
could yoiu please demonstrate how this would be done please??

.ral:cr
December 30th, 2008, 06:57 AM
class MenuHolder extends Sprite {
public function MenuHolder () {
super();
...... your rest of the code .....
}
}
when you add childs will be added to this Sprite. i don't know what your class contains but i never use graphics inside a class that do not extends Sprite.