{ means...?

this is probably a real newbie question but in action scripting i always see people use { and } can someone tell me what those mean and when they should be used? thx very much :slight_smile:

{} curly brackets like these are used to encapsulate a section of code. This usually occures when scripting a function and sometimes with other methods. Below is an example.

If (this==that){
doThis();
}

in this case I’ve used them with an ‘if’ statement. If the variable “this” is equal to “that”, then do whatever is inside the {}.

creating a function is done similarly.

function doThis(){
myMovieClip._x++;
}

in this case I’ve defined a function called ‘doThis’. It says, whenever the script encounters the funtion doThis, do whatever is inside the {} brackets.

It may make more sense if you see them like the following. In any case, you may contain the whole code on a single line and it will behave exactly the same as their multiline scripts above. below are the two above scripts writen on a single line.

If (this==that){doThis();}

function doThis(){myMovieClip._x++;}

Hope that helps.

cool i getit now thx very much