Oct
20
20
YouTube AS3 Example Using Flash Professional
Based on comments received in my previous article I’ve decided to also produce an example using Flash Professional CS4. The approach is different in some ways, but very similar in others.
View the Example:
This movie requires Flash Player 8
References:
The ActionScript 3 YouTube Chromeless Player is Now Live
YouTube ActionScript 3.0 Player API Reference
Download the Example:
YouTubeAS3_CS4.zip
View Code for Flash Professional:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | package { import flash.system.Security; import flash.display.MovieClip; import flash.display.Loader; import flash.events.Event; import flash.net.URLRequest; import fl.data.DataProvider; import fl.controls.ComboBox; import fl.controls.TextArea; public class YouTubeAS3 extends MovieClip { public var VidHolder:MovieClip; public var VidSelection:ComboBox; public var traceArea:TextArea; private var player:Object; private var loader:Loader; private var vidCollection:DataProvider; public function YouTubeAS3():void { Security.allowInsecureDomain("*"); Security.allowDomain("*"); vidCollection = new DataProvider(); vidCollection.addItem({data:"KhAplw0Z8zQ", label:"Wreckage"}); vidCollection.addItem({data:"d54AA2YWll0", label:"Window View"}); vidCollection.addItem({data:"Sv83GeuyN8A", label:"The Fearless Man"}); vidCollection.addItem({data:"9t5guYGbuZs", label:"Ephemeral"}); VidSelection.dataProvider = vidCollection; VidSelection.addEventListener(Event.CHANGE, cueVideo); loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit); loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3")); } private function onLoaderInit(event:Event):void { VidHolder.addChild(loader); loader.content.addEventListener("onReady", onPlayerReady); loader.content.addEventListener("onError", onPlayerError); loader.content.addEventListener("onStateChange", onPlayerStateChange); loader.content.addEventListener("onPlaybackQualityChange", onVideoPlaybackQualityChange); } private function onPlayerReady(event:Event):void { traceArea.text += "player ready:" + Object(event).data + "\r"; player = loader.content; player.setSize(VidHolder.width, VidHolder.height); VidSelection.selectedIndex = 0; VidSelection.dispatchEvent(new Event(Event.CHANGE)); } private function cueVideo(event:Event):void { traceArea.text += "switch to:" + event.target.selectedItem.label + "\r"; player.cueVideoById(event.target.selectedItem.data); } private function onPlayerError(event:Event):void { traceArea.text += "player error:" + Object(event).data + "\r"; } private function onPlayerStateChange(event:Event):void { traceArea.text += "player state:" + Object(event).data + "\r"; } private function onVideoPlaybackQualityChange(event:Event):void { traceArea.text += "video quality:" + Object(event).data + "\r"; } } } |
5 Comments to “YouTube AS3 Example Using Flash Professional”
Leave a comment
About this Website
Follow me on Twitter!
Tags
ActionScript
Adobe
AEL
After Effects
AIR
An Early Morning Letter Displaced
AS3
Audio
Business
conference
CS3
driver
DU
DUVAGA
Education
Embed
FITC
Flash
Flash Platform
Flash Player
Flex
FMS
FVM
Google
Hardware
HTML
Images
MAX
Mobile
Music
Personal
PHP
Premiere
Presentation
problem
Rant
sales
Security
Software
Teaching
Twitter
Video
VRA
Windows
YouTube
















[...] This post was Twitted by kevglx [...]
[...] YouTube AS3 Example Using Flash Professional | In Flagrante Delicto! [...]
[...] that YouTube released a ActionScript 3 API for their Chromeless Player. I looked at some availabe code snippets on different blogs and unfortunateley, I had to realize that the API is not really object-oriented [...]
Hi Jospeh,
thanks for your tutorial. Sometimes it is a little bit ugly to work with the You Tube Chromeless API. I like to have some type-safed objects and code-completion. That was the reason why I created some easy to use classes for Flash, Flex and Air.
http://blog.derhess.de/2009/10/27/the-new-youtube-as3-chromeless-api-in-flex-air-flash/
Maybe it is interesting for you and your readers?!
Best regards,
Flo
Thanks for this example, been looking for something so simple and all the others I have found were going into the api. Nice. Thanks.