Be a Supporter!

AS Game System

  • 457 Views
  • 3 Replies
New Topic Respond to this Topic
Boltrig
Boltrig
  • Member since: Mar. 17, 2006
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
AS Game System 2007-03-20 06:46:28 Reply

Hey just a quick question.

I need to get user input inside a while loop. The format is kinda as follows:

while (enemyShips > 0)
{
//get the user to select a weapon
}

The user selects their weapon to fire via buttons. What Im not sure of is general syntax and how to put an onRelease statement in there. Will this affect the loop or just halt it until the user clicks something?

Thanks in advance guys.

GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS Game System 2007-03-20 06:56:07 Reply

All AS runs in a single thread. The loop statements are for processing only. Ofcourse you can set and call the event from inside the loop but Flash itself won't respond until all code is done (or if the code exceeds fifteen seconds of running). You don't need to delay stuff like that in Flash, there's the timeline.


BBS Signature
EvanHayes
EvanHayes
  • Member since: Jan. 13, 2007
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS Game System 2007-03-20 07:42:43 Reply

if you want it to halt,set a variable in an on press fuction or somthing,and that while loop wont stop until the ships are above 0,but i guess i dont get what your saying beacuse you diddnt ask a question,you just said you had a problem with the loop,but if you want,upload the fla and ill fix it,or just upload the swf


Grah i feel so unknown, SK8MORE god damn :/ EvanHayes seems like a much more serious name than sk8more,so i changed it.

GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS Game System 2007-03-20 08:03:23 Reply

He is talking about a basic wait approach in programming, a thread does an empty loop until another gives it go. It's kinda silly because it loops a billion times a second for no reason, but it simply takes lots more code to run at an interval only.
AS is diffirent because all code is in a single thread. Thus you must do it the other way around and use the on-release event to check for the count in.


BBS Signature