I was doing a tutorial and got this error.
Line 3 1046: Type was not found or was not a compile-time constant: startButton.
I did some research and I found someone who had excatly the same problem. He was helped in the comment section.
the creator of the tutorial told him the following:
“Have you turned “auto-declare stage instances” on, as in the start of Part 1? Also, is your startButton inside the MenuScreen clip, and is the MenuScreen exported for ActionScript?”
Now i think i haven’t auto-declared stage instances. (the other things are done, I did a double check) But it’s a bit vague to me what it means, could you possible tell me how to do “auto-declare stage instances” after already having it all coded.
the link to tutorial: http://gamedev.michaeljameswilliams.com/2008/10/12/avoider-game-tutorial-4/comment-page-5/#comments
package
{
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
public class MenuScreen extends MovieClip
{
public function MenuScreen()
{
startButton.addEventListener( MouseEvent.CLICK, onClickStart );
}
public function onClickStart( event:MouseEvent ):void
{
dispatchEvent( new NavigationEvent( NavigationEvent.START ) );
}
}
}
add
or
to the class
MenuScreendepending on type ofstartButtonon the scene. Be sure that you gave the namestartButtonto the button instance and don’t forget to assign classMenuScreento the component that holds thestartButton.