Although there seems to be lots of posts already on here about the dreaded 1009, my lack of experience is causing me problems understanding them. I have heard that you cannot access the stage outside of the document class unless through a movie clip. So how would I add my movie clip to the stage without being able to access it?
If none of this makes any sense, Here are the three classes I am using, they don’t do much, it’s just a trial so I can get used to certain functions etc.
package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.Stage;
public class makedot
{
static var dotArray:Array = new Array();
public function makedot(){
var mymc:MovieClip = new MovieClip();
var mysprite:Sprite = new Sprite();
mysprite.graphics.beginFill(0x6AA29C, 1);
mysprite.graphics.drawCircle(Math.random()*300,Math.random()*300,10);
dotArray.push(mysprite);
mymc.stage.addChild(mysprite);
}
}
}
package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.Stage;
public class makerect
{
static var rectArray:Array = new Array();
public function makerect(){
var mymc:MovieClip = new MovieClip();
var mysprite:Sprite = new Sprite();
mysprite.graphics.beginFill(0x445566, 1);
mysprite.graphics.drawCircle(Math.random()*300,Math.random()*300,10);
rectArray.push(mysprite);
mymc.stage.addChild(mysprite);
}
}
}
package
{
import flash.display.MovieClip;
import flash.events.*;
import flash.ui.Keyboard;
import flash.display.Stage;
public class document extends MovieClip
{
public function document(){
var mymc = new MovieClip();
var dotOne = new makedot();
var dotTwo = new makedot();
var dotThree = new makedot();
var rectOne = new makerect();
var rectTwo = new makerect();
var rectThree = new makerect();
mymc.stage.addEventListener(KeyboardEvent.KEY_DOWN, moveStage);
}
public function moveStage(Event:KeyboardEvent){
if (Event.keyCode == Keyboard.LEFT){
for each (var item in makerect.rectArray){
item.x += 10;
}
for each (var rect in makedot.dotArray){
item.x += 10;
}
}
}
}
}
The final class ‘document’ is my document class. Any ideas as to why it’s throwing this?
Also as I’m new to the AS3 world, if anyone has any other suggestions as to how my code could be improved please let me know