克隆嵌入的SWF类 [英] Clone embedded swf class

查看:187
本文介绍了克隆嵌入的SWF类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来克隆一个嵌入类?因为否则的话,我不能直接使用我的自定义方法。

Is there a way to clone an embedded class? Because otherwise, I can't directly use my custom methods.

这是内部的类不工作嵌入。

Embedding from within the class doesn't work.

package  {
 import flash.display.Sprite;

 public class Player {
     public var player:Sprite;
     [Embed(source = '../lib/player.swf')] private var swf:Class;
     public function Player() {
         this = new swf(); // doesnt work
     }
     public function method1():void {
         return;
     }
 }
}

从类的外部嵌入,也不起作用。

Embedding from outside the class, also doesn't work.

package  {
 import flash.display.Sprite;

 public class Main {
     public var player:Player;
     [Embed(source = '../lib/player.swf')] private var swf:Class;
     public function Main() {
         player = Player(new swf()); // doesn't work
         player = new swf() as Player; // doesn't work
     }
 }
}

或者,也许有一种方法可以从嵌入实例化一个类,并将其转换为另一个类?谢谢你。

Or maybe there is a way to instantiate a class from an embed and convert it to another class? Thanks.

推荐答案

我想你要找的东西是这样的:

I think what you're looking for is this:

[Embed(source = '../lib/player.swf', symbol='Player')]
public class Player extends MovieClip
{
    // Continue with class code as before

如果该影片剪辑要导入只有1帧,则可能需要将其更改为播放器扩展Sprite 。当然,这段代码假设您已经导出的影片剪辑的ActionScript和从Flash IDE内部给它的类名球员。如果你有麻烦,你可以看看这里的一步一步的演练。

If the MovieClip you are importing only has 1 frame, you might need to change it to Player extends Sprite. This snippet of course assumes that you have exported the MovieClip for ActionScript and given it the Class name "Player" from inside the Flash IDE. If you are having trouble you can look here for a step-by-step walkthrough.

这篇关于克隆嵌入的SWF类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆