Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-10-2004, 09:41 AM   #1
ursulaminor
Member
 
Join Date: Jan 2004
Location: Canada
Posts: 79
Default 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
ursulaminor is offline   Reply With Quote
Old 02-10-2004, 10:39 AM   #2
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

dataStore[i]==undefined
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 02-10-2004, 10:40 AM   #3
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

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.
pixelwit is offline   Reply With Quote
Old 02-10-2004, 10:42 AM   #4
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

your typing way too much pixelwit... but as usually, its the more robust answer.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 02-10-2004, 10:48 AM   #5
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

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.
pixelwit is offline   Reply With Quote
Old 02-10-2004, 10:56 AM   #6
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

Quote:
[i] You know, keeping myself honest.
-PiXELWiT
http://www.pixelwit.com [/B]
why in the world would anyone ever want to do that....
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 02-10-2004, 11:03 AM   #7
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

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.
pixelwit is offline   Reply With Quote
Old 02-10-2004, 11:32 AM   #8
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

hehhehheh.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 02-10-2004, 11:54 AM   #9
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

overachiever











__________________
(6)
senocular is offline   Reply With Quote
Old 02-10-2004, 12:42 PM   #10
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

"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.
pixelwit is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loading an object from an array NateVeronica ActionScript 2.0 1 03-30-2004 10:53 PM


All times are GMT. The time now is 02:30 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.