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

查看:110
本文介绍了Actionscript3主类是根类,但不允许使用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.

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

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中完全没有代码(功能必需品除外),并且在时间轴中没有Camera,我也会收到此错误:

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添加到了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?

谢谢, 安迪

推荐答案

尝试声明公共动态类Main ,因为 VirtualCamera 类并非不可能期望通用的<作为根用户的strong> MovieClip (动态的=您可以添加任何属性而不会引发异常).

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主类是根类,但不允许使用Animate Virtual Camera的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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