Andy Malik
Andy Malik

Reputation: 13

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

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

Upvotes: 0

Views: 525

Answers (1)

Organis
Organis

Reputation: 7316

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

Upvotes: 1

Related Questions