外部影片剪辑仅在调整窗口大小时可见
我正在 SWF 中加载外部影片剪辑。舞台比例模式为“无比例”,舞台对齐为左上角。我正在 OnResize 事件中使用以下内容将移动剪辑的大小调整为父影片剪辑的实际高度和宽度:
object.x = stage.x;
object.y = stage.y;
object.width = stage.stageWidth;
object.height = stage.stageHeight;
但它不起作用。两个要点:
- 早期,当使用 10 之前版本的 Flash Player 时,它可以正常工作
- 。现在,只有当我调整窗口大小时,它才可以工作。我只是不明白为什么它会造成问题。
任何形式的帮助将不胜感激,因为我就是因为这个而被阻止的。我不想使用舞台的精确配合比例模式。
谢谢!
I am loading an external movie clip in my SWF. The stage scale mode is "no scale" and stage align is TOP LEFT. I am resizing move clip to the actual height and width of parent movie clip using following in OnResize event:
object.x = stage.x;
object.y = stage.y;
object.width = stage.stageWidth;
object.height = stage.stageHeight;
But it's not working. Two important points:
- It was working earlier when was using Flash Player older than 10.
- Now, it works only when I resize the window. I just can't understand why it's creating the problem.
Any help of any sort would be highly appreciated as I am blocked just coz of this. I don't want to use exact fit scale mode of the stage.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请记住,object.height 和 object.width 指的是对象上的活动内容,具体取决于您导入它的方式:
上面的代码可以工作,但您可能会将宽度拉伸到内容被拉伸的程度场景,追踪宽度和高度。
编辑:
对于 YouTube 来说,它会是这样的:
Remember that the object.height and object.width refers to the active content on the object depending on how you're importing it:
That code above works, but you may be stretching the width to the point where the content is being stretched out of the scene, trace the width and height.
EDIT:
for youtube it would be something like this:
您可能在将对象添加到舞台之前应用转换,因此舞台引用为 null 且/或它的属性为 null。您应该将事件侦听器添加到对象 Event.ADDED_TO_STAGE,然后在事件的回调中应用您的转换。此外,您不需要通过 object.stage 访问 stage 对象,stage 应该是一个静态实体,您可以从对象内部或外部调用它。如果您无法通过在应用此转换的范围内简单地键入“stage”来访问该阶段,那么这可能是问题的原因。就像我说的,尝试使用 ADDED_TO_STAGE 事件,在该回调中应用转换,如果我是对的,一切都应该没问题。此外,当您尝试像上面发布的那样强制转换对象时,请使用“as”关键字。示例:
您关于 YouTube 播放器“不支持此方法”的说法实际上没有意义,因为这与 YouTube 或任何其他外部 API 无关。强制转换/类型转换是一种编程语言功能。该语句成立的唯一情况是,youtube 播放器与 MovieClip 对象没有共同的内在性,在这种情况下,您会在运行时(在某些情况下甚至可能是编译时)收到类型强制错误,告诉您只需无法将一个对象转换为完全不同的对象。无论如何希望这会有所帮助。
You're probably applying the transformation before the object has been added to the stage and thus, the stage reference is null and or its properties are null. You should add the event listener to the object Event.ADDED_TO_STAGE and then within the callback of the event, apply your transformations. Also you don't need to access the stage object through object.stage, the stage should be a static entity that you can call from either within the object or outside of it. If you cannot access the stage by simply typing "stage" from within the scope where you are applying this transformation then this would probably be the cause of the issue. Like I said, try using the ADDED_TO_STAGE event, apply the transformations within that callback and everything should be okay if I'm right. Also when you're trying to cast an object like you've posted above, use the "as" keyword. Example:
Your statement that the youtube player "doesn't support this method" doesn't really make sense, since this had nothing to do with youtube or any other external API. Casting/type conversion is a programming language feature. The only case where this statement would be true is if the youtube player had no common inhertence with the MovieClip object, in which case you'd get a type coercion error at runtime (maybe even compile time in some instances) telling you that you simply cannot cast an object as a completely different object. Anyway hope this helps.