Dynamic RTMP problem

Ok I’ve got problem with adding RTMP to my tool. I wanted to make my player work with this protocol, but I encounter a “small” problem.

Each time I want to play something that comes from RTMP (as far as I know) I need to use 2 variables (file name and this rtmp server with catalogs). So sourcode looks like this:


tmpServer = "rtmp://mydomain/somethingmore/evenmore"

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(rtmpServer);
var ns:NetStream = new NetStream(connection_nc);
theVideo.attachVideo(ns);

ns.play("my_file")

Looks pretty simple, doesn’t it? But now…the problem is that those 2 variables comes a bit too late and movie won’t start. If I leave them like here… It will work, but in real enviroment those 2 things will be missing until i load them via xml. If I put everything into function and run it after loading these variables - nothing will happen. What should I do now ?