的Youtube API的ActionScript 3和缩略图 [英] Youtube API Actionscript 3 and Thumbnails
问题描述
我有在AS3 Youtube的API设置 - 这一切都加载很好,但我想加载多个缩略图,然后显示出来,使用户可以点击一个观看的视频,但我有一个小麻烦做本。
I've got the Youtube API setup in AS3 - it's all loading nicely but I'd like to load multiple thumbnails and then display them so that user may click one to watch the video but I'm having a little trouble doing this.
在code,我有做这个是这样的:(其中vid_player是我的容器对象的实例名称
The code that I have for doing this is this: (where "vid_player" is the instance name of my container object.
function createFeaturedButtons(vid_player:Object, featuredVideos:Array) {
var results:Array = [];
for each (var id:String in featuredVideos) {
results.push(vid_player.getClickToPlayButton("BYjoERBzfNw"));
results.push(vid_player.getClickToPlayButton("oEB50roGOOg"));
}
return results;
}
现在我怎么得到它,以显示我的我的数组的结果吗?
Now how do I get it to display my results of my Array?
推荐答案
这应该让你的缩略图和他们之间的每5个像素添加到舞台的显示列表中的一行。在idArray项目数确定有多少按钮将加载:
This should get you the thumbnails and add them to the stage display list in a row with 5 pixels between each. The number of items in idArray defines how many buttons will load:
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 ] );
}
}
从这个程序中,当添加到code,成功地加载播放器时,输出(用我自己的视频的标识)类似于下,(我用同样的ID为所有5个大拇指):
the output from this routine, when added to code that successfully loads a player, (using my own video IDs) looks like below, (I used the same ID for all 5 thumbs):
这篇关于的Youtube API的ActionScript 3和缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!