Hello to all the talented people at Kirupa!
I’ll make this as simple to follow as possible, as I really need your help!
My document is laid out as follows.
Frame 1: Preloader.
Frame 2: Game content.
Frame 3: Game content.
Main class: Game.as.
I had everything on Frame 1 (Preloader, Game content) and Frame 2 (Game content) but I have changed it and inserted a new frame (which is now Frame 1) for just the preloader (This was because a long white screen was appearing before the preloader came on).
When I export and preview the game, I get TypeError: Error #1009 on any line of code that references a movieclip that is on Frame 2 (regardless of whether or not it has an instance name).
Here is some code:
public function Game()
{
stage.showDefaultContextMenu = false;
main = this;
if(this.loaderInfo.bytesLoaded < this.loaderInfo.bytesTotal)
{
loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler, false, 0, true);
loaderInfo.addEventListener(Event.COMPLETE, completeListener, false, 0, true);
}
public function progressHandler(e:ProgressEvent):void
{
loaderBar.meter.scaleX = e.bytesLoaded / e.bytesTotal;
}
public function completeListener(event:Event):void
{
loaderInfo.removeEventListener(ProgressEvent.PROGRESS,progressHandler);
loaderInfo.removeEventListener(Event.COMPLETE,completeListener);
gotoAndStop(2);
stage.addChild(teslaMovie);
teslaMovie.gotoAndPlay(1);
settleIn();
}
public function settleIn()
{
/* ERROR HAPPENS HERE: MCs given instance names on Frame 2:
playNowButton.visible = false;
mcIntroBg.visible = false;
mcLogo.visible = false;
mainMenu.visible = false;
LevelSelect.main.visible = false; */
debrisOn = true;
lightingOn = true;
backgroundOn = true;
musicOn = true;
//Pause.main.init();
Key.initialize(stage);
mcIntroBg.visible = true;
//mcLogo.visible = true;
//playNowButton.buttonMode = true;
//playNowButton.visible = true;
//playNowButton.addEventListener(MouseEvent.CLICK, showMenuOptions, false, 0, true);
}
Note that mcIntroBg.visible = true; is referencing an MC on frame 1, so it is fine. Do I really have to place all my movie clips onto the stage on frame 1 to get rid of this problem or is there an easy solution that I am missing??
Thanks in advance, Harry.