02-10-2004, 09:41 AM
|
#1
|
|
Member
Join Date: Jan 2004
Location: Canada
Posts: 79
|
an array with nothing in it returns null or 0 or what????
Hi
I have this AS code
PHP Code:
for(i=0;i<10;i++){
if ((dataStore[i]==0)&&(pos[i]<280)){
Q1count +=Number(((dataStore[i]==0)&&(pos[i]<280)));
possumAnswer_mc.possum_mc.theAnswer_txt.text = Q1count;
}
}
this.deconstruct();
}
The problem is, that sometimes there is nothing in the array (pos[i] array meeting the <280 requirement. Instead of it returning 0 or null...it returns absolutely nothing. How can I get it to say '0'. I feel like I should be able to write an if statement that says there's no entry found then theAnswer_txt.text = 0 but I don't know how to say in actionscript 'if there is nothng in the array'
Thanks to anyone who has an aswer to this.
__________________
um
|
|
|
02-10-2004, 10:39 AM
|
#2
|
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
|
dataStore[i]==undefined
__________________
tg
---
what the hell was i thinking?
|
|
|
02-10-2004, 10:40 AM
|
#3
|
|
village halfwit
Join Date: Jul 2001
Location: USA, PA
Posts: 3,328
|
Test to see if the current index of your array is "undefined".
Code:
var arry = [];
arry[0] = "str";
arry[2] = 1;
arry [4] = this.createEmptyMovieClip("Dot", 10);
for(var i=0; i<arry.length; i++){
if(arry[i]== undefined){
trace("arry["+i+"] == undefined");
}
}
-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
|
|
|
02-10-2004, 10:42 AM
|
#4
|
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
|
your typing way too much pixelwit... but as usually, its the more robust answer.
__________________
tg
---
what the hell was i thinking?
|
|
|
02-10-2004, 10:48 AM
|
#5
|
|
village halfwit
Join Date: Jul 2001
Location: USA, PA
Posts: 3,328
|
Yeah I know but I like posting code you can test with a quick copy and paste. Plus it assures that what I say works actually does work. You know, keeping myself honest.
-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
|
|
|
02-10-2004, 10:56 AM
|
#6
|
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
|
why in the world would anyone ever want to do that....
__________________
tg
---
what the hell was i thinking?
|
|
|
02-10-2004, 11:03 AM
|
#7
|
|
village halfwit
Join Date: Jul 2001
Location: USA, PA
Posts: 3,328
|
Good point. Like my footer says, "truth is only relevant in times of reason" and I don't find today's times very reasonable. Perhaps I'll start posting crap code (well crappier than usual anyway) for the fun of it.
-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
|
|
|
02-10-2004, 11:32 AM
|
#8
|
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
|
hehhehheh.
__________________
tg
---
what the hell was i thinking?
|
|
|
02-10-2004, 11:54 AM
|
#9
|
|
six eyes
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
|
overachiever
|
|
|
02-10-2004, 12:42 PM
|
#10
|
|
village halfwit
Join Date: Jul 2001
Location: USA, PA
Posts: 3,328
|
"Overachiever"? Ha! That's a good one. I've never been called that before.
Although I do have to admit sometimes I get caught up in answering questions. Take this thread for example. The five lines describing the snapIt function probably would have been enough to get the point across but all that other stuff was so much fun to make I just had to post it.
So I talk too much. Is that what you're saying? Well in that case I
-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 02:53 AM.
///
|
|