i just st开发者_运维知识库arted learning actionscript 3 and i have a question. I am trying to create a game but i am not sure on how to create a global update for a variable? for example if i put this:
myNumber+=1;
txt.text = myNumber.toString();
It only updates once and stops when the game starts. I would like a constant update. How is this possible? is there an update() method this needs to go under?
import flash.events.Event;
addEventListener(Event.EnterFrame, HandleGameLoop);
function HandleGameLoop(e:Event):void
{
// Everything in here will be called Every frame.
}
I suggest you look at a few tutorials given the questions you have asked. Here is a great one about games. It goes through the process from start to finish.
http://gamedev.michaeljameswilliams.com/
精彩评论