troubleshooting Question

my game loop

Avatar of jagguy
jagguyFlag for Australia asked on
Web Development SoftwareAdobe Flash
4 Comments1 Solution427 ViewsLast Modified:
My game loop works and I want someone to look at it to see if I can improve it AS3 style.
What I do is load an image from a class and it dispatches an event when completed. When all images are loaded (which is 1 in this example) I then start the game loop which is just a trace.

This way I could load many images and then start the my game loop

This is a skeleton I can build upon.
var noLoaded:int;
var li:ClassImg2= new ClassImg2("ladybug.png",120,120);

function imageLoadedHandler(e:Event){

 function doSomething(e:KeyboardEvent):void
		if (e.keyCode==37) //39 is right arrow
		trace("left pressed")
		if (e.keyCode==39) //39 is right arrow
		trace("right pressed")
stage.addEventListener(Event.ENTER_FRAME, gameLoop);

function gameLoop(event:Event)
	if (noLoaded==1)
		trace("all loaded");	
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros