   Actionscript: Implement a TIMER
  Hi I can't get the TIMER to work. I get the following error.1120: Access of undefined property timerForSounds.Does the post go in this part of forum or in general programming?package {// import - on writing an import structure it shows you all the sub classes of that main class ie: media has sound, sound channel, net has loads etc...import flash.display.Bitmap;import flash.display.MovieClip;import flash.media.Sound;import flash.media.SoundChannel;import flash.media.SoundMixer;// to use stop all soundsimport flash.net.navigateToURL;import flash.net.URLRequest;//sound uses URL to navigate to route sound folderimport flash.net.URLVariables;import flash.events.*;//import flash.events.Event;import flash.ui.Mouse;//import flash.events.MouseEvent;import flash.geom.Point;import fl.transitions.Tween;import fl.transitions.TweenEvent;import fl.transitions.easing.*;import flash.utils.Timer;import flash.events.TimerEvent;import proyectos.trivia.TriviaEvent;public class game1SunnyWalk extends MovieClip {private var v:Number=5;private var varObject:String;private var i:Number;private var arrayObjects:Array;private var soundClip:Sound;private var soundLoop:Sound;//This one we will pass into soundChannel to be able to loop it ie: soundchannel has that methodprivate var soundChannel:SoundChannel;private var randomnumber:Number;private var hitcount:Number;// counts objects hitprivate var soundsArray:Array;private var blHit:Boolean;private var timerForSounds:Timer;//private var timerForSounds:Timer;public function game1SunnyWalk() {this.timerforSounds=new Timer(300,1); // 300 is an interval of 3 seconds i think and is activated once. Don't over use timers. ie: Timing a game could be a bad choice - use points instead. Also, if you have an onEventFrame working then you could use that to time and no need to have both going simultaneously.this.soundsArray = new Array();//IGNACIO NEWthis.addEventListener(Event.ADDED_TO_STAGE,this.onAddedToStage);//This starts it all off. In my other games I need a listener as they look for a stage that is not there yet. Here it appears to be OK as we are using document class.this.setSounds();//IGNACIO NEW//****************INITIALISE VARIABLESthis.arrayObjects=["one","two","three","four","five"];this.i=1;this.varObject=arrayObjects[i-1];this.hitcount=0;this.blHit=false;}private function setSounds() {//IGNACIO NEWvar oneSound:OneSound = new OneSound();this.soundsArray.push(oneSound);var twoSound:TwoSound = new TwoSound();this.soundsArray.push(twoSound);var threeSound:ThreeSound = new ThreeSound();this.soundsArray.push(threeSound);var fourSound:FourSound = new FourSound();this.soundsArray.push(fourSound);var fiveSound:FiveSound = new FiveSound();this.soundsArray.push(fiveSound);}private function onAddedToStage(e:Event) {this.initSoundLoop();// call function to start music loopthis.stage.addEventListener(MouseEvent.CLICK, myClickReaction);this.init();}public function getXMLName(nombre:String) {// Added by Ignacio why???trace("game1SunnyWalk",nombre);}timerForSounds.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerCompleteEvalTimer);timerForSounds.start();private function onTimerCompleteEvalTimer(e:TimerEvent) {this.init();}   
  Please put [source] tags around your code - it preserves formatting and adds syntax highlighting. Currently it's pretty hard to read your code. Also, did the error message show you a line number? If so, please post it.Anyway, it looks like timerForSounds.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerCompleteEvalTimer); is the problem (and the line below it as well). Those aren't placed in any function, and since timerForSounds is a member variable, that won't work. You'll have to put those lines inside a member function.   ;  Thanks - all solved. Next time I'll post properly.   