Error 1046:Type was not found or was not a compile

2019-07-16 12:50发布

问题:

I'm trying to make a interactive flash video in CS6 for a class I am taking. I briefly talked with the professor about this and he could not figure out the issue either. The weird thing is it says the errors are on lines 2 and 3. When I remove the code on those lines it still says the error is on those lines. Take a look at my AS and tell me what you think.

import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.*;

public class Essay1 extends MovieClip{

public function Essay1() {

    mc_Gas.visible = false;
    mc_Drive.visible = false;
    mc_Outside.visible = false;
    mc_DriveZoom.visible = false;
    mc_Dash.visible = false;

    mc_Start.btn_Start.addEventListener(MouseEvent.MOUSE_DOWN, gotoWindow);
    mc_Drive.btn_Drive.addEventListener(MouseEvent.MOUSE_DOWN, gotoZoom);
}
public function gotoWindow(MouseEvent):void{
    mc_Start.gotoAndPlay(2);
}
public function gotoZoom(MouseEvent):void{
    mc_DriveZoom.visible = true;
    mc_DriveZoom.mc_Car3.mc_HeadDown.gotoAndPlay(2);
}

}

Here's the error message:

F:\WDMD201\Essay\Essay1.as, Line 2 1046: Type was not found or was not a compile-time constant: mc_Dash.

F:\WDMD201\Essay\Essay1.as, Line 2 1046: Type was not found or was not a compile-time constant: mc_Drive.

F:\WDMD201\Essay\Essay1.as, Line 3 1046: Type was not found or was not a compile-time constant: mc_Gas.

F:\WDMD201\Essay\Essay1.as, Line 3 1046: Type was not found or was not a compile-time constant: mc_Start.

F:\WDMD201\Essay\Essay1.as, Line 4 1046: Type was not found or was not a compile-time constant: mc_Outside.

F:\WDMD201\Essay\Essay1.as, Line 5 1046: Type was not found or was not a compile-time constant: mc_DriveZoom.

回答1:

The issue is that you are trying to access unknown properties. To access them, your need to declare properties matching the instance names on the stage. Declare all the properties mc_Dash, mc_Drive, and so on, as member variables :

public class Essay1 extends MovieClip {

    public var mc_Dash:MovieClip;

    public function Essay1 {
    ....