Results 1 to 9 of 9
Thread: Redundant code help
-
November 19th, 2005, 12:00 AM #1
Redundant code help
Can someone consolidate this code:
Maybe as a funtion or something.
I know there has to be a better way of doing this. Im not very good at AS.
Ill offer you 10-15 bucks for the first person who can give me a working answer. Thanks for your time! I have lot of other stuff I need help with too.
Thanks!
// TEACHING QUESTIONS
if (_root.TQ1Completed == "6") {
TQcheckMark1._visible = true;
} else {
TQcheckMark1._visible = false;
}
if (_root.TQ2Completed == "5") {
TQcheckMark2._visible = true;
} else {
TQcheckMark2._visible = false;
}
if (_root.TQ3Completed == "4") {
TQcheckMark3._visible = true;
} else {
TQcheckMark3._visible = false;
}
if (_root.TQ4Completed == "3") {
TQcheckMark4._visible = true;
} else {
TQcheckMark4._visible = false;
}
if (_root.TQ5Completed == "4") {
TQcheckMark5._visible = true;
} else {
TQcheckMark5._visible = false;
}
The "numbers" correspond to the number of sections in the question.
For example "TQ1Completed" has "6" sections and so on.
-
November 19th, 2005, 12:55 AM #2
Hello, I don't really get what you want in the if statement (ex: == "4") How is "4" determined?
tqstart = 1;
tqend = 5;
for (i=tqstart; i<=tqend; i++){
if (_root["TQ" + i + "Completed"] == idontgetwhatyouwanthere){
_root["TQcheckMark" + i]._visible = true;
}else{
_root["TQcheckMark" + i]._visible = false;
}
}
EDIT:
Wait, I think this is what you want:
sections = array(6,5,4,3,4);
for (i=0; i<sections.length; i++){
if (_root["TQ" + (i+1) + "Completed"] == sections[i]){
_root["TQcheckMark" + (i+1)]._visible = true;
}else{
_root["TQcheckMark" + (i+1)]._visible = false;
}
}
-freeskier89
Last edited by freeskier89; November 19th, 2005 at 12:59 AM.
-
November 19th, 2005, 01:01 AM #3
freeskier89 thanks for the quick reply.
I type this number (ex: == "4") in by hand.
The (ex: == "4") corresponds to the amount of sections in the teaching question.
So (ex: == "4") has 4 sections in the teahing question.
Thanks!
-T
-
November 19th, 2005, 01:03 AM #4
-
November 19th, 2005, 01:08 AM #5
Oh crap that was fast.
That looks about right. Im gonna try it.
PM me your pay pal address please.
-T
-
November 19th, 2005, 01:10 AM #6
-
November 19th, 2005, 01:34 AM #7
Did i do this right?
I needed to target the same timeline the script was in so I used "this" on the _visible commands and it worked. Is that ok? or should I use something else?
// TEACHING QUESTIONS SCRATCH OFF
sections = new array(6, 5, 4, 3, 4);
for (i=0; i<sections.length; i++) {
if (_root["TQ"+(i+1)+"Completed"] == sections[i]) {
this["TQcheckMark"+(i+1)]._visible = true;
} else {
this["TQcheckMark"+(i+1)]._visible = false;
}
}
Thanks!
-T
-
November 19th, 2005, 01:55 AM #8
-
November 19th, 2005, 10:29 AM #9
im gonna just show off, lol
this["TQcheckMark"+(i+1)]._visible = (_root["TQ"+(i+1)+"Completed"] == sections[i]);
Similar Threads
-
Post html code in question
By waffe in forum Forum Guidelines/SuggestionsReplies: 12Last Post: January 24th, 2008, 03:33 PM -
[FMX] Interactive Circuit builder...need a few tiny bits of code, so very confused!
By shangrula in forum ActionScript 2 (and Earlier)Replies: 0Last Post: March 10th, 2004, 01:08 PM -
Viewing Code
By .soulty in forum ActionScript 2 (and Earlier)Replies: 10Last Post: July 9th, 2003, 04:41 PM -
aaah please help with this code?
By ave in forum ActionScript 2 (and Earlier)Replies: 12Last Post: May 6th, 2003, 12:34 PM -
code consolidation
By subquark in forum ActionScript 2 (and Earlier)Replies: 15Last Post: January 21st, 2003, 08:45 PM

Reply With Quote
I just realized you might need a "new" in front "array"

Bookmarks