Flash AS3 - 在舞台上创建的第二个视频与第一个视频的大小相同
尽管我为每个指定了不同的宽度和高度。
vid = new Video(600, 800);
this.addChild(vid);
trace(vid.width); //600
trace(vid.height); //800
vid2 = new Video(1000, 1200);
this.addChild(vid2);
trace(vid2.width); //600
trace(vid2.height); //800
这是怎么回事?这是闪存错误吗?
Even though I specify different widths and heights for each.
vid = new Video(600, 800);
this.addChild(vid);
trace(vid.width); //600
trace(vid.height); //800
vid2 = new Video(1000, 1200);
this.addChild(vid2);
trace(vid2.width); //600
trace(vid2.height); //800
What is going on here? Is this a flash bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个错误。解决方法很简单 - 您只需在调用构造函数后手动设置宽度和高度即可。我通过创建自己的 Video 类来实现这一点,该类继承自 flash.media 中的 Video 类,如下所示:
然后只需导入此类,您的代码就应该可以工作。请注意,我正在设置尺寸的默认值;这是为了匹配父类中的默认值。
This is a bug. The workaround is simple - you just need to manually set the width and height after you have called the constructor. I do this by creating my own Video class which inherits from the one in flash.media, like so:
Then just import this class and your code should work. Notice that I am setting defaults for the dimensions; this is to match the defaults in the parent class.
这个问题可能会解决显示问题,但我们这里还有另一个灾难性问题。当您使用 BitmapData“绘制”视频内容时,我们再次遇到此问题,无论您尝试做什么,从视频中快照的图像的大小都是您为创建 FlashPlayer 实例的第一个视频组件指定的大小。
无论你做什么都解决不了问题。因此,解决方法如下:
为您创建的第一个视频对象提供视频可以拥有的最大尺寸(以像素为单位)。例如:
要对视频显示进行快照,您需要使用 Matrix 类,例如:
现在,当您使用此位图作为图像时,您将获得所需的正确图像。
如果您使用较大的视频分辨率,请增加视频大小。
This issue might solve the display problem, but we have another catastrophe problem here. When you use the BitmapData to "draw" the video content we have this issue again and no matter what you try to do the image you snapshot from the video is in the size you gave the first Video component for that FlashPlayer instance was created on.
No matter what you do it won't solve it. So the workaround is as follows:
Give the first Video object you create the max size in pixels you can have for your videos. For example:
To snapshot the video display you need to use the Matrix class, for example:
Now when you use this Bitmap as image you will get the right image you want to.
If you use larger videos resolution, increase that video size.
我刚刚在 Mac 上的 Flash CS4 中尝试了您的示例代码,但没有看到这个问题(我必须在变量名称之前添加
var
)。您使用什么版本和平台?这可能是一个错误。I just tried your sample code in Flash CS4 on the Mac and I didn't see this problem (I had to add
var
before the variable names). What version and platform are you using? It might be a bug.