How to embed youtube video in flash timeline. Flash CS6 / AS3

This article was written by in September 7, 2014, & may not be posted on other sites!
Original source url for this article: How to embed youtube video in flash timeline. Flash CS6 / AS3

How to embed youtube video in flash timeline.
There are 2 ways to embed a youtube video into your flash CS6 timeline. Use AS3 to import the youtube video directly from url, or download the video to your computer, convert it into a fla file and put the video on your timeline as any other object.

 

1. Embed youtube video in flash timeline using AS3

Use this AS3 code to embed youtube video in flash CS6, directly from URL. You don’t have to download the video, just add this code, and replace the video url to match your youtube video:
Security.allowDomain("www.youtube.com");
var videoPlayer:Object;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
function onLoaderInit(event:Event):void {
addChild(loader);
loader.content.addEventListener("onReady", onPlayerReady);
}
function onPlayerReady(event:Event):void {
videoPlayer = loader.content;
videoPlayer.setSize(640, 400); //the size of the video
videoPlayer.cueVideoByUrl("http://www.youtube.com/v/vH0oxXn4Ucs", 0);//youtube video url
}

To place the video in the center
To place the youtube video in the center of the stage, add this code to the onPlayerReady function above,
videoPlayer.x = stage.width/2; //puts the video horizontally centered
videoPlayer.y = stage.width/2; //puts the video vertically centered

To play the video right away
Simply change the code cueVideoByUrl to loadVideoByUrl

 

 

 

2. Embed youtube video in flash timeline as any other object / movieclip

Start by downloading the youtube video to your computor.

To download a youtube video, use a video download software or just download it fast and easy without any extra program using one of these methods:
1. Go to the url of the video on youtube. Just replace www.youtube… with www.ssyoutube… Simply add “ss” in the url and then click on one of the download links. “MP4 360p” or “MP4 720p”.
2. Go to http://www.youtubeinmp4.com and paste the youtube video url, then hit download.

Embedding the youtube video in Flash timeline

  1. Move your downloaded video from the downloads folder to a better location, for example your project folder.
  2. Open your flash file and create a new layer in the stage and then go to file > import > import video. Check “Embed FLV in SWF and play in timeline”. Then click browse and select your video. You will get a warning message saying that the file is not a valid FLV file, just click OK.
  3. Click the “Launch Adobe Media Encoder” button, and click OK in the alert box telling you that you will have to hit the browse button again after encoding is finished. This will open the program Media Encoder.
    How to embed youtube video in flash timeline. Flash CS6 / AS3
  4. The new converted fla video will be saved in the same folder as your original youtube video unless you change the path. Start converting your video by clicking the green play icon (img below).
    How to embed youtube video in flash timeline. Flash CS6 / AS3
  5. When video is converted just close Adobe Media Encoder. When returning to the import video box in flash, you need to click the browse button yet again, but this time to select your converted fla video instead. Then click the “next” button, and then “next” again. The youtube video is now embedded into your flash file timeline, and can be treated as any other asset. You might want to put it inside a movieclip as any other bitmap to animate it.

 

Having problems using Adobe Media Encoder?
Getting an error similar to: “please launch and activate the adobe product” when trying to use Adobe Media Encoder? Go to C:\Program Files\Adobe\Adobe Premiere Pro CS6 and copy the file amtlib.dll. Then go to C:\Program Files\Adobe\Adobe Media Encoder CS6 and delete the amtlib.dll and paste in the new amtlib.dll instead.

 

Spread the word

Facebooktwittergoogle_pluslinkedinmail

2 thoughts on “How to embed youtube video in flash timeline. Flash CS6 / AS3

  1. haxor Post author

    There must be a variable for this, something like showBtn = true. I have to look in to it! Thanx for the feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *