Groups | Blog | Home
all groups > flash (macromedia) > may 2006 >

flash (macromedia) : Zero in Flash


David Stiller
5/12/2006 3:17:58 PM
Stuart,

[quoted text, click to view]

I'm confused, now. Is n a string, or a number?

[quoted text, click to view]

Okay.

[quoted text, click to view]

I'm not sure what system you mean. Flash certainly understands zero.
;) I would use the global trace() function to see what the value of
records.n is at that point. Maybe it's null!

trace(records.n);
if (records.n == 0) {
gotoAndStop(60);
}


David
stiller (at) quip (dot) net
Dev essays: http://www.quip.net/blog/
"Luck is the residue of good design."

DMennenoh
5/12/2006 5:41:12 PM
Casting is simply using a variable of one type as another type. If your
'number' is a string then using Number(string) on it is casting the string
to a number. Better to use parseInt or parseFloat though, they are more
reliable.

--
Dave -
Adobe Community Expert
www.blurredistinction.com
www.macromedia.com/support/forums/team_macromedia/

stuart__s
5/12/2006 6:44:00 PM
Hi, I am hoping that someone out there can help me.

I am recieving a number of records back from an SQL query. The total number of
records is being presented in a string records.n, where n is the number of
records. If I have records it works perfectly, however I want the movie to jump
to a differnet frame if no records are found, I am using the code...

if (records.n == 0) {
gotoAndStop(60);
}

However the system does not seem to recognise '0' can anyone help me with this
code?

Many thanks in advance for any help that you can give me.

Regards

Stuart Seeley
JustStartingOut
5/12/2006 7:46:02 PM
My initial guess is that the value in records.n is not 0, but "0" (a string,
not a number). It works when the value is "4" because "4" is not 0 either.
Try casting it to a number and checking that.
if (Number(records.n) == 0) { ... }
stuart__s
5/12/2006 9:47:00 PM
stuart__s
5/12/2006 9:49:49 PM
Could you explain what you mean by 'Casting'?

stuart__s
5/12/2006 9:59:02 PM
stuart__s
5/13/2006 1:21:58 PM
parseInt worked...many thanks for your help.

Jeckyl
5/14/2006 12:00:00 AM
I answered this exact question a couple of days ago from you
--
Jeckyl

AddThis Social Bookmark Button