Actionscript3 Main class is the root, but does not allow the Animate Virtual Camera

我的梦境 提交于 2019-12-01 13:30:47

问题


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

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.

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

Specific image showcasing what I mean about giving FLA a class

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);
    }

}

}

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()

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);

to:

camera = VirtualCamera.getCamera(this.parent);

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

How can I use a Virtual Camera and still have Main.as?

Thanks, Andy


回答1:


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).



来源:https://stackoverflow.com/questions/48673142/actionscript3-main-class-is-the-root-but-does-not-allow-the-animate-virtual-cam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!