Skip to main content
Known Participant
January 13, 2011
Answered

Get width and height from youtube player!?

  • January 13, 2011
  • 1 reply
  • 693 views

HI!

I'm trying to get size of a loaded youtube player, but it's not working (it's tracing 0):


fotoLoader = new MovieClipLoader();
fotoLoadListener = new Object();
fotoLoader.addListener(fotoLoadListener);

fotoLoadListener.onLoadInit = function(target) {
trace (target._width);

}

fotoLoader.loadClip("http://www.youtube.com/v/"+"VhRas_qrz5Y", loader);

Any tips? ~~~~~~

This topic has been closed for replies.
Correct answer Ned Murphy

It's possible that everything hasn't yet physically (? digitally) been planted despite having been loaded.  Try using a setTimeout to wait a bit before testing the dimensions.

fotoLoader = new MovieClipLoader();
fotoLoadListener = new Object();
fotoLoader.addListener(fotoLoadListener);

function traceIt(){
    trace(loader._width);
}

fotoLoadListener.onLoadInit = function(target) {
    setTimeout(traceIt, 200);
}


fotoLoader.loadClip("http://www.youtube.com/v/"+"VhRas_qrz5Y", loader);

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
January 13, 2011

It's possible that everything hasn't yet physically (? digitally) been planted despite having been loaded.  Try using a setTimeout to wait a bit before testing the dimensions.

fotoLoader = new MovieClipLoader();
fotoLoadListener = new Object();
fotoLoader.addListener(fotoLoadListener);

function traceIt(){
    trace(loader._width);
}

fotoLoadListener.onLoadInit = function(target) {
    setTimeout(traceIt, 200);
}


fotoLoader.loadClip("http://www.youtube.com/v/"+"VhRas_qrz5Y", loader);

vb_kAuthor
Known Participant
January 14, 2011

Hi!

I guessed onLoadInit would solve that matter =x.

Anyways, with the timeOut  there was a reported width, but an odd number.

For width tracing I've got 1000, for height 5064.

.-.

Any clues?

vb_kAuthor
Known Participant
January 14, 2011

OK

An update, I believe flash has a problem with the youtube player!

I have an script for the site, to dynamicly resize the pages (so my index has this HUGE background), that sets the resize scale, if i get any content bigger than it, the scale gets messed.

When the youtubeplayer is on stage my resize gets totally messed, as if it really  1000x5064!