you get a possibly undefined error because root is not what it used to be. root is now the programatic base of the structure, stage has taken its place as the holder of display objects, and thus should be referenced for adding children etc.
Stage is a dynamic property that is only given to objects that are on the displaylist. so if you are creating this class programatically this might return a null error if you just change root for stage, because it has not yet been given a stage reference because it hasnt been added to the list. try using the Event.ADDED_TO_STAGE
listener if it might not be attached to be sure that stage will not be null.
more to the point is why you are planning to attach things to the stage this way. generally it isnt a wonderful idea as the stage itself will have no reference to the child directly (though you can use getChildByName or getChildAt) and could cause problems with losing references later on. try thinking about either adding the child to the current userinterface or adding a function that will assign some sort of value to the clip being passed, for instance:
public static const PLAY_THIS:String = "the event to play the mc";
public function RPUserInterface(){
var np:nowplaying = new nowplaying();
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function getClip():nowplaying{
return np;
}
private function init(ev:Event):void{
//If you want it to play immediately, else use mouseEvent etc
dispatchEvent(new Event(PLAY_THIS));
}
on your main timeline:
var userInt:RPUserInterface = new RPUserInterface();
userInt.addEventListener(RPUserInterface.PLAY_THIS, addFromThis);
addChild(userInt);
private function addFromThis(ev:Event){
//add a global var ref here if needed.
var clip = (ev.target as RPUserInterface).getClip();
addChild(clip);
}
it might seem more complex and a waste of space, but its good practice and a lot easier to make the classes interact like this. its also a lot easier to change on the fly later.