在 Flex 应用程序中运行 Flash 影片
我有一个 Flash 影片,我想在 Flex 应用程序中使用它,它与预加载器非常相似。
查看本教程,http://www. flexer.info/2008/02/07/very-first-flex-preloader-customization/,我预计这将是一个不扩展“Preloader”并扩展“Sprite”并在任何地方使用我创建的类的问题我需要。
唉,我创作的电影没有上映。
这是我的包含电影的类的代码,是根据上面的教程制作的:
package
{
import mx.preloaders.DownloadProgressBar;
import flash.display.Sprite;
import flash.events.ProgressEvent;
import flash.events.Event;
import mx.events.FlexEvent;
import flash.display.MovieClip;
public class PlayerAnimation extends Sprite
{
[Embed("Player.swf")]
public var PlayerGraphic:Class;
public var mc:MovieClip;
public function PlayerAnimation():void
{
super();
mc = new PlayerGraphic();
addChild(mc);
}
public function Play():void
{
mc.gotoAndStop(2);
}
}
}
I've a flash movie that I would like to use inside of a flex application, very similar to a preloader.
Looking at this tutorial, http://www.flexer.info/2008/02/07/very-first-flex-preloader-customization/, I expected it would be a matter of not extending "Preloader" and extending "Sprite" and using the class i created wherever i needed.
Alas, the movie I created, is not being shown.
This is the code for my class containing the movie, made based on the tutorial above:
package
{
import mx.preloaders.DownloadProgressBar;
import flash.display.Sprite;
import flash.events.ProgressEvent;
import flash.events.Event;
import mx.events.FlexEvent;
import flash.display.MovieClip;
public class PlayerAnimation extends Sprite
{
[Embed("Player.swf")]
public var PlayerGraphic:Class;
public var mc:MovieClip;
public function PlayerAnimation():void
{
super();
mc = new PlayerGraphic();
addChild(mc);
}
public function Play():void
{
mc.gotoAndStop(2);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要考虑到flex的基本显示基元是UIComponent,而不是主要使用Sprites的Flash。 您只能将 UIComponent 添加到 Flex 组件(而不是直接添加 Sprite,正如您似乎正在尝试做的那样)。
你应该:
var iui:UIComponent=new UIComponent();
//首先创建UIComponent容器
var 玩家:PlayerAnimation=new PlayerAnimation();
//然后创建基于 Sprite 的类
玩家.宽度=这个.宽度;
玩家.高度=这个.高度;
//设置高度、宽度
iui.addChild(玩家);
//将基于 Sprite 的类添加到 UIComponent
this.addChild(iui);
//最后你可以将 UIComponent 添加到你的 Flex 容器中(Application、TitleWindow、VBox、Panel...无论它是什么)
you need to take into account that flex's basic display primitive is UIComponent, as opposed to Flash that uses mainly Sprites. You can only add a UIComponent to a Flex component (and not directly a Sprite, as you seem to be trying to do).
you should:
var iui:UIComponent=new UIComponent();
//first create the UIComponent container
var player:PlayerAnimation=new PlayerAnimation();
//then create your Sprite-based class
player.width=this.width;
player.height=this.height;
//set-up height,width
iui.addChild(player);
//add your Sprite-based class to the UIComponent
this.addChild(iui);
//finally you can add the UIComponent to your Flex Container (Application, TitleWindow, VBox, Panel... whatever it is)