A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: [RESOLVED] Video aspect ratio problem, please help

  1. #1
    Flash Developer
    Join Date
    Feb 2006

    resolved [RESOLVED] Video aspect ratio problem, please help


    I'm creating a video (FLV) player that plays multiple FLVs. I've come across a problem: when it switches to another video of different aspect ratios, it messes up, usually all video take on the same aspect ratio of the first and when the stage is resized, it messes up completely.

    The first video is 590x300, the second and third are 720x576..

    I'm also going to give you the code (AS3) so you can see if and where I made a mistake or error.

    This function is called at the start to set up the video:
    private function setUpVideo():void {
    	// this create a new video and sets up the necessary connections and adds the necessary listeners
    	vid = new Video(_xml.video[onVideo].@width, _xml.video[onVideo].@height);
    	nc = new NetConnection();
    	ns = new NetStream(nc);
    	ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
    	ns.client = this;
    	ns.soundTransform = soundTrans;
    	_base.holder.addEventListener(Event.ENTER_FRAME, videoStatus);
    Once the video finishes playing, this function is called:
    private function startVideo(vidPath:String):void {
    	vid.smoothing = true;
    	if (firstTime) {
    		firstTime = false;
    		if (_xml.@video_start_paused == "yes") {
    		} else {
    			isPlaying = true;
    And here is the sizeVideo function that is called in the previous function; this is also called on stageResize:
    private function sizeVideo():void {
    	vid.scaleX = vid.scaleY = 1;
    	vid.x = vid.y = 0;
    	xsf = uint(_xml.video[onVideo].@width) / _base.stage.stageWidth;
    	ysf = uint(_xml.video[onVideo].@height) / _base.stage.stageHeight;
    	if (xsf < ysf) {
    		vid.height = _base.stage.stageHeight;
    		vid.scaleX = vid.scaleY;
    		vid.x = Math.round((_base.stage.stageWidth / 2) - (vid.width / 2));
    	} else {
    		vid.width = _base.stage.stageWidth;
    		vid.scaleY = vid.scaleX;
    		vid.y = Math.round((_base.stage.stageHeight / 2) - (vid.height / 2));
    Thanks for reading! Please help.
    Last edited by nonameusername; 04-27-2009 at 01:58 AM. Reason: URLs no longer valid

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center