Im new to actionscript and I have have been mucking around trying to create a sidescrolling game. All was going well until I realized I need a game over feature. The problem is I have many movieclip objects with their own instance names that I access from my document class.
However, now I have a new document class that initiates my old document class to start the game, and also initiates the game over screen, so i can reset the game. Except now I get the error access of undefined property (fill in the blank) for all 50 of my instance objects.
So my question is how can I get flash to recognize and allow my non document class, class to manipulate these Movie Clip instances.
I created a smallscale example to illustrate what im trying to do.
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Stage;
public class Test extends MovieClip {
public static var gstage:Stage;
public function Test() {
// constructor code
var playScreen:Go = new Go();
addChild( playScreen );
}
}
}
The above is my Document class "moveme is the name of the instance
The other class which would be my old Document class is
package {
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import Test;
public class Go extends MovieClip {
public var test:Test;
public function Go()
{
if (stage)
{
init();
}
else
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
}
private function init(e:Event = null):void
{
if (e) removeEventListener(Event.ADDED_TO_STAGE, init);
trace(stage.width);
addEventListener(Event.ENTER_FRAME, loop);
}
public function loop(e:Event, Test):void
{
Test.moveme.scaleX++
Test.moveme.x++
}
}
}
The error I get with this one is ArgumentError: Error #1063: Argument count mismatch on Go/loop(). Expected 2, got 1.
or if I remove the Test in public function loop(e:Event, Test):void I get the same error as before. Ive tried many things already I can get it to trace the stage width I just cant seem to control the instances.
Any help would be appreciated!