Skip to main content
October 14, 2008
Question

Resize FLV dynamically

  • October 14, 2008
  • 1 reply
  • 358 views
I am trying to resize a FLV movie that is loaded through ActionScript 3 so that the end user would be able to switch back and forth from a smaller movie to a larger movie without starting the movie over. The movie is encoded at 320 x 240 and I would like it to scale to 640 x 480 on the click of a button instead of using the fullscreen functionality because I lose my captions when I switch to fullscreen mode. A simple toggle button would be ideal. Some help with setScale, setSize or whatever is easiest and how to use them dynamically to change a FLV from 320x240 to 640x480 and back again using a button would be greatly appreciated.
This project requires I use ActionScript 3 to load the movie instead of placing it on the stage because of the volume of movies that I am having to do. It has produced a lot of unique problems since I am really using the new FLVPlaybackCaptioning for the first time and I am having to use multiple languages for the captions. I am also just now switching from ActionScript 2 to ActionScript 3.
Currently I have a Dynamic Text field that is given an instance name of "captionText" and a combo box that is given the instance name of "language". The combo box serves as a data provider for the languages and captions that are loaded in an external XML file. The XML file contains all my caption information, language codes, as well as cuepoint information for the movie. You can view the working movie at:
Feel free to email me at jferrell@sieducation.com and thanks in advance for any help you can give me.
View the movie HERE

My code so far is below.
This topic has been closed for replies.

1 reply

October 14, 2008
Here is my solution I found. Let me know if anyone else has a better way of doing this.

In 3 Frames -
Frame 1 = Call Movie Frame
Frame 2 = smaller Movie frame
Frame 3 = larger Movie frame

Frame 1 ActionScript

import fl.video.FLVPlaybackCaptioning;
import flash.events.*
import fl.video.*;
import flash.display.*;
import fl.data.DataProvider;

var selectedLang:Object = new Object();
var currentCuePoint:Number = 0;
var captions:XMLList = new XMLList();
var languages:XMLList = new XMLList();

var my_FLVPlybk = new FLVPlayback();
my_FLVPlybk.setSize(320, 240);
my_FLVPlybk.x = 240;
my_FLVPlybk.y = 120;
addChild(my_FLVPlybk);
my_FLVPlybk.source = "_Video_360.flv";
my_FLVPlybk.skin = "SkinUnderAllNoFullNoCaption.swf";
my_FLVPlybk.skinBackgroundColor = "#6699FF";
my_FLVPlybk.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

larger.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler);
larger.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);

function mouseOverHandler(event:MouseEvent):void {
my_FLVPlybk.play();
}

function mouseDownHandler(event:MouseEvent):void {
gotoAndPlay(3);
//my_FLVPlybk.skinAutoHide = true;
my_FLVPlybk.setSize(610, 457.5);
my_FLVPlybk.x = 95;
my_FLVPlybk.y = 4;
//captionText.setSize(620, 150);
//captionText.x = 240;
//captionText.y = 520;
//language.x = 357.5;
//language.y = 550.6;
}

var dp:DataProvider = new DataProvider();
language.dataProvider = dp;
language.addEventListener(Event.CHANGE, setLanguage);

// load the XML file
var captionsXMLLoader:URLLoader = new URLLoader();
captionsXMLLoader.load(new URLRequest("_captions.xml"));
captionsXMLLoader.addEventListener(Event.COMPLETE, captionsXMLLoadedHandler);

function captionsXMLLoadedHandler(eventObj:Event):void {
var captionsXML = new XML(eventObj.currentTarget.data);
captions = captionsXML.children();
languages = captionsXML.children()[0].children();
setCuePoints();
setLanguages();
}

function setCuePoints():void {
var i:int = 0;
for each(var prop:XML in captions) {
var captionData:XML = prop;
my_FLVPlybk.addASCuePoint({name:i.toString(), time:Number(captionData.@cuepoint)});
i++;
}
}

function setLanguages():void {
var i:int=0;
for each(var prop:XML in languages) {
var languageData:XML=prop;
dp.addItem( { label:languageData.@name, data:languageData.@code } );
i++;
}
selectedLang = language.dataProvider.getItemAt(0);
}


function cp_listener(eventObject:MetadataEvent):void {
currentCuePoint = eventObject.info.name;
setCaption(currentCuePoint);
}

function setCaption(cp:Number):void {
captionText.text = captions[cp][selectedLang.data];
}

function setLanguage(evt:Object):void {
selectedLang=language.selectedItem
setCaption(currentCuePoint);
}

stop ();




Frame 2 ActionScript

larger.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler2);
larger.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler2);

function mouseOverHandler2(event:MouseEvent):void {
my_FLVPlybk.play();
}

function mouseDownHandler2(event:MouseEvent):void {
gotoAndPlay(3);
my_FLVPlybk.setSize(610, 457.5);
my_FLVPlybk.x = 95;
my_FLVPlybk.y = 4;

}

stop ();




Frame 3 ActionScript

smaller.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler1);
smaller.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler1);

function mouseOverHandler1(event:MouseEvent):void {
my_FLVPlybk.play();
}

function mouseDownHandler1(event:MouseEvent):void {
gotoAndPlay(2);
my_FLVPlybk.setSize(320, 240);
my_FLVPlybk.x = 240;
my_FLVPlybk.y = 120;
}

stop ();




Thanks,
Joel