-
1. Re: I need IF statment Help Pwease
Ned Murphy Oct 28, 2012 5:52 AM (in response to Kilik89)You should not place code on objects. Keep all of your code in the timeline. Give your button an instance name and assign code to it using that name.
You should avoid using the var properties of textfields. Use a variable that you define in the timeline and assign value to that variable. If you want that value displayed in a textfield, then assign an instance name to the textfield and assign text to it using its text property.
As far as the conditional code you wrote goes, you should not build functions within. The following is all you would need for that button code when placing it in the timeline...
btnName.onRelease = function (){
if (nameofvar < 1)
{
trace(You already have a nameofvar);
}
else
{
nameofvar = nameofvar + 1;
}
}
-
2. Re: I need IF statment Help Pwease
Kilik89 Oct 28, 2012 7:49 AM (in response to Ned Murphy)1 person found this helpfulThank you for the on timeline Explaintion <3 if you dont mind explian differance between keeping it on button and keeping it on timeline
-
3. Re: I need IF statment Help Pwease
Ned Murphy Oct 28, 2012 8:15 AM (in response to Kilik89)1 person found this helpfulThe difference is primarily poor coding practices versus good coding practices. When you keep all of the code in the timeline, it is much easier to find and to manage - you don't have to click every item to try to find if code is hiding on them. It also makes it much clearer which objects are being addressed when code is targeting them.
If you ever plan to advance to using the newer versions of Flash and AS3, placing code on objects is not allowed, so getting in the habit now is better.
-
4. Re: I need IF statment Help Pwease
Kilik89 Oct 28, 2012 10:55 PM (in response to Ned Murphy)1 person found this helpfulThank you I now use all code on timeline Thank You so much for your lesson!
-
5. Re: I need IF statment Help Pwease
Ned Murphy Oct 29, 2012 5:25 AM (in response to Kilik89)You're welcome