Hi there,
I'm trying to make an array in a class .as file which will be used to specify the bahavior of some movie clips I have.
I might have the for statement in the wrong place. Please tell me how it should be. If I remove the lines marked in red everything works fine, but I have been trying for days to make my first array of movie clips work
Here is the error code I get:
ReferenceError: Error #1069: Property [object T] not found on S and there is no default value.
at LetterArray() //This is the class file below
at BugGoopFSGame() //This is the main .as file.
Here is my class .as file - error causing lines in red:
package
{
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.Timer;
import flash.utils.getDefinitionByName;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
public class LetterArray extends MovieClip
{
private var _stage:Stage;
//Movie clips to be used
public var a:A = new A();
public var f:F = new F();
public var g:G = new G();
public var h:H = new H();
public var i:I = new I();
public var n:N = new N();
public var o:O = new O();
public var s:S = new S();
public var t:T = new T();
private var lettersL1:Array = new Array [a,f,g,h,i,n,o,s,t];
//Text Fields and Format
var textFormat = new TextFormat();
var textWord = new TextField();
var textScore = new TextField();
//Sound Specs
public var sound2:Sound2 = new Sound2();
public var sound4:Sound4 = new Sound4();
//***CONSTRUCTOR FUNCTION***
public function LetterArray(s:Stage)
{
_stage = stage;
trace("Main construtor is working");
//GameLoop
initText();
initLetters();
initLetterWasClickedOn();
initCheckIfLetterIsCorrect();
initInGameAnimation();
initRemoveLetterChildren();
initPointsGiven();
}
//OTHER FUNCTIONS
function initText():void
{
// text formatting works fine
trace("Text Initiation started");
}
function initLetters():void
{
for(var i:int =0; i <lettersL1.length; i++)
{
var C:Class=Class(getDefinitionByName(lettersL1[i]));
var c:*=new C(); // create instances from the classes in lettersL1
// do whatever with c
}
trace("Letter Initiation started");
}
//Other functions for game loop will go here
}
}
And just in case you need it, here is my main .as file.
package
{
import flash.display.*;
import flash.utils.Timer;
import flash.events.*;
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.events.Event;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.media.SoundTransform;
import flash.text.*;
import flash.net.URLRequest;
public class BugGoopFSGame extends MovieClip
{
public var mybackground:BackGround;
public var letterArray:LetterArray = new LetterArray(stage);
public var lettera:A;
public var c:*=new C();
public var cinders:Cinders;
public var gameTimer:Timer;
public var spidy:Spidy;
public var myplaybtn:Play;
public var timerback:TimerBack;
public var timermiddle:TimerMiddle;
public var timerfront:TimerFront;
public var settings_btn:Settings_btn;
public var sound1:Sound1 = new Sound1();
public var sound3:Sound3 = new Sound3();
public var channel:SoundChannel = sound1.play(0,int.MAX_VALUE)
public var st:SoundTransform = channel.soundTransform;
public function BugGoopFSGame()
{
sound1 = new Sound1();
st.volume = 0.5;
channel.soundTransform = st;
mybackground = new BackGround ();
addChild(mybackground);
lettera = new A ();
addChild(lettera);
cinders = new Cinders();
addChild(cinders);
spidy = new Spidy();
addChild(spidy);
myplaybtn = new Play();
addChild(myplaybtn);
timerback = new TimerBack();
addChild(timerback);
timermiddle = new TimerMiddle();
addChild(timermiddle);
timerfront = new TimerFront();
addChild(timerfront);
settings_btn = new Settings_btn();
addChild(settings_btn);
gameTimer = new Timer(31,5120);
//Add event listener for start button
myplaybtn.addEventListener(MouseEvent.CLICK, startTimer);
//Add event listener for timer;
gameTimer.addEventListener(TimerEvent.TIMER, tickTock);
gameTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerFinished);
gameTimer.addEventListener(TimerEvent.TIMER, fadeIn);
gameTimer.addEventListener(TimerEvent.TIMER, moveA);
gameTimer.addEventListener(TimerEvent.TIMER, scaleLifeBar);
//Add event listener for when lettera is clicked
lettera.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
}
//Start timer function
public function startTimer(timerEvent:MouseEvent):void
{
gameTimer.start();
trace("Timer started");
myplaybtn.visible = false;
}
public function tickTock(timerEvent:TimerEvent):void
{
trace("Tick");
}
public function timerFinished(timerEvent:TimerEvent):void
{
trace("Timer is finished");
}
public function scaleLifeBar(timerEvent:TimerEvent):void
{
timermiddle.scaleLifeBar();
}
public function fadeIn(timerEvent:TimerEvent):void
{
lettera.fadeIn();
}
public function moveA(timerEvent:TimerEvent):void
{
lettera.moveA();
}
public function onClick(event:MouseEvent):void
{
trace("The letter a was clicked");
}
}
}