So I'm having a problem with AS2 when loading a netstream video.
my_vid = _root.createEmptyMovieClip("my_vid", _root.getNextHighestDepth());
var video:Video = new Video();
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
video.attachVideo(ns);
my_vid.attachVideo(video);
and later
ns.play("http://localhost/video.mp4");
I can actually listen to the audio in background but for some reason i can't see any picture. I tried with a video only without a movieclip, and the other way around and keep listening only to audio.
I'm definitely doing something wrong but what?
Your problem is that you don't ever attach the video object to the stage. This line
my_vid.attachVideo(video);
does nothing, because MovieClip does not have a method calledattachVideo
.You need to create a video object in your library and add it to the stage. To do this, follow these steps in the IDE:
New Video...
from the dropdown.Video (ActionScript-controlled)
radio button and click OK.myVideo
).videoContainer
), then press OK.Now you have an item in your library that you can attach with code, that already contains a video object that is ready to work. Your code should be modified as follows, assuming you used the same names as I did above.