Syntax Questions

I just wanted to make sure I’m using AS right. I sort of skipped a lot of reading about syntax (although I couldn’t find many sources) because I know other languages.


Is there any way to tell a function that I’m allowed to omit a parameter, so if its not given - not to freak out and give me an error… or must I use if/else statements manually (ie. pass “null” as parameter - if(parameter == “null”) //do this)


When I pass an instance as a parameter to a function, it is only passing a reference to the object right? (eg. I can change anything in that parameter, and it changes where it came from too, aka not a copy). I thought I saw somewhere that AS usually only references the instance, and I wanted to make sure.

ie. this example shows how a function copies it over to _global.fileName, _global.fileName doesnt point to p_fileName.

[AS]_global.fileName = “yes.swf”;
trace(_global.fileName); //returns “yes.swf”

function something(p_fileName:String):Void {
_global.fileName = p_fileName;

var m_fileName:String = “no.swf”;
something(m_fileName); //returns “no.swf”

m_fileName = “both.swf”;
trace(_global.fileName); //returns “no.swf” !![/AS]

BTW, is there any way to explicitly say _global.fileName should point to p_fileName (aka. pointer or reference in C++), no matter what its changed to, it will equal that. Assuming of course p_fileName is pointing to m_fileName, hence _global.fileName is pointing to m_fileName, and they will both always equal the same thing.

Thanks, I appreciate any help I can get!