Добрый вечер.
Как можно обратиться к объекту, созданному в другой функции?
Следующий код выдаёт 2 ошибки, связанные с обращением к нему.

Код AS3:
function someFunc ():void{
var MessageBox:MB_YN = new MB_YN();
MessageBox.name = "MB";
MessageBox.alpha = 0;
MessageBox.x = 350;
MessageBox.y = 270;
MessageBox.txt.text = "Press No To completely skip this tutorial."
stage.addChild(MessageBox);
MessageBox.y_btn.addEventListener(MouseEvent.CLICK, tutMsgBoxHandler);
MessageBox.n_btn.addEventListener(MouseEvent.CLICK, tutMsgBoxHandler);
TweenLite.to(MessageBox, 0.6, {alpha:1});
}
function tutMsgBoxHandler (e:MouseEvent):void{
stage.getChildByName("MB").y_btn.removeEventListener(MouseEvent.CLICK, tutMsgBoxHandler);
// 1119: Access of possibly undefined property y_btn through a reference with static type flash.display:DisplayObject.
stage.getChildByName("MB").n_btn.removeEventListener(MouseEvent.CLICK, tutMsgBoxHandler);
// 1119: Access of possibly undefined property n_btn through a reference with static type flash.display:DisplayObject.
if (e.target.name == "y_btn"){
TweenLite.to(stage.getChildByName("MB"), 0.6, {autoAlpha:0});
//..........
} else {
//..........
}
}
Это не созданный мной класс, а просто объект (мувиклип) в библиотеке, с Import for AS.
Внутри мувиклипа две кнопки: y_btn , n_btn и текстовое поле - txt.