PDA

View Full Version : newbie needs help


soundgarden
07-18-2003, 12:02 PM
why does the output window show undefined for this script..

function math(){
trace(Math.round(Math.random()*10));
}

math()

tg
07-18-2003, 01:13 PM
function math(){...}
may be overwriting the math object.

try it like this:

function rounder(){
trace(Math.round(Math.random()*10));
}
rounder();

soundgarden
07-18-2003, 02:42 PM
Thanks, I guess using math as the name of the function screws it up somehow

tg
07-18-2003, 02:56 PM
basically your overwriting the object, thus destroying the entire math object and all of its methods and properties.


suggestion:
don't use key words as function/variable names. you get unknown/undesirable results.

tg
07-18-2003, 02:59 PM
another helpful suggestion:
use descriptive subject headers on your post.... the header' problem with math object' would probably gathered more (better?) responses.

i know alot of the very helpful folks around here will not even read posts with generic topics like 'i need help' etc.

stealthelephant
07-18-2003, 06:39 PM
but arent math and Math 2 different objects cos the cases are different?

CyanBlue
07-18-2003, 08:23 PM
i know alot of the very helpful folks around here will not even read posts with generic topics like 'i need help' etc.I am not sure how helpful I am to others, but I am one of those people who do not open the thread with that sort of topic... Don't blame me on this... I just answer what I can on what I know... If I do not know what you mean by 'I need help', I don't want to waste my time on it... :D


Hey, stealthelephant... ;)

I don't think ActionScript is really case sensitive language...

Try this...trace(Math.abs(-5));
trace(math.abs(-5));x = 100;
trace("value of variable x is " + X);But it is always a good idea to keep it as it should be... :)

tg
07-21-2003, 11:49 AM
yeah flash will fool you. the as editor is case sensitive so 'Math' will show up in blue, and give you hints, while 'math' will not. however a.s. interprets them the same ( non case sensitive).

tg
07-21-2003, 11:51 AM
Originally posted by CyanBlue
I am not sure how helpful I am to others

cb, thats almost rediculously modest.

CyanBlue
07-21-2003, 02:24 PM
Well... There could be lots of people who hate me because I yap alot on don't do this and don't do that and the stuff... ;)