MovieClip.CreateEmptyMovieClip 的 AS3 等效项是什么?

发布于 2024-09-16 21:21:33 字数 565 浏览 4 评论 0原文

我有一些旧的 AS2 风格的 Haxe 代码,它使用 flash.Lib.Current.CreateEmptyMovieClip() 来创建基于磁盘的图像的幻灯片。它创建一个新的剪辑来保存每个图像,并简单地使用 Alpha 级别淡入和淡出每个图像。

使用 -swf -swf-version 8 编译它可以很好地创建一个 SWF 文件,并且可以在浏览器中运行。

但是,我正在将其转换为 -swf9,并且我发现 MovieClip 不再具有该方法。

如何使用 Haxe(AS3 风格)加载一系列图像?

就其价值而言,代码大致如下:

static function main() {
  mc = flash.Lib.current;
  var clip : MovieClip;

  clip = mc.createEmptyMovieClip ("clip_000", mc.getNextHighestDepth());
  clip.loadMovie ("demo_img000.jpg");

  : : :

I have some older AS2-style Haxe code which uses flash.Lib.Current.CreateEmptyMovieClip() to create a slideshow of disk-based images. It creates a new clip for holding each image and simply fades each image in and out with alpha levels.

Compiling it with -swf -swf-version 8 creates an SWF file fine and this works in the browser.

However, I'm in the process to converting this over to -swf9 and I find that the MovieClip no longer has that method.

How do you load up a series of images with Haxe (AS3-style)?

The code, for what it's worth, is along these lines:

static function main() {
  mc = flash.Lib.current;
  var clip : MovieClip;

  clip = mc.createEmptyMovieClip ("clip_000", mc.getNextHighestDepth());
  clip.loadMovie ("demo_img000.jpg");

  : : :

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮光沉寂 2024-09-23 21:21:33

您可以创建一个新的显示对象,而不将其链接到库中的剪辑,如下所示:

var sprite:Sprite = new Sprite() // -- creates a sprite
var clip:MovieClip = new MovieClip() // -- creates a movie clip

然后您可以使用 addChild() 方法将其添加到另一个显示对象:

myOtherClip.addChild( sprite )

上面的行将将新剪辑添加到显示列表的顶部,就像使用 getNextHighestDepth() 一样。

如果您想在其他两个剪辑之间添加一个剪辑,您可以使用:

myOtherClip.addChildAt( movieClip, 2 ); // -- adds a clip at 2 levels up from 0

至于加载图像,AS3 中不存在 loadMovie。您需要像这样使用 Loader 和 URLRequest 对象:

var loader:Loader = new Loader();
var request:URLRequest = new URLRequest( 'path_to_my_image.jpg' );
loader.addEventListener( Event.COMPLETE, onLoadComplete );
loader.load( request );

function onLoadComplete( event:Event ):void
{
     if( loader.content ){
         clip.addChild( loader.content )
     }
}

You can just create a new display object w/o linking it to a clip in the library like this:

var sprite:Sprite = new Sprite() // -- creates a sprite
var clip:MovieClip = new MovieClip() // -- creates a movie clip

You can then add it to another display object by using the addChild() method:

myOtherClip.addChild( sprite )

The above line will add the new clip to the top of the display list, just like using getNextHighestDepth().

If you want to add a clip a depth between two other clips you can use:

myOtherClip.addChildAt( movieClip, 2 ); // -- adds a clip at 2 levels up from 0

As for loading an image, loadMovie does not exist in AS3. You need to use the Loader and URLRequest objects like this:

var loader:Loader = new Loader();
var request:URLRequest = new URLRequest( 'path_to_my_image.jpg' );
loader.addEventListener( Event.COMPLETE, onLoadComplete );
loader.load( request );

function onLoadComplete( event:Event ):void
{
     if( loader.content ){
         clip.addChild( loader.content )
     }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文