I’m currently trying to add a Vimeo video to my Flash site. After a few hours of research, I came across the correct AS3 code to do the job. Unfortunately, I am not very good with AS3 (the site is currently in AS2).
Here’s the code I have got from Vimeo that produces a working SWF in SWF video:
import flash.system.Security;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
var moogaloop:Sprite = new Sprite(); // the video player
var player_width:int=490;
var player_height:int=276;
var clip_id:int = 13112413;
function startLoad():void
{
Security.allowDomain("bitcast.vimeo.com");
var v_loader:Loader = new Loader();
var v_request = new URLRequest("http://bitcast.vimeo.com/vimeo/swf/moogaloop.swf?clip_id=" + clip_id + "&server=vimeo.com" + "&width=" + player_width + "&height=" + player_height + "&show_title=0&show_byline=0&show_portrait=0&color=cf0f01&fullscreen=0");
v_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
v_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
v_loader.load(v_request);
}
function onCompleteHandler(e:Event):void
{
// Position the player where you want it
moogaloop.x = 5;
moogaloop.y = 10;
moogaloop.addChild(e.currentTarget.content);
// Create the mask for moogaloop
var v_mask:Sprite = new Sprite();
with( v_mask.graphics ) {
beginFill(0x000000, 1);
drawRect(moogaloop.x, moogaloop.y, player_width, player_height);
endFill();
}
addChild(v_mask);
moogaloop.mask = v_mask;
addChild(moogaloop);
}
function onProgressHandler(e:ProgressEvent):void
{
var percent:Number = e.bytesLoaded / e.bytesTotal;
trace(percent);
}
startLoad();
Basically I want to take the “clip_id” variable and have it update it with an external text file so I can change the video remotely without having to update the Flash file itself.
As you can see, it’s already set up to automatically fill in the URL with whatever video number is contained in “clip_id”, I just have no idea how to code it to use an external TXT file.
Any help would be awesome!
Thanks!