When is video size available to Flash?

[FONT=Calibri]I’m building a video player but are running into some issues with the original size of the FLV:s. What I need to know is when the size of the FLV is available to me in the code.[/FONT]

[FONT=Calibri]Below is an simplification of the code I use.[/FONT]

[FONT=Calibri]
public class VideoPlayer [/FONT]
[FONT=Calibri]{[/FONT]
  [FONT=Calibri]private var myFlvUrl:String = "http://www.mysite.com/myFlv.flv";[/FONT]
  [FONT=Calibri]private var video:Video;                [/FONT]
  [FONT=Calibri]private var connection:NetConnection;[/FONT]
  [FONT=Calibri]private var stream:NetStream;[/FONT]
  [FONT=Calibri]private var duration:Number;[/FONT]
  
  [FONT=Calibri]/* Constructor. */[/FONT]
  [FONT=Calibri]public function VideoPlayer()[/FONT]
  [FONT=Calibri]{[/FONT]
      [FONT=Calibri]video = new Video(0, 0);[/FONT]
      [FONT=Calibri]addChild(video);[/FONT]
  
      [FONT=Calibri]connection = new NetConnection();[/FONT]
      [FONT=Calibri]connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);[/FONT]
      [FONT=Calibri]connection.connect(null);[/FONT]
  [FONT=Calibri]}[/FONT]
  
  [FONT=Calibri]private function netStatusHandler(event:NetStatusEvent):void [/FONT]
  [FONT=Calibri]{[/FONT]
      [FONT=Calibri]switch (event.info.code) [/FONT]
      [FONT=Calibri]{[/FONT]
          [FONT=Calibri]case "NetConnection.Connect.Success":[/FONT]
              [FONT=Calibri]connectStream();[/FONT]
              [FONT=Calibri]break;[/FONT]
      [FONT=Calibri]}[/FONT]
  [FONT=Calibri]}[/FONT]
  
  [FONT=Calibri]private function connectStream():void [/FONT]
  [FONT=Calibri]{[/FONT]
      [FONT=Calibri]//Create a custom "client" object to be able to catch the "onMetaData" event.[/FONT]
      [FONT=Calibri]var customClient:Object = new Object();[/FONT]
      [FONT=Calibri]customClient.onMetaData = onMetaDataHandler;[/FONT]
  
      [FONT=Calibri]stream = new NetStream(connection);[/FONT]
      [FONT=Calibri]stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);[/FONT]
      [FONT=Calibri]stream.client = customClient;[/FONT]
      [FONT=Calibri]video.attachNetStream(stream);[/FONT]
      [FONT=Calibri]stream.play(myFlvUrl);[/FONT]
  [FONT=Calibri]}[/FONT]
  
  [FONT=Calibri]private function onMetaDataHandler(metaData:Object):void[/FONT]
  [FONT=Calibri]{[/FONT]
      [FONT=Calibri]duration = metaData.duration;[/FONT]
      [FONT=Calibri]stream.pause();[/FONT]
  [FONT=Calibri]}[/FONT]
[FONT=Calibri]}[/FONT]

[FONT=Calibri]I get the size of the FLV through the following properties:[/FONT]
[FONT=Calibri]video.videoWidth[/FONT]
[FONT=Calibri]video.videoHeight[/FONT]

[FONT=Calibri]Sometimes, but not always, the size is available in the method “onMetaDataHandler” in my code above. Other times both these properties are just set to zero at that point of time. [/FONT]

[FONT=Calibri]I’ve tried to include a button which writes out the value of these properties when I click it, and the properties seem to always be set. The problem is that I need to know when I can be sure that the size is available. Is there some event I can catch or something?[/FONT]

[FONT=Calibri]Hope you can help me! :)[/FONT]