var loadInterval:Number;
var ytplayer:MovieClip = this.createEmptyMovieClip("ytplayer",
this.getNextHighestDepth());
var dev_key:String = "YOUR_KEY_HERE";
var swf:String = "http://gdata.youtube.com/apiplayer?key="+dev_key;
//This created a connection for AS3 to talk to it
var _as3_to_as2:LocalConnection = new LocalConnection();
_as3_to_as2.connect("AS3_to_AS2");
//This is to connect to a connection started by the AS3 file
var _as2_to_as3:LocalConnection = new LocalConnection();
function checkPlayerLoaded():Void {
if (ytplayer.isPlayerLoaded()) {
//Let the AS3 file know that the player is loaded
// the function onSwfLoadComplete exists within the
AS3 file
_as2_to_as3.send("AS2_to_AS3", "onSwfLoadComplete");
clearInterval(loadInterval); // IMPORTANT - kill the interval
function onPlayerStateChange(newState:Number) {
//do something when player changes state
}
function onPlayerError(errorCode:Number) {
//do something on player error
}
var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();
ytPlayerLoader.addListener(ytPlayerLoaderListener);
ytPlayerLoader.loadClip(swf, ytplayer);
//////// CREATE EVENT HANDLERS
// These functions can be called from within the AS3 file
// This is the window where AS3 will access the API
// You can add any of the Javascript Api here
public class YouTube extends Sprite{
private var _loader:Loader;
private var _as3_to_as2:LocalConnection;
private var _as2_to_as3:LocalConnection;
public function YouTube(){
init();
}
public function init(){
Security.allowDomain('www.youtube.com'); Security.allowDomain('gdata.youtube.com');
Security.allowInsecureDomain('gdata.youtube.com');
Security.allowInsecureDomain('www.youtube.com');
_as3_to_as2 = new LocalConnection();
_as3_to_as2.addEventListener(StatusEvent.STATUS,
onLocalConnectionStatusChange);
_as2_to_as3 = new LocalConnection();
_as2_to_as3.addEventListener(StatusEvent.STATUS,
onLocalConnectionStatusChange);
_as2_to_as3.client = this; //This enables the local connection to
use functions of this class
_as2_to_as3.connect("AS2_to_AS3");
_loader = new Loader();
_loader.load(new URLRequest("yt.swf"));
}
private function stopVideo() {
_wui_to_ytl.send("AS3_to_AS2", "stopVideo");
}
private function playVideo() {
_wui_to_ytl.send("AS3_to_AS2", "playVideo");
}
private function pauseVideo() {
_wui_to_ytl.send("AS3_to_AS2", "pauseVideo");
}
public function loadVideoById(id) {
_wui_to_ytl.send("AS3_to_AS2", "loadVideoById", id);
}
public function onSwfLoadComplete(){
addChild(_loader);
}
private function onLocalConnectionStatusChange(e:StatusEvent):void{
// error was thrown without this handler
}
}
> var loadInterval:Number;
> var ytplayer:MovieClip = this.createEmptyMovieClip("ytplayer",
> this.getNextHighestDepth());
> var dev_key:String = "YOUR_KEY_HERE";
> var swf:String = "http://gdata.youtube.com/apiplayer?key="+dev_key;
> //This created a connection for AS3 to talk to it
> var _as3_to_as2:LocalConnection = new LocalConnection();
> _as3_to_as2.connect("AS3_to_AS2");
> //This is to connect to a connection started by the AS3 file
> var _as2_to_as3:LocalConnection = new LocalConnection();
> function checkPlayerLoaded():Void {
> if (ytplayer.isPlayerLoaded()) {
> //Let the AS3 file know that the player is loaded
> // the function onSwfLoadComplete exists within the
> AS3 file
> _as2_to_as3.send("AS2_to_AS3", "onSwfLoadComplete");
> clearInterval(loadInterval); // IMPORTANT - kill the interval
> function onPlayerStateChange(newState:Number) {
> //do something when player changes state
> }
> function onPlayerError(errorCode:Number) {
> //do something on player error
> }
> var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();
> ytPlayerLoader.addListener(ytPlayerLoaderListener);
> ytPlayerLoader.loadClip(swf, ytplayer);
> //////// CREATE EVENT HANDLERS
> // These functions can be called from within the AS3 file
> // This is the window where AS3 will access the API
> // You can add any of the Javascript Api here
> public class YouTube extends Sprite{
> private var _loader:Loader;
> private var _as3_to_as2:LocalConnection;
> private var _as2_to_as3:LocalConnection;
> public function YouTube(){
> init();
> }
> public function init(){
> Security.allowDomain('www.youtube.com'); > Security.allowDomain('gdata.youtube.com');
> Security.allowInsecureDomain('gdata.youtube.com');
> Security.allowInsecureDomain('www.youtube.com');
> _as3_to_as2 = new LocalConnection();
> _as3_to_as2.addEventListener(StatusEvent.STATUS,
> onLocalConnectionStatusChange);
> _as2_to_as3 = new LocalConnection();
> _as2_to_as3.addEventListener(StatusEvent.STATUS,
> onLocalConnectionStatusChange);
> _as2_to_as3.client = this; //This enables the local connection to
> use functions of this class
> _as2_to_as3.connect("AS2_to_AS3");
> _loader = new Loader();
> _loader.load(new URLRequest("yt.swf"));
> }
> private function stopVideo() {
> _wui_to_ytl.send("AS3_to_AS2", "stopVideo");
> }
> private function playVideo() {
> _wui_to_ytl.send("AS3_to_AS2", "playVideo");
> }
> private function pauseVideo() {
> _wui_to_ytl.send("AS3_to_AS2", "pauseVideo");
> }
> public function loadVideoById(id) {
> _wui_to_ytl.send("AS3_to_AS2", "loadVideoById", id);
> }
> public function onSwfLoadComplete(){
> addChild(_loader);
> }
> private function onLocalConnectionStatusChange(e:StatusEvent):void{
> // error was thrown without this handler
> }
> }
> Thanks for contributing this! If you'd like to do a blog post or
> something we can link to, we'd be happy to feature your work to a
> wider audience. :)
> Cheers,
> -Jeff
> On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > You will need to create an AS2 file that accesses the API.
> > Then you need to make a connection to that file using a
> > LoacalConnection.
> > The following the the code needed for both these files:
> > var loadInterval:Number;
> > var ytplayer:MovieClip = this.createEmptyMovieClip("ytplayer",
> > this.getNextHighestDepth());
> > var dev_key:String = "YOUR_KEY_HERE";
> > var swf:String = "http://gdata.youtube.com/apiplayer?key="+dev_key;
> > //This created a connection for AS3 to talk to it
> > var _as3_to_as2:LocalConnection = new LocalConnection();
> > _as3_to_as2.connect("AS3_to_AS2");
> > //This is to connect to a connection started by the AS3 file
> > var _as2_to_as3:LocalConnection = new LocalConnection();
> > function checkPlayerLoaded():Void {
> > if (ytplayer.isPlayerLoaded()) {
> > //Let the AS3 file know that the player is loaded
> > // the function onSwfLoadComplete exists within the
> > AS3 file
> > _as2_to_as3.send("AS2_to_AS3", "onSwfLoadComplete");
> > clearInterval(loadInterval); // IMPORTANT - kill the interval
> > function onPlayerStateChange(newState:Number) {
> > //do something when player changes state
> > }
> > function onPlayerError(errorCode:Number) {
> > //do something on player error
> > }
> > var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();
> > ytPlayerLoader.addListener(ytPlayerLoaderListener);
> > ytPlayerLoader.loadClip(swf, ytplayer);
> > //////// CREATE EVENT HANDLERS
> > // These functions can be called from within the AS3 file
> > // This is the window where AS3 will access the API
> > // You can add any of the Javascript Api here
> > public class YouTube extends Sprite{
> > private var _loader:Loader;
> > private var _as3_to_as2:LocalConnection;
> > private var _as2_to_as3:LocalConnection;
> > public function YouTube(){
> > init();
> > }
> > public function init(){
> > Security.allowDomain('www.youtube.com'); > > Security.allowDomain('gdata.youtube.com');
> > Security.allowInsecureDomain('gdata.youtube.com');
> > Security.allowInsecureDomain('www.youtube.com');
> > _as2_to_as3 = new LocalConnection();
> > _as2_to_as3.addEventListener(StatusEvent.STATUS,
> > onLocalConnectionStatusChange);
> > _as2_to_as3.client = this; //This enables the local connection to
> > use functions of this class
> > _as2_to_as3.connect("AS2_to_AS3");
Hi Matthew - thanks for sharing! I've had a play around with it and
it's great. Just one question: I'm getting a "Access of undefined
property _wui_to_ytl" error in the loadVideoById function (in the
YouTube class). Any idea why this may be happening? It's been a long
day and I've only just had time to play with this so forgive me if
I've missed something obvious ;)
Cheers,
Jassa
On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> Ok i will do a post about it later and send you the link.
> Matthew
> On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > Hi Matthew,
> > Thanks for contributing this! If you'd like to do a blog post or
> > something we can link to, we'd be happy to feature your work to a
> > wider audience. :)
> > Cheers,
> > -Jeff
> > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > You will need to create an AS2 file that accesses the API.
> > > Then you need to make a connection to that file using a
> > > LoacalConnection.
> > > The following the the code needed for both these files:
> > > var loadInterval:Number;
> > > var ytplayer:MovieClip = this.createEmptyMovieClip("ytplayer",
> > > this.getNextHighestDepth());
> > > var dev_key:String = "YOUR_KEY_HERE";
> > > var swf:String = "http://gdata.youtube.com/apiplayer?key="+dev_key;
> > > //This created a connection for AS3 to talk to it
> > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > _as3_to_as2.connect("AS3_to_AS2");
> > > //This is to connect to a connection started by the AS3 file
> > > var _as2_to_as3:LocalConnection = new LocalConnection();
> > > function checkPlayerLoaded():Void {
> > > if (ytplayer.isPlayerLoaded()) {
> > > //Let the AS3 file know that the player is loaded
> > > // the function onSwfLoadComplete exists within the
> > > AS3 file
> > > _as2_to_as3.send("AS2_to_AS3", "onSwfLoadComplete");
> > > clearInterval(loadInterval); // IMPORTANT - kill the interval
> > > function onPlayerStateChange(newState:Number) {
> > > //do something when player changes state
> > > }
> > > function onPlayerError(errorCode:Number) {
> > > //do something on player error
> > > }
> > > var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();
> > > ytPlayerLoader.addListener(ytPlayerLoaderListener);
> > > ytPlayerLoader.loadClip(swf, ytplayer);
> > > //////// CREATE EVENT HANDLERS
> > > // These functions can be called from within the AS3 file
> > > // This is the window where AS3 will access the API
> > > // You can add any of the Javascript Api here
> > > _as2_to_as3 = new LocalConnection();
> > > _as2_to_as3.addEventListener(StatusEvent.STATUS,
> > > onLocalConnectionStatusChange);
> > > _as2_to_as3.client = this; //This enables the local connection to
> > > use functions of this class
> > > _as2_to_as3.connect("AS2_to_AS3");
> > > I changed some of this code here in the editor i hope i did not break
> > > anything. Let me know if it works.
> > > You can build controls for the player right in the as 2 file...... or
> > > in the as 3 file via the functions built off of the local connection.
> Hi Matthew - thanks for sharing! I've had a play around with it and
> it's great. Just one question: I'm getting a "Access of undefined
> property _wui_to_ytl" error in the loadVideoById function (in the
> YouTube class). Any idea why this may be happening? It's been a long
> day and I've only just had time to play with this so forgive me if
> I've missed something obvious ;)
> Cheers,
> Jassa
> On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > Ok i will do a post about it later and send you the link.
> > Matthew
> > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > Hi Matthew,
> > > Thanks for contributing this! If you'd like to do a blog post or
> > > something we can link to, we'd be happy to feature your work to a
> > > wider audience. :)
> > > Cheers,
> > > -Jeff
> > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > You will need to create an AS2 file that accesses the API.
> > > > Then you need to make a connection to that file using a
> > > > LoacalConnection.
> > > > The following the the code needed for both these files:
> > > > var loadInterval:Number;
> > > > var ytplayer:MovieClip = this.createEmptyMovieClip("ytplayer",
> > > > this.getNextHighestDepth());
> > > > var dev_key:String = "YOUR_KEY_HERE";
> > > > var swf:String = "http://gdata.youtube.com/apiplayer?key="+dev_key;
> > > > //This created a connection forAS3to talk to it
> > > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > > _as3_to_as2.connect("AS3_to_AS2");
> > > > //This is to connect to a connection started by theAS3file
> > > > var _as2_to_as3:LocalConnection = new LocalConnection();
> > > > function checkPlayerLoaded():Void {
> > > > if (ytplayer.isPlayerLoaded()) {
> > > > //Let theAS3file know that the player is loaded
> > > > // the function onSwfLoadComplete exists within the
> > > >AS3file
> > > > _as2_to_as3.send("AS2_to_AS3", "onSwfLoadComplete");
> > > > clearInterval(loadInterval); // IMPORTANT - kill the interval
> > > > function onPlayerStateChange(newState:Number) {
> > > > //do something when player changes state
> > > > }
> > > > function onPlayerError(errorCode:Number) {
> > > > //do something on player error
> > > > }
> > > > var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();
> > > > ytPlayerLoader.addListener(ytPlayerLoaderListener);
> > > > ytPlayerLoader.loadClip(swf, ytplayer);
> > > > //////// CREATE EVENT HANDLERS
> > > > // These functions can be called from within theAS3file
> > > > // This is the window whereAS3will access the API
> > > > // You can add any of the Javascript Api here
> > > > I changed some of this code here in the editor i hope i did not break
> > > > anything. Let me know if it works.
> > > > You can build controls for the player right in the as 2 file...... or
> > > > in the as 3 file via the functions built off of the local connection.
<benjaminru...@googlemail.com> wrote:
> I have the same problem. Do you know the solution?
> On 26 Mrz., 07:47, jassa <ja...@viamedia.com.au> wrote:
> > Hi Matthew - thanks for sharing! I've had a play around with it and
> > it's great. Just one question: I'm getting a "Access of undefined
> > property _wui_to_ytl" error in the loadVideoById function (in the
> > YouTube class). Any idea why this may be happening? It's been a long
> > day and I've only just had time to play with this so forgive me if
> > I've missed something obvious ;)
> > Cheers,
> > Jassa
> > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > Ok i will do a post about it later and send you the link.
> > > Matthew
> > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > Hi Matthew,
> > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > something we can link to, we'd be happy to feature your work to a
> > > > wider audience. :)
> > > > Cheers,
> > > > -Jeff
> > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > You will need to create an AS2 file that accesses the API.
> > > > > Then you need to make a connection to that file using a
> > > > > LoacalConnection.
> > > > > The following the the code needed for both these files:
> > > > > var loadInterval:Number;
> > > > > var ytplayer:MovieClip = this.createEmptyMovieClip("ytplayer",
> > > > > this.getNextHighestDepth());
> > > > > var dev_key:String = "YOUR_KEY_HERE";
> > > > > var swf:String = "http://gdata.youtube.com/apiplayer?key="+dev_key;
> > > > > //This created a connection forAS3to talk to it
> > > > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > > > _as3_to_as2.connect("AS3_to_AS2");
> > > > > //This is to connect to a connection started by theAS3file
> > > > > var _as2_to_as3:LocalConnection = new LocalConnection();
> > > > > //////// CREATE EVENT HANDLERS
> > > > > // These functions can be called from within theAS3file
> > > > > // This is the window whereAS3will access the API
> > > > > // You can add any of the Javascript Api here
> > > > > I changed some of this code here in the editor i hope i did not break
> > > > > anything. Let me know if it works.
> > > > > You can build controls for the player right in the as 2 file...... or
> > > > > in the as 3 file via the functions built off of the local connection.
> Not yet - I'm hoping some one can help us out, or point us in the
> right direction.
> Let me know if you figure it out!
> Cheers,
> Jassa
> On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> <benjaminru...@googlemail.com> wrote:
> > I have the same problem. Do you know the solution?
> > On 26 Mrz., 07:47, jassa <ja...@viamedia.com.au> wrote:
> > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > it's great. Just one question: I'm getting a "Access of undefined
> > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > YouTube class). Any idea why this may be happening? It's been a long
> > > day and I've only just had time to play with this so forgive me if
> > > I've missed something obvious ;)
> > > Cheers,
> > > Jassa
> > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > Ok i will do a post about it later and send you the link.
> > > > Matthew
> > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > Hi Matthew,
> > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > something we can link to, we'd be happy to feature your work to a
> > > > > wider audience. :)
> > > > > Cheers,
> > > > > -Jeff
> > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > Then you need to make a connection to that file using a
> > > > > > LoacalConnection.
> > > > > > The following the thecodeneeded for both these files:
> > > > > > //////// CREATE EVENT HANDLERS
> > > > > > // These functions can be called from within theAS3file
> > > > > > // This is the window whereAS3will access the API
> > > > > > // You can add any of the Javascript Api here
> > > > > > I changed some of thiscodehere in the editor i hope i did not break
> > > > > > anything. Let me know if it works.
> > > > > > You can build controls for the player right in the as 2 file...... or
> > > > > > in the as 3 file via the functions built off of the local connection.
I have another problem: What kind of url does the loaderobject need? I
tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
the EventListener throws an error about the LocalConnection
([StatusEvent type="status" bubbles=false cancelable=false
eventPhase=2 code=null level="error"]).
Any idea to fix the problem?
thanks again
On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> I am sorry guys...i edited this on the fly i expected there to be an
> error somewhere.
> That variable should be _as3_to_as2 instead of _wui_to_ytl.
> That should fix that porblem. I forgot to change that variable name.
> Sorry about that.
> Matthew
> On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > Not yet - I'm hoping some one can help us out, or point us in the
> > right direction.
> > Let me know if you figure it out!
> > Cheers,
> > Jassa
> > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > <benjaminru...@googlemail.com> wrote:
> > > I have the same problem. Do you know the solution?
> > > On 26 Mrz., 07:47, jassa <ja...@viamedia.com.au> wrote:
> > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > day and I've only just had time to play with this so forgive me if
> > > > I've missed something obvious ;)
> > > > Cheers,
> > > > Jassa
> > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > Ok i will do a post about it later and send you the link.
> > > > > Matthew
> > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > Hi Matthew,
> > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > wider audience. :)
> > > > > > Cheers,
> > > > > > -Jeff
> > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > Then you need to make a connection to that file using a
> > > > > > > LoacalConnection.
> > > > > > > The following the thecodeneeded for both these files:
> > > > > > > //////// CREATE EVENT HANDLERS
> > > > > > > // These functions can be called from within theAS3file
> > > > > > > // This is the window whereAS3will access the API
> > > > > > > // You can add any of the Javascript Api here
<benjaminru...@googlemail.com> wrote:
> Nice and thanks.
> I have another problem: What kind of url does the loaderobject need? I
> tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> the EventListener throws an error about the LocalConnection
> ([StatusEvent type="status" bubbles=false cancelable=false
> eventPhase=2code=null level="error"]).
> Any idea to fix the problem?
> thanks again
> On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > I am sorry guys...i edited this on the fly i expected there to be an
> > error somewhere.
> > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > That should fix that porblem. I forgot to change that variable name.
> > Sorry about that.
> > Matthew
> > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > Not yet - I'm hoping some one can help us out, or point us in the
> > > right direction.
> > > Let me know if you figure it out!
> > > Cheers,
> > > Jassa
> > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > <benjaminru...@googlemail.com> wrote:
> > > > I have the same problem. Do you know the solution?
> > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > day and I've only just had time to play with this so forgive me if
> > > > > I've missed something obvious ;)
> > > > > Cheers,
> > > > > Jassa
> > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > Ok i will do a post about it later and send you the link.
> > > > > > Matthew
> > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > Hi Matthew,
> > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > wider audience. :)
> > > > > > > Cheers,
> > > > > > > -Jeff
> > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > LoacalConnection.
> > > > > > > > The following the thecodeneeded for both these files:
> > > > > > > > //////// CREATE EVENT HANDLERS
> > > > > > > > // These functions can be called from within theAS3file
> > > > > > > > // This is the window whereAS3will access the API
> > > > > > > > // You can add any of the Javascript Api here
> On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> <benjaminru...@googlemail.com> wrote:
> > Nice and thanks.
> > I have another problem: What kind of url does the loaderobject need? I
> > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > the EventListener throws an error about the LocalConnection
> > ([StatusEvent type="status" bubbles=false cancelable=false
> > eventPhase=2code=null level="error"]).
> > Any idea to fix the problem?
> > thanks again
> > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > I am sorry guys...i edited this on the fly i expected there to be an
> > > error somewhere.
> > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > That should fix that porblem. I forgot to change that variable name.
> > > Sorry about that.
> > > Matthew
> > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > right direction.
> > > > Let me know if you figure it out!
> > > > Cheers,
> > > > Jassa
> > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > <benjaminru...@googlemail.com> wrote:
> > > > > I have the same problem. Do you know the solution?
> > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > I've missed something obvious ;)
> > > > > > Cheers,
> > > > > > Jassa
> > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > Matthew
> > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > Hi Matthew,
> > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > wider audience. :)
> > > > > > > > Cheers,
> > > > > > > > -Jeff
> > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > LoacalConnection.
> > > > > > > > > The following the thecodeneeded for both these files:
> > > > > > > > > //This created a connection forAS3to talk to it
> > > > > > > > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > > > > > > > _as3_to_as2.connect("AS3_to_AS2");
> > > > > > > > > //This is to connect to a connection started by theAS3file
> > > > > > > > > var _as2_to_as3:LocalConnection = new LocalConnection();
> > > > > > > > > //////// CREATE EVENT HANDLERS
> > > > > > > > > // These functions can be called from within theAS3file
> > > > > > > > > // This is the window whereAS3will access the API
> > > > > > > > > // You can add any of the Javascript Api here
> I can get it to run now but I'm getting a new error:
> Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
> Any ideas?
> Thanks,
> Jassa
> On Mar 28, 3:29 am, Matthew <matthew.enci...@gmail.com> wrote:
> > I am not sure if i understand your question.
> > Matthew
> > On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> > <benjaminru...@googlemail.com> wrote:
> > > Nice and thanks.
> > > I have another problem: What kind of url does the loaderobject need? I
> > > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > > the EventListener throws an error about the LocalConnection
> > > ([StatusEvent type="status" bubbles=false cancelable=false
> > > eventPhase=2code=null level="error"]).
> > > Any idea to fix the problem?
> > > thanks again
> > > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > > I am sorry guys...i edited this on the fly i expected there to be an
> > > > error somewhere.
> > > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > > That should fix that porblem. I forgot to change that variable name.
> > > > Sorry about that.
> > > > Matthew
> > > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > > right direction.
> > > > > Let me know if you figure it out!
> > > > > Cheers,
> > > > > Jassa
> > > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > > <benjaminru...@googlemail.com> wrote:
> > > > > > I have the same problem. Do you know the solution?
> > > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > > I've missed something obvious ;)
> > > > > > > Cheers,
> > > > > > > Jassa
> > > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > > Matthew
> > > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > > Hi Matthew,
> > > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > > wider audience. :)
> > > > > > > > > Cheers,
> > > > > > > > > -Jeff
> > > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > > LoacalConnection.
> > > > > > > > > > The following the thecodeneeded for both these files:
> > > > > > > > > > //This created a connection forAS3to talk to it
> > > > > > > > > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > > > > > > > > _as3_to_as2.connect("AS3_to_AS2");
> > > > > > > > > > //This is to connect to a connection started by theAS3file
> > > > > > > > > > var _as2_to_as3:LocalConnection = new LocalConnection();
> > > > > > > > > > //////// CREATE EVENT HANDLERS
> > > > > > > > > > // These functions can be called from within theAS3file
> > > > > > > > > > // This is the window whereAS3will access the API
> > > > > > > > > > // You can add any of the Javascript Api here
Thanks so much for this... great work and much appreciated!
One small comment:
In your example you call loadVideoById() on the AS3 YouTube wrapper
class immediately after creating it in the init() function. This
doesn't always work (as the AS2 counterpart may not have loaded yet).
It's best to start invoking methods only after the onSwfLoadComplete()
is triggered.
Not sure, but this might be the problem some people mentioned on this
thread previously...
On Mar 27, 10:29 am, Matthew <matthew.enci...@gmail.com> wrote:
> On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> <benjaminru...@googlemail.com> wrote:
> > Nice and thanks.
> > I have another problem: What kind of url does the loaderobject need? I
> > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > the EventListener throws an error about the LocalConnection
> > ([StatusEvent type="status" bubbles=false cancelable=false
> > eventPhase=2code=null level="error"]).
> > Any idea to fix the problem?
> > thanks again
> > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > I am sorry guys...i edited this on the fly i expected there to be an
> > > error somewhere.
> > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > That should fix that porblem. I forgot to change that variable name.
> > > Sorry about that.
> > > Matthew
> > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > right direction.
> > > > Let me know if you figure it out!
> > > > Cheers,
> > > > Jassa
> > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > <benjaminru...@googlemail.com> wrote:
> > > > > I have the same problem. Do you know the solution?
> > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > I've missed something obvious ;)
> > > > > > Cheers,
> > > > > > Jassa
> > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > Matthew
> > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > Hi Matthew,
> > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > wider audience. :)
> > > > > > > > Cheers,
> > > > > > > > -Jeff
> > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > LoacalConnection.
> > > > > > > > > The following the thecodeneeded for both these files:
> > > > > > > > > //This created a connection forAS3to talk to it
> > > > > > > > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > > > > > > > _as3_to_as2.connect("AS3_to_AS2");
> > > > > > > > > //This is to connect to a connection started by theAS3file
> > > > > > > > > var _as2_to_as3:LocalConnection = new LocalConnection();
> > > > > > > > > //////// CREATE EVENT HANDLERS
> > > > > > > > > // These functions can be called from within theAS3file
> > > > > > > > > // This is the window whereAS3will access the API
> > > > > > > > > // You can add any of the Javascript Api here
You should just be able to compile that as a flash8 swf and itll be
good for loading in flex. I may be able to post the AS3 side of
things later if i get a chance(its heavily tailored to our specific
application right now).
Couple caveats:
1) You need to define your dev key. It can be defined as a url param
or in the code itself.
2) Make sure to call stopVideo() and disconnect() from AS3 once you're
done with the wrapper swf. This will let AS2 disconnect from AS3 to
let AS3 garbage collect the swf. I was having issues with AS3 not
being able to play more than 1 movie if the SWF file needed to be
reloaded. So if you see that problem, call disconnect over the
localconnection.
3) The funcs that return values, (getTotalBytesLoaded, getVolume,
etc..) currently don't report their results to AS3. I'm not too
familiar with how local connection works. So if someone knows how to
get the return data from localconnection function calls, please let me
know :)
On Mar 28, 10:19 am, oraboy <ora...@gmail.com> wrote:
> Thanks so much for this... great work and much appreciated!
> One small comment:
> In your example you call loadVideoById() on the AS3 YouTube wrapper
> class immediately after creating it in the init() function. This
> doesn't always work (as the AS2 counterpart may not have loaded yet).
> It's best to start invoking methods only after the onSwfLoadComplete()
> is triggered.
> Not sure, but this might be the problem some people mentioned on this
> thread previously...
> On Mar 27, 10:29 am, Matthew <matthew.enci...@gmail.com> wrote:
> > I am not sure if i understand your question.
> > Matthew
> > On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> > <benjaminru...@googlemail.com> wrote:
> > > Nice and thanks.
> > > I have another problem: What kind of url does the loaderobject need? I
> > > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > > the EventListener throws an error about the LocalConnection
> > > ([StatusEvent type="status" bubbles=false cancelable=false
> > > eventPhase=2code=null level="error"]).
> > > Any idea to fix the problem?
> > > thanks again
> > > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > > I am sorry guys...i edited this on the fly i expected there to be an
> > > > error somewhere.
> > > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > > That should fix that porblem. I forgot to change that variable name.
> > > > Sorry about that.
> > > > Matthew
> > > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > > right direction.
> > > > > Let me know if you figure it out!
> > > > > Cheers,
> > > > > Jassa
> > > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > > <benjaminru...@googlemail.com> wrote:
> > > > > > I have the same problem. Do you know the solution?
> > > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > > I've missed something obvious ;)
> > > > > > > Cheers,
> > > > > > > Jassa
> > > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > > Matthew
> > > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > > Hi Matthew,
> > > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > > wider audience. :)
> > > > > > > > > Cheers,
> > > > > > > > > -Jeff
> > > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > > LoacalConnection.
> > > > > > > > > > The following the thecodeneeded for both these files:
> > > > > > > > > > //This created a connection forAS3to talk to it
> > > > > > > > > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > > > > > > > > _as3_to_as2.connect("AS3_to_AS2");
> > > > > > > > > > //This is to connect to a connection started by theAS3file
> > > > > > > > > > var _as2_to_as3:LocalConnection = new LocalConnection();
> > > > > > > > > > //////// CREATE EVENT HANDLERS
> > > > > > > > > > // These functions can be called from within theAS3file
> > > > > > > > > > // This is the window whereAS3will access the API
> > > > > > > > > > // You can add any of the Javascript Api here
Sorry one last thing, your actionscript 3 code needs to have the
following functions defined (in addition to the stuff Matthew said
above):
/** Callback for when the player has finished loading. */
public function onSwfLoadComplete():void {
/* - This is what we're doing once the chromeless player has been
loaded. the m_ytWrapper var is just an instance of the wrapper swf in
flex.
if(m_ytWrapper != null) {
addChild(m_ytWrapper);
loadVideoById(m_videoId);
}
*/
}
/** Callback for the YouTube player status change */
public function onPlayerStateChange(newState:Number):void{
// Do some stuff in response to player state changes
}
/** Callback for when an error has occured with the YouTube player.
*/
public function onPlayerError(errorCode:Number):void{
// Handle errors, according to Geoff the errorCode is always 100
right now.
}
On Mar 28, 1:27 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> You should just be able to compile that as a flash8 swf and itll be
> good for loading in flex. I may be able to post the AS3 side of
> things later if i get a chance(its heavily tailored to our specific
> application right now).
> Couple caveats:
> 1) You need to define your dev key. It can be defined as a url param
> or in the code itself.
> 2) Make sure to call stopVideo() and disconnect() from AS3 once you're
> done with the wrapper swf. This will let AS2 disconnect from AS3 to
> let AS3 garbage collect the swf. I was having issues with AS3 not
> being able to play more than 1 movie if the SWF file needed to be
> reloaded. So if you see that problem, call disconnect over the
> localconnection.
> 3) The funcs that return values, (getTotalBytesLoaded, getVolume,
> etc..) currently don't report their results to AS3. I'm not too
> familiar with how local connection works. So if someone knows how to
> get the return data from localconnection function calls, please let me
> know :)
> On Mar 28, 10:19 am, oraboy <ora...@gmail.com> wrote:
> > Matthew,
> > Thanks so much for this... great work and much appreciated!
> > One small comment:
> > In your example you call loadVideoById() on the AS3 YouTube wrapper
> > class immediately after creating it in the init() function. This
> > doesn't always work (as the AS2 counterpart may not have loaded yet).
> > It's best to start invoking methods only after the onSwfLoadComplete()
> > is triggered.
> > Not sure, but this might be the problem some people mentioned on this
> > thread previously...
> > On Mar 27, 10:29 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > I am not sure if i understand your question.
> > > Matthew
> > > On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> > > > I have another problem: What kind of url does the loaderobject need? I
> > > > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > > > the EventListener throws an error about the LocalConnection
> > > > ([StatusEvent type="status" bubbles=false cancelable=false
> > > > eventPhase=2code=null level="error"]).
> > > > Any idea to fix the problem?
> > > > thanks again
> > > > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > I am sorry guys...i edited this on the fly i expected there to be an
> > > > > error somewhere.
> > > > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > > > That should fix that porblem. I forgot to change that variable name.
> > > > > Sorry about that.
> > > > > Matthew
> > > > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > > > right direction.
> > > > > > Let me know if you figure it out!
> > > > > > Cheers,
> > > > > > Jassa
> > > > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > > > <benjaminru...@googlemail.com> wrote:
> > > > > > > I have the same problem. Do you know the solution?
> > > > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > > > I've missed something obvious ;)
> > > > > > > > Cheers,
> > > > > > > > Jassa
> > > > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > > > Matthew
> > > > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > > > Hi Matthew,
> > > > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > > > wider audience. :)
> > > > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > > > LoacalConnection.
> > > > > > > > > > > The following the thecodeneeded for both these files:
> > > > > > > > > > > //This created a connection forAS3to talk to it
> > > > > > > > > > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > > > > > > > > > _as3_to_as2.connect("AS3_to_AS2");
> > > > > > > > > > > //This is to connect to a connection started by theAS3file
> > > > > > > > > > > var _as2_to_as3:LocalConnection = new LocalConnection();
> > > > > > > > > > > //////// CREATE EVENT HANDLERS
> > > > > > > > > > > // These functions can be called from within theAS3file
> > > > > > > > > > > // This is the window whereAS3will access the API
> > > > > > > > > > > // You can add any of the Javascript Api here
I took a look at the fla and it looks good... great job. I wish i had
more time to give away something as complete as what you did.
There is one other caveat that i should mention and it comes from
using the local connection. It seems that you can only make ONE
connection to a movie at a time using a particular id. In our case we
are using "AS3_to_AS2" like this:
_as3_to_as2.connect("AS3_to_AS2");
This means that when you finally create your application and run it in
the broswer it will only work in the first instance i.e the first
browser window opened. All other windows opened after that, that uses
the same fla file will fail to work
To get around this i created a connection manager that gives the as 2
and as 3 files unique keys for every session opened. This means that
there will have to be a connection open in the as2 file that simply
receives the keys and then is closed.
If i have time in the coming week i will try to put my code in the fla
you created and release it on my website. Unless you want to make that
addition which seems very important.
Matthew
On Mar 28, 4:40 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> Sorry one last thing, your actionscript 3codeneeds to have the
> following functions defined (in addition to the stuff Matthew said
> above):
> /** Callback for when the player has finished loading. */
> public function onSwfLoadComplete():void {
> /* - This is what we're doing once the chromeless player has been
> loaded. the m_ytWrapper var is just an instance of the wrapper swf in
> flex.
> if(m_ytWrapper != null) {
> addChild(m_ytWrapper);
> loadVideoById(m_videoId);
> }
> */
> }
> /** Callback for the YouTube player status change */
> public function onPlayerStateChange(newState:Number):void{
> // Do some stuff in response to player state changes
> }
> /** Callback for when an error has occured with the YouTube player.
> */
> public function onPlayerError(errorCode:Number):void{
> // Handle errors, according to Geoff the errorCode is always 100
> right now.
> }
> On Mar 28, 1:27 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> > You should just be able to compile that as a flash8 swf and itll be
> > good for loading in flex. I may be able to post the AS3 side of
> > things later if i get a chance(its heavily tailored to our specific
> > application right now).
> > Couple caveats:
> > 1) You need to define your dev key. It can be defined as a url param
> > or in thecodeitself.
> > 2) Make sure to call stopVideo() and disconnect() from AS3 once you're
> > done with the wrapper swf. This will let AS2 disconnect from AS3 to
> > let AS3 garbage collect the swf. I was having issues with AS3 not
> > being able to play more than 1 movie if the SWF file needed to be
> > reloaded. So if you see that problem, call disconnect over the
> > localconnection.
> > 3) The funcs that return values, (getTotalBytesLoaded, getVolume,
> > etc..) currently don't report their results to AS3. I'm not too
> > familiar with how local connection works. So if someone knows how to
> > get the return data from localconnection function calls, please let me
> > know :)
> > On Mar 28, 10:19 am, oraboy <ora...@gmail.com> wrote:
> > > Matthew,
> > > Thanks so much for this... great work and much appreciated!
> > > One small comment:
> > > In your example you call loadVideoById() on the AS3 YouTube wrapper
> > > class immediately after creating it in the init() function. This
> > > doesn't always work (as the AS2 counterpart may not have loaded yet).
> > > It's best to start invoking methods only after the onSwfLoadComplete()
> > > is triggered.
> > > Not sure, but this might be the problem some people mentioned on this
> > > thread previously...
> > > On Mar 27, 10:29 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > I am not sure if i understand your question.
> > > > Matthew
> > > > On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> > > > > I have another problem: What kind of url does the loaderobject need? I
> > > > > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > > > > the EventListener throws an error about the LocalConnection
> > > > > ([StatusEvent type="status" bubbles=false cancelable=false
> > > > > eventPhase=2code=null level="error"]).
> > > > > Any idea to fix the problem?
> > > > > thanks again
> > > > > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > I am sorry guys...i edited this on the fly i expected there to be an
> > > > > > error somewhere.
> > > > > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > > > > That should fix that porblem. I forgot to change that variable name.
> > > > > > Sorry about that.
> > > > > > Matthew
> > > > > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > > > > right direction.
> > > > > > > Let me know if you figure it out!
> > > > > > > Cheers,
> > > > > > > Jassa
> > > > > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > > > > <benjaminru...@googlemail.com> wrote:
> > > > > > > > I have the same problem. Do you know the solution?
> > > > > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > > > > I've missed something obvious ;)
> > > > > > > > > Cheers,
> > > > > > > > > Jassa
> > > > > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > > > > Matthew
> > > > > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > > > > Hi Matthew,
> > > > > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > > > > wider audience. :)
> > > > > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > > > > LoacalConnection.
> > > > > > > > > > > > The following the thecodeneeded for both these files:
> > > > > > > > > > > > //This created a connection forAS3to talk to it
> > > > > > > > > > > > var _as3_to_as2:LocalConnection = new LocalConnection();
> > > > > > > > > > > > _as3_to_as2.connect("AS3_to_AS2");
> > > > > > > > > > > > //This is to connect to a connection started by theAS3file
> > > > > > > > > > > > var _as2_to_as3:LocalConnection = new LocalConnection();
I'm trying to embed a youtube player into an existing flex
application. I've only learned AS3, so some of this discussion about
AS2 is going over my head. I think that this fla file that Ammitt so
kindly put together could be really helpful for me, but I don't know
how to use it.
Can someone please explain what I do with the fla file or the AS2
code? Can I just put it into an '.as' file? Thank you very kindly.
-dexter
On Mar 30, 5:42 pm, Matthew <matthew.enci...@gmail.com> wrote:
> I took a look at the fla and it looks good... great job. I wish i had
> more time to give away something as complete as what you did.
> There is one other caveat that i should mention and it comes from
> using the local connection. It seems that you can only make ONE
> connection to a movie at a time using a particular id. In our case we
> are using "AS3_to_AS2" like this:
> _as3_to_as2.connect("AS3_to_AS2");
> This means that when you finally create your application and run it in
> the broswer it will only work in the first instance i.e the first
> browser window opened. All other windows opened after that, that uses
> the same fla file will fail to work
> To get around this i created a connection manager that gives the as 2
> and as 3 files unique keys for every session opened. This means that
> there will have to be a connection open in the as2 file that simply
> receives the keys and then is closed.
> If i have time in the coming week i will try to put my code in the fla
> you created and release it on my website. Unless you want to make that
> addition which seems very important.
> Matthew
> On Mar 28, 4:40 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> > Sorry one last thing, your actionscript 3codeneeds to have the
> > following functions defined (in addition to the stuff Matthew said
> > above):
> > /** Callback for when theplayerhas finished loading. */
> > public function onSwfLoadComplete():void {
> > /* - This is what we're doing once the chromelessplayerhas been
> > loaded. the m_ytWrapper var is just an instance of the wrapper swf in
> > flex.
> > if(m_ytWrapper != null) {
> > addChild(m_ytWrapper);
> > loadVideoById(m_videoId);
> > }
> > */
> > }
> > /** Callback for the YouTubeplayerstatus change */
> > public function onPlayerStateChange(newState:Number):void{
> > // Do some stuff in response toplayerstate changes
> > }
> > /** Callback for when an error has occured with the YouTubeplayer.
> > */
> > public function onPlayerError(errorCode:Number):void{
> > // Handle errors, according to Geoff the errorCode is always 100
> > right now.
> > }
> > On Mar 28, 1:27 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> > > You should just be able to compile that as a flash8 swf and itll be
> > > good for loading in flex. I may be able to post theAS3side of
> > > things later if i get a chance(its heavily tailored to our specific
> > > application right now).
> > > Couple caveats:
> > > 1) You need to define your dev key. It can be defined as a url param
> > > or in thecodeitself.
> > > 2) Make sure to call stopVideo() and disconnect() fromAS3once you're
> > > done with the wrapper swf. This will let AS2 disconnect fromAS3to
> > > letAS3garbage collect the swf. I was having issues withAS3not
> > > being able to play more than 1 movie if the SWF file needed to be
> > > reloaded. So if you see that problem, call disconnect over the
> > > localconnection.
> > > 3) The funcs that return values, (getTotalBytesLoaded, getVolume,
> > > etc..) currently don't report their results toAS3. I'm not too
> > > familiar with how local connection works. So if someone knows how to
> > > get the return data from localconnection function calls, please let me
> > > know :)
> > > On Mar 28, 10:19 am, oraboy <ora...@gmail.com> wrote:
> > > > Matthew,
> > > > Thanks so much for this... great work and much appreciated!
> > > > One small comment:
> > > > In your example you call loadVideoById() on theAS3YouTube wrapper
> > > > class immediately after creating it in the init() function. This
> > > > doesn't always work (as the AS2 counterpart may not have loaded yet).
> > > > It's best to start invoking methods only after the onSwfLoadComplete()
> > > > is triggered.
> > > > Not sure, but this might be the problem some people mentioned on this
> > > > thread previously...
> > > > On Mar 27, 10:29 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > I am not sure if i understand your question.
> > > > > Matthew
> > > > > On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> > > > > > I have another problem: What kind of url does the loaderobject need? I
> > > > > > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > > > > > the EventListener throws an error about the LocalConnection
> > > > > > ([StatusEvent type="status" bubbles=false cancelable=false
> > > > > > eventPhase=2code=null level="error"]).
> > > > > > Any idea to fix the problem?
> > > > > > thanks again
> > > > > > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > I am sorry guys...i edited this on the fly i expected there to be an
> > > > > > > error somewhere.
> > > > > > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > > > > > That should fix that porblem. I forgot to change that variable name.
> > > > > > > Sorry about that.
> > > > > > > Matthew
> > > > > > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > > > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > > > > > right direction.
> > > > > > > > Let me know if you figure it out!
> > > > > > > > Cheers,
> > > > > > > > Jassa
> > > > > > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > > > > > <benjaminru...@googlemail.com> wrote:
> > > > > > > > > I have the same problem. Do you know the solution?
> > > > > > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > > > > > I've missed something obvious ;)
> > > > > > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > > > > > Matthew
> > > > > > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > > > > > Hi Matthew,
> > > > > > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > > > > > wider audience. :)
> > > > > > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > > > > > LoacalConnection.
> > > > > > > > > > > > > The following the thecodeneeded for both these files:
You need to compile the AS2 code using Flash Creative Suite (CS)...
Load CS, open the file, then Publish it (through the file menu). That
should generate an .swf file... put that file on the web-server where
your Flex application is and follow the instructions on that side.
BTW: If you are trying to embed the player in a Flex component, you
should inherit from UIComponent rather than Sprite
On Apr 3, 11:57 am, dexterpg <alexkristianw...@gmail.com> wrote:
> I'm trying to embed a youtube player into an existing flex
> application. I've only learnedAS3, so some of this discussion about
> AS2 is going over my head. I think that this fla file that Ammitt so
> kindly put together could be really helpful for me, but I don't know
> how to use it.
> Can someone please explain what I do with the fla file or the AS2
> code? Can I just put it into an '.as' file? Thank you very kindly.
> -dexter
> On Mar 30, 5:42 pm, Matthew <matthew.enci...@gmail.com> wrote:> Hey Amitt,
> > I took a look at the fla and it looks good... great job. I wish i had
> > more time to give away something as complete as what you did.
> > There is one other caveat that i should mention and it comes from
> > using the local connection. It seems that you can only make ONE
> > connection to a movie at a time using a particular id. In our case we
> > are using "AS3_to_AS2" like this:
> > _as3_to_as2.connect("AS3_to_AS2");
> > This means that when you finally create your application and run it in
> > the broswer it will only work in the first instance i.e the first
> > browser window opened. All other windows opened after that, that uses
> > the same fla file will fail to work
> > To get around this i created a connection manager that gives the as 2
> > and as 3 files unique keys for every session opened. This means that
> > there will have to be a connection open in the as2 file that simply
> > receives the keys and then is closed.
> > If i have time in the coming week i will try to put my code in the fla
> > you created and release it on my website. Unless you want to make that
> > addition which seems very important.
> > Matthew
> > On Mar 28, 4:40 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> > > Sorry one last thing, your actionscript 3codeneeds to have the
> > > following functions defined (in addition to the stuff Matthew said
> > > above):
> > > /** Callback for when theplayerhas finished loading. */
> > > public function onSwfLoadComplete():void {
> > > /* - This is what we're doing once the chromelessplayerhas been
> > > loaded. the m_ytWrapper var is just an instance of the wrapper swf in
> > > flex.
> > > if(m_ytWrapper != null) {
> > > addChild(m_ytWrapper);
> > > loadVideoById(m_videoId);
> > > }
> > > */
> > > }
> > > /** Callback for the YouTubeplayerstatus change */
> > > public function onPlayerStateChange(newState:Number):void{
> > > // Do some stuff in response toplayerstate changes
> > > }
> > > /** Callback for when an error has occured with the YouTubeplayer.
> > > */
> > > public function onPlayerError(errorCode:Number):void{
> > > // Handle errors, according to Geoff the errorCode is always 100
> > > right now.
> > > }
> > > On Mar 28, 1:27 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> > > > You should just be able to compile that as a flash8 swf and itll be
> > > > good for loading in flex. I may be able to post theAS3side of
> > > > things later if i get a chance(its heavily tailored to our specific
> > > > application right now).
> > > > Couple caveats:
> > > > 1) You need to define your dev key. It can be defined as a url param
> > > > or in thecodeitself.
> > > > 2) Make sure to call stopVideo() and disconnect() fromAS3once you're
> > > > done with the wrapper swf. This will let AS2 disconnect fromAS3to
> > > > letAS3garbage collect the swf. I was having issues withAS3not
> > > > being able to play more than 1 movie if the SWF file needed to be
> > > > reloaded. So if you see that problem, call disconnect over the
> > > > localconnection.
> > > > 3) The funcs that return values, (getTotalBytesLoaded, getVolume,
> > > > etc..) currently don't report their results toAS3. I'm not too
> > > > familiar with how local connection works. So if someone knows how to
> > > > get the return data from localconnection function calls, please let me
> > > > know :)
> > > > On Mar 28, 10:19 am, oraboy <ora...@gmail.com> wrote:
> > > > > Matthew,
> > > > > Thanks so much for this... great work and much appreciated!
> > > > > One small comment:
> > > > > In your example you call loadVideoById() on theAS3YouTube wrapper
> > > > > class immediately after creating it in the init() function. This
> > > > > doesn't always work (as the AS2 counterpart may not have loaded yet).
> > > > > It's best to start invoking methods only after the onSwfLoadComplete()
> > > > > is triggered.
> > > > > Not sure, but this might be the problem some people mentioned on this
> > > > > thread previously...
> > > > > On Mar 27, 10:29 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > I am not sure if i understand your question.
> > > > > > Matthew
> > > > > > On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> > > > > > > I have another problem: What kind of url does the loaderobject need? I
> > > > > > > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > > > > > > the EventListener throws an error about the LocalConnection
> > > > > > > ([StatusEvent type="status" bubbles=false cancelable=false
> > > > > > > eventPhase=2code=null level="error"]).
> > > > > > > Any idea to fix the problem?
> > > > > > > thanks again
> > > > > > > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > I am sorry guys...i edited this on the fly i expected there to be an
> > > > > > > > error somewhere.
> > > > > > > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > > > > > > That should fix that porblem. I forgot to change that variable name.
> > > > > > > > Sorry about that.
> > > > > > > > Matthew
> > > > > > > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > > > > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > > > > > > right direction.
> > > > > > > > > Let me know if you figure it out!
> > > > > > > > > Cheers,
> > > > > > > > > Jassa
> > > > > > > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > > > > > > <benjaminru...@googlemail.com> wrote:
> > > > > > > > > > I have the same problem. Do you know the solution?
> > > > > > > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > > > > > > I've missed something obvious ;)
> > > > > > > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > > > > > > Matthew
> > > > > > > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > > > > > > Hi Matthew,
> > > > > > > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > > > > > > wider audience. :)
> > > > > > > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > > > > > > LoacalConnection.
> > > > > > > > > > > > > > The following the thecodeneeded for both these files:
I did a "connection manager" in the way you suggested. Something like
this:
AS2:
var randy:String = Math.random(9999).toString();
var _as2_to_as3:LocalConnection = new LocalConnection();
var _as3_to_as2:LocalConnection = new LocalConnection();
_as3_to_as2.connect("AS3_to_AS2" + randy);
_as2_to_as3.send("AS2_to_AS3", "clave", randy);
AS3:
public function clave(randy:String):void {
keystring = randy;
_as2_to_as3.close();
_as2_to_as3.connect("AS2_TO_AS3" + keystring);
}
Basically interchanging a "key" to instance local connections. It
works fine (I can load more than one YouTube() instances on the same
swf), but only works loading the different instances in chain: When
the first instance loaded, then can load the second (I did it
assigning a mouse listener to create new instances with each click).
If I do:
_youtube1 = new YouTube("fKQAaPDshbc");
addChild(_youtube1);
_youtube2 = new YouTube("fKQAaPDshbc");
addChild(_youtube2);
I get the "already connected" error, because the first instance didn't
loaded yet when I call the second.
Can you avoid that with your connection manager without doing a chain
loader?
On 31 mar, 02:42, Matthew <matthew.enci...@gmail.com> wrote:
> I took a look at the fla and it looks good... great job. I wish i had
> more time to give away something as complete as what you did.
> There is one other caveat that i should mention and it comes from
> using the local connection. It seems that you can only make ONE
> connection to a movie at a time using a particular id. In our case we
> are using "AS3_to_AS2" like this:
> _as3_to_as2.connect("AS3_to_AS2");
> This means that when you finally create your application and run it in
> the broswer it will only work in the first instance i.e the first
> browser window opened. All other windows opened after that, that uses
> the same fla file will fail to work
> To get around this i created a connection manager that gives the as 2
> and as 3 files unique keys for every session opened. This means that
> there will have to be a connection open in the as2 file that simply
> receives the keys and then is closed.
> If i have time in the coming week i will try to put my code in the fla
> you created and release it on my website. Unless you want to make that
> addition which seems very important.
> Matthew
> On Mar 28, 4:40 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> > Sorry one last thing, your actionscript 3codeneeds to have the
> > following functions defined (in addition to the stuff Matthew said
> > above):
> > /** Callback for when the player has finished loading. */
> > public function onSwfLoadComplete():void {
> > /* - This is what we're doing once the chromeless player has been
> > loaded. the m_ytWrapper var is just an instance of the wrapper swf in
> > flex.
> > if(m_ytWrapper != null) {
> > addChild(m_ytWrapper);
> > loadVideoById(m_videoId);
> > }
> > */
> > }
> > /** Callback for the YouTube player status change */
> > public function onPlayerStateChange(newState:Number):void{
> > // Do some stuff in response to player state changes
> > }
> > /** Callback for when an error has occured with the YouTube player.
> > */
> > public function onPlayerError(errorCode:Number):void{
> > // Handle errors, according to Geoff the errorCode is always 100
> > right now.
> > }
> > On Mar 28, 1:27 pm, Amitt Mahajan <amitt.maha...@gmail.com> wrote:
> > > You should just be able to compile that as a flash8 swf and itll be
> > > good for loading in flex. I may be able to post the AS3 side of
> > > things later if i get a chance(its heavily tailored to our specific
> > > application right now).
> > > Couple caveats:
> > > 1) You need to define your dev key. It can be defined as a url param
> > > or in thecodeitself.
> > > 2) Make sure to call stopVideo() and disconnect() from AS3 once you're
> > > done with the wrapper swf. This will let AS2 disconnect from AS3 to
> > > let AS3 garbage collect the swf. I was having issues with AS3 not
> > > being able to play more than 1 movie if the SWF file needed to be
> > > reloaded. So if you see that problem, call disconnect over the
> > > localconnection.
> > > 3) The funcs that return values, (getTotalBytesLoaded, getVolume,
> > > etc..) currently don't report their results to AS3. I'm not too
> > > familiar with how local connection works. So if someone knows how to
> > > get the return data from localconnection function calls, please let me
> > > know :)
> > > On Mar 28, 10:19 am, oraboy <ora...@gmail.com> wrote:
> > > > Matthew,
> > > > Thanks so much for this... great work and much appreciated!
> > > > One small comment:
> > > > In your example you call loadVideoById() on the AS3 YouTube wrapper
> > > > class immediately after creating it in the init() function. This
> > > > doesn't always work (as the AS2 counterpart may not have loaded yet).
> > > > It's best to start invoking methods only after the onSwfLoadComplete()
> > > > is triggered.
> > > > Not sure, but this might be the problem some people mentioned on this
> > > > thread previously...
> > > > On Mar 27, 10:29 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > I am not sure if i understand your question.
> > > > > Matthew
> > > > > On Mar 27, 11:34 am, "benjaminru...@googlemail.com"
> > > > > > I have another problem: What kind of url does the loaderobject need? I
> > > > > > tried it with "http://gdata.youtube.com/apiplayer?key="+dev_key but
> > > > > > the EventListener throws an error about the LocalConnection
> > > > > > ([StatusEvent type="status" bubbles=false cancelable=false
> > > > > > eventPhase=2code=null level="error"]).
> > > > > > Any idea to fix the problem?
> > > > > > thanks again
> > > > > > On 27 Mrz., 16:20, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > I am sorry guys...i edited this on the fly i expected there to be an
> > > > > > > error somewhere.
> > > > > > > That variable should be _as3_to_as2 instead of _wui_to_ytl.
> > > > > > > That should fix that porblem. I forgot to change that variable name.
> > > > > > > Sorry about that.
> > > > > > > Matthew
> > > > > > > On Mar 27, 8:50 am, jassa <ja...@viamedia.com.au> wrote:
> > > > > > > > Not yet - I'm hoping some one can help us out, or point us in the
> > > > > > > > right direction.
> > > > > > > > Let me know if you figure it out!
> > > > > > > > Cheers,
> > > > > > > > Jassa
> > > > > > > > On Mar 27, 8:33 pm, "benjaminru...@googlemail.com"
> > > > > > > > <benjaminru...@googlemail.com> wrote:
> > > > > > > > > I have the same problem. Do you know the solution?
> > > > > > > > > > Hi Matthew - thanks for sharing! I've had a play around with it and
> > > > > > > > > > it's great. Just one question: I'm getting a "Access of undefined
> > > > > > > > > > property _wui_to_ytl" error in the loadVideoById function (in the
> > > > > > > > > > YouTube class). Any idea why this may be happening? It's been a long
> > > > > > > > > > day and I've only just had time to play with this so forgive me if
> > > > > > > > > > I've missed something obvious ;)
> > > > > > > > > > On Mar 18, 8:31 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > > Ok i will do a post about it later and send you the link.
> > > > > > > > > > > Matthew
> > > > > > > > > > > On Mar 17, 5:51 pm, Jeff Fisher <jfis...@youtube.com> wrote:
> > > > > > > > > > > > Hi Matthew,
> > > > > > > > > > > > Thanks for contributing this! If you'd like to do a blog post or
> > > > > > > > > > > > something we can link to, we'd be happy to feature your work to a
> > > > > > > > > > > > wider audience. :)
> > > > > > > > > > > > On Mar 17, 9:07 am, Matthew <matthew.enci...@gmail.com> wrote:
> > > > > > > > > > > > > You will need to create an AS2 file that accesses the API.
> > > > > > > > > > > > > Then you need to make a connection to that file using a
> > > > > > > > > > > > > LoacalConnection.
> > > > > > > > > > > > > The following the thecodeneeded for both these files:
Did anyone else come across this error message at runtime?
ArgumentError: Error #2082: Connect failed because the object is
already connected.
at flash.net::LocalConnection/connect()
at YouTube/init()
at YouTube()
at youtubeDC/init()
at youtubeDC()
For all of us "Flex-only" developers, I have taken the great tips here
and created a working Flex demo and a wrapper SWF that you can use
directly with Flex if you don't want to or can't make your own.
Great stuff mentioned here, just wanted to add a few things:-
1) How to instantiate many YouTube objects?
You need to have unique name for LocalConnection, that can be done by
creating pair of unique names (prefix+ Math.random () * currentTime)
in AS3 wrapper, pass these names to AS2 wrapper (for youtube player)
via query-string while making _loader.load (..). That way you can use
exchange the localconnection names.
This approach does have a disadvantage which is, AS2 wrapper swf would
not be used for next session because browser would AS2_Wrapper_SWF_URL
+ unique_query string, so for each session effective URL is different.
If your AS2 wrapper SWF is light-weight, this is no issue. So keep
your controls in AS3 to keep AS2 Wrapper SWF lightweight
2) How to get values like volume, videoBytesLoaded, videoBytesTotal,
state, etc?
There could be many ways, the way I thought, I would keep AS3 wrapper
up to date all the time, which can be done either by using a Timer in
AS2 Wrapper or event or both
a) Keep state in AS3 variable and update it whenever LC invokes state-
change handler in AS3
b) Volume - it can be done either via set-interval or other methods
which updates this
c) isMuted - Updated it whenever mute (..) method of AS3 wrapper is
called, actually you are maintaining states in AS3 instead of relying
on AS2 wrapper. I believe, you might have to sync it since YouTube
player persists the user preferences in SharedObject, so its not bad
idea to update these fields in AS3 once AS2 wrapper successfully loads
ytplayer.swf
This is what I have thought of and going to implement in the wrapper.
Thanks for sharing the code and ideas, it got me started easily.
-abdul
On Jun 9, 6:17 am, Garth <therealga...@gmail.com> wrote:
> For all of us "Flex-only" developers, I have taken the great tips here
> and created a working Flex demo and a wrapper SWF that you can use
> directly with Flex if you don't want to or can't make your own.
Good example Garth. Could be my error but the volume/mute control
works only for the first video played. Been looking into adding a
youtube feed grabber to load files dynamicaly or via user search using
the same API as you did.
> For all of us "Flex-only" developers, I have taken the great tips here
> and created a workingFlexdemo and a wrapper SWF that you can use
> directly withFlexif you don't want to or can't make your own.