Why does flash acknowledge the timeline but not the code
Alright so I have posted a similar question before, but it was never truly answered, only fixed. I mean, I recieved incredible amounts of help and a solution that works, but not one that makes sense to me.
After adding a preloader with this code:
stop();
import flash.events.ProgressEvent;
import flash.events.Event;
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoading);
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onLoading(evt:ProgressEvent):void {
//trace("Do Not Disturb");
var loaded:Number = evt.bytesLoaded / evt.bytesTotal;
percent_txt.text = (loaded*100).toFixed(0) + "%";
}
function onComplete(event:Event):void {
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoading);
this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
gotoAndStop(2);
}
package cbhCode
{
import flash.display.MovieClip;
import flash.events.Event;
import com.rw.GameClock
import flash.events.MouseEvent;
public class Main extends MovieClip
{
//TOYS
public var bouncyBall:BouncyBall = new BouncyBall();
//BROKE TOYS
public var brokeBouncyBall:BrokeBouncyBall = new BrokeBouncyBall();
//This array will hold the names of all the safe toys so when they spawn, I can simply reference a number of this array
public var safeToys:Array = new Array(bouncyBall);
//This is the same as the safeToys array, but for broken toys
public var brokenToys:Array = new Array(brokeBouncyBall);
//This array will hold any toys, safe or broken, that are on the stage
public var stageToys:Array = new Array();
//This variable will be used to hold the object in the array chosen at random
public var chooseToy:int;
//These two variables hold the length of safeToys and brokenToys
public var brokeToysNum:int = (brokenToys.length -1);
public var safeToysNum:int = (safeToys.length -1);
public function Main()
{
// constructor code
initGame();
}
public function initGame() {
trace("hello");
safeToys[0].x = 0;
safeToys[0].y = -50;
stage.addChild(safeToys[0]);
stageToys.push(safeToys[0]);
brokenToys[0].x = 0;
brokenToys[0].y = -1000;
stage.addChild(brokenToys[0]);
stageToys.push(brokenToys[0]);
addEventListener(Event.ENTER_FRAME, checkToyLocation);
}
public function checkToyLocation(e:Event)
{
trace(currentFrame);
for (var i:int; i < stageToys.length; i++)
{
//once a toy reaches the end of the stage, it needs to be removed
if (stageToys.x > stage.stageWidth)
{
trace("later");
stage.removeChild(stageToys);
stageToys.splice(i,1);
}
}
}
}
}
