Actionscript3 Main 类是根,但不允许 Animate Virtual Camera [英] Actionscript3 Main class is the root, but does not allow the Animate Virtual Camera

查看:17
本文介绍了Actionscript3 Main 类是根,但不允许 Animate Virtual Camera的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用 Actionscript 3 学习 Animate CC.

I've recently started learning Animate CC with Actionscript 3.

我正在尝试使用 Animate 的虚拟相机"功能,为我提供一个可以平移、旋转和缩放游戏的相机.

I'm trying to use Animate's "Virtual Camera" feature, giving me a camera that can pan, rotate, and zoom the game.

当根没有子类时,很容易实现相机.例如,您可以在屏幕上放置一个块,并在时间线本身内添加相机效果,然后播放您的电影.很简单.

It's easy to implement a Camera when the root has no subclass. For example, you can put a block on screen, and add a camera effect within the timeline itself, and play your movie it. Easy.

但是当我给 fla 一个类(Main")并给那个类一个外部 AS3 文件时,我得到一个错误:

But when I give the fla a class ("Main") and give that class an external AS3 file, I get an error:

具体图片展示了我给 FLA 上课的意思

下面的代码是Main.as"

The code below is "Main.as"

package  {
import flash.display.MovieClip;
import flash.display.DisplayObject;
import fl.VirtualCamera;

public class Main extends MovieClip {


    var camera;

    public function Main() {
        // constructor code
        camera = VirtualCamera.getCamera(root);
        trace(camera);
    }

}

}

现在,即使我在 Main.as 中绝对没有代码(除了功能必需品),并且时间轴中有一个相机,我也会收到此错误:

Now, even when I had absolutely no code (other than functional necessities) in Main.as, and a Camera in the timeline, I would get this error:

ReferenceError: Error #1069: Property ___layerDepthEnabled___ not found on Main and there is no default value.
at privatePkg::___Camera___/cameraControl()

我在上面的代码中添加了 Main,但我得到了同样的错误.

I added in this code above to Main, and I get the same error.

唯一能修复它的就是改变

The only thing that fixes it is changing

camera = VirtualCamera.getCamera(root);

到:

camera = VirtualCamera.getCamera(this.parent);

而且,虽然消除了代码,但实际上也没有给我一个可以使用的相机.

and that, while eliminating the code, also doesn't actually give me a camera to use.

如何在使用虚拟摄像机的同时仍然拥有 Main.as?

谢谢,安迪

推荐答案

尝试声明 public dynamic class Main 因为 VirtualCamera 类期望通用 MovieClip 作为 root(这是动态的 = 您可以添加任何属性而不会引发异常).

Try declaring public dynamic class Main because it is not impossible that VirtualCamera class is expecting a generic MovieClip as root (which is dynamic = you can add any property without raising an exception).

这篇关于Actionscript3 Main 类是根,但不允许 Animate Virtual Camera的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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