这应该会为您提供缩略图并将它们添加到舞台显示列表中,每行之间有 5 个像素。idArray 中的项目数定义了将加载多少个按钮:
var spacing:Number = 5;
var nextX:Number = 0;
var idArray:Array = [ 'BYjoERBzfNw', 'oEB50roGOOg', 'oEB50roGOOg', 'oEB50roGOOg', 'oEB50roGOOg' ];
// this call needs to be made in the onPlayerReady() method (not listed in this example but part of the youtube player initialization process)
createThumbnails( vid_player, idArray );
function createThumbnails( vid_player:Object, videoIdArray:Array )
{
var i:int;
var results:Array = [];
for( i = 0; i < videoIdArray.length; i++ )
{
results.push( vid_player.getClickToPlayButton( videoIdArray[ i ] ) );
}
for( i = 0; i < results.length; i ++ )
{
// set whatever width and height you want the thumb to be
results[ i ].width = 50;
results[ i ].height = 50;
// set its position
results[ i ].x = nextX;
// set the next position
nextX += results[ i ].width + spacing;
addChild( results[ i ] );
}
}
当添加到成功加载播放器的代码中时,此例程的输出(使用我自己的视频 ID)如下所示,(我对所有 5 个拇指使用相同的 ID):