If Statements...

This is a discussion on "If Statements..." within the Flash & Multimedia Forum section. This forum, and the thread "If Statements... are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices




Closed Thread
 
LinkBack Thread Tools
  #1  
Old Sep 1st, 2004, 17:28
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
If Statements...

Hey Karl. here's my problem. No matter what kind of If statement I use and no matter if x is actually = to the 22 or not.... it always does everything anyways. FE - if I have this:
Code: Select all
If (x = 20;){
       Attack = Attack + 20
}
Else; {
       Attack = Attack - 10
}
End If;
and when it runs what happens is it'll add 20 to attack, and then it'll subtract 10 from it. Why does it do this? and how can I fix it? (it'll do it when x is equal to 15 too.. Whats wrong?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Sep 1st, 2004, 20:16
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Because your code is weird.

Why do you have x=20; and Else;
they shouldn't have ; after them. Statements should, like Attack = Attack + 20;

Actionscript also doesn't use End If;
it uses if (condition) {
// do something
}
that's it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Sep 1st, 2004, 20:32
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
It gives me an error if I pull out the ';' and it also errors and tells me I need to put End If; if I leave it off... WHAT THE HECK IS WRONG!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Sep 2nd, 2004, 02:20
Junior Member
Join Date: Jun 2004
Location: USA
Age: 25
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
The code should be this:

if (x == 20){
Attack = Attack + 20;
}
else {
Attack = Attack - 10;
}


First off, your equal signs need to be double equals when checking for equality, otherwise it is like setting x equal to 20. Second, you are placing the semi-colons in the wrong places. Semi-colons only need to be after command statements. In other words, if it is the start of a function, or checking for equality... you dont need a semicolon. This is sort of a hard concept to explain, but for the record, the code I gave you should work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
Old Sep 2nd, 2004, 02:43
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Ahh thanks man
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #6  
Old Sep 2nd, 2004, 02:48
Junior Member
Join Date: Jun 2004
Location: USA
Age: 25
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
No problem :-) I owed ya one for the navigation menu help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
statements

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.write if statements in a form? natalief2008 Classic ASP 1 May 5th, 2008 21:58


All times are GMT. The time now is 09:45.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42