在 flash as3 中播放多个视频
我有一个空白项目,仅播放两个视频文件。无论我如何尝试,第二个视频的大小都会与第一个视频的大小相同。请告诉我这不是 Flash 错误,我可以采取一些措施来完成此任务。这是我的文档类:
package{
import flash.display.*;
import flash.media.*;
import flash.net.*;
public class Test extends MovieClip{
public function Test(){
var nc = new NetConnection();
nc.connect(null);
var ns = new NetStream(nc);
var vid1 = new Video(120, 88);
vid1.x = 100;
vid1.y = 300;
this.addChild(vid1);
vid1.attachNetStream(ns);
ns.client = new Object();
ns.play("video/testvideo1.flv");
var ns2 = new NetStream(nc);
var vid2 = new Video(600,678);
vid2.x = 500;
vid2.y = 50;
this.addChild(vid2);
vid2.attachNetStream(ns2);
ns2.client = new Object();
ns2.play("video/testvideo2.flv");
}
}
}
如果您在 (600,768) 创建 vid2 后立即追踪其大小,它会显示 (120,88) - 第一个视频的大小。
I have a blank project that simply plays two video files. No matter what I try, the second video gets sized to the same as the first. Please tell me this isn't a Flash bug and that there's something I can do to accomplish this. Here's my document class:
package{
import flash.display.*;
import flash.media.*;
import flash.net.*;
public class Test extends MovieClip{
public function Test(){
var nc = new NetConnection();
nc.connect(null);
var ns = new NetStream(nc);
var vid1 = new Video(120, 88);
vid1.x = 100;
vid1.y = 300;
this.addChild(vid1);
vid1.attachNetStream(ns);
ns.client = new Object();
ns.play("video/testvideo1.flv");
var ns2 = new NetStream(nc);
var vid2 = new Video(600,678);
vid2.x = 500;
vid2.y = 50;
this.addChild(vid2);
vid2.attachNetStream(ns2);
ns2.client = new Object();
ns2.play("video/testvideo2.flv");
}
}
}
If you trace out the size of vid2 immediately after you create it at (600,768), it says (120,88) - the size of the first video.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看这篇博文:http://synja.com/?p=14
显然你只需在初始化后指定宽度和高度即可。所以:
Take a look at this blogpost: http://synja.com/?p=14
Apparently you just have to specify the width and height after initialization. So:
如果没有特殊原因,两个视频必须在同一个 SWF 中播放,您可以将这两个视频作为单独的 SWF 托管在单个 HTML 页面中。如果您需要在它们之间进行一些协调,您可以使用ExternalInterface轻松为此编写一个JavaScript桥。
If there is no special reason both videos have to play within the same SWF, you could just host both videos as separate SWFs in a single HTML page. If you need some coordination between them, you can write a JavaScript bridge easily for this, using ExternalInterface.
我在播放两种不同尺寸的视频时也有同样的经历。技巧是创建一个矩形绘图并将其转换为影片剪辑。为该影片剪辑分配一个实例名称。然后复制该影片剪辑并指定不同的实例名称。将 2 个影片剪辑放在舞台上,然后使用调整大小工具根据您需要的大小调整特定影片剪辑的大小。定位每个影片剪辑的实例名称以将视频加载到舞台上。
I had the same experience playing videos of two different sizes. The tricks is creating a rectangle drawing and converting it to a movie clip. Assign an instance name for that movie clip. Then make a duplicate of that movie clip and assign a different instance name. Place your 2 movie clips on stage and resize the particular movie clip according to the size you needed using the resize tool. Target each movie clip's instance name to load your video on stage.