Can someone explain this code?

[FONT=Calibri][SIZE=3]I thought I knew a little bit about actionscript 3.0 but after looking at this code I know how much I do not know.[/SIZE][/FONT]
[SIZE=3][FONT=Calibri]This code was posted by “pensamente” a user from this forum, it works great thanks. There is something in this code that I do not understand and this is the used of the word *as. *[/FONT][/SIZE]

[FONT=Calibri][SIZE=3]Contens1 as [COLOR=blue]MovieClip[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Contents2 as [COLOR=blue]MovieClip[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Contents3 as [COLOR=blue]MovieClip[/COLOR][/SIZE][/FONT]

[FONT=Calibri][SIZE=3]I notice that if I delete the word “as” the animation does not work properly ( no error messages it just not work) why?.[/SIZE][/FONT]

[FONT=Calibri][SIZE=3]Would someone be so kind and explain?[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]thanks,[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]fs_tigre[/SIZE][/FONT]

[FONT=Calibri][SIZE=3]Original post:[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]http://kirupa.com/forum/showthread.php?t=302510[/SIZE][/FONT]

[COLOR=blue][FONT=Courier New]import[/FONT][/COLOR][COLOR=black][FONT=Courier New] gs.[/FONT][/COLOR][COLOR=navy][FONT=Courier New]TweenLite[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]

[FONT=Courier New][COLOR=black]var last_cont:[/COLOR][/FONT][COLOR=blue][FONT=Courier New]MovieClip[/FONT][/COLOR][COLOR=black][FONT=Courier New] = new [/FONT][/COLOR][COLOR=blue][FONT=Courier New]MovieClip[/FONT][/COLOR][COLOR=black]FONT=Courier New;[/FONT][/COLOR]

[COLOR=blue][FONT=Courier New]this[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]contents1[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]content_txt[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=blue][FONT=Courier New]text[/FONT][/COLOR][COLOR=black][FONT=Courier New] = [/FONT][/COLOR][COLOR=red][FONT=Courier New]“contents / 01”[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]this[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]contents2[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]content_txt[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=blue][FONT=Courier New]text[/FONT][/COLOR][COLOR=black][FONT=Courier New] = [/FONT][/COLOR][COLOR=red][FONT=Courier New]“contents / 02”[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]this[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]contents3[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]content_txt[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=blue][FONT=Courier New]text[/FONT][/COLOR][COLOR=black][FONT=Courier New] = [/FONT][/COLOR][COLOR=red][FONT=Courier New]“contents / 03”[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]

[COLOR=blue][FONT=Courier New]this[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]c1_btn[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]addEventListener[/FONT][/COLOR][COLOR=black][FONT=Courier New](MouseEvent.[/FONT][/COLOR][COLOR=navy][FONT=Courier New]CLICK[/FONT][/COLOR][COLOR=black][FONT=Courier New], menuClick);[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]this[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]c2_btn[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]addEventListener[/FONT][/COLOR][COLOR=black][FONT=Courier New](MouseEvent.[/FONT][/COLOR][COLOR=navy][FONT=Courier New]CLICK[/FONT][/COLOR][COLOR=black][FONT=Courier New], menuClick);[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]this[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]c3_btn[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=navy][FONT=Courier New]addEventListener[/FONT][/COLOR][COLOR=black][FONT=Courier New](MouseEvent.[/FONT][/COLOR][COLOR=navy][FONT=Courier New]CLICK[/FONT][/COLOR][COLOR=black][FONT=Courier New], menuClick);[/FONT][/COLOR]

[FONT=Courier New][COLOR=black]function menuClick ([/COLOR][/FONT][COLOR=blue][FONT=Courier New]e[/FONT][/COLOR][COLOR=black][FONT=Courier New]:Event):[/FONT][/COLOR][COLOR=blue][FONT=Courier New]void[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]{[/COLOR][/FONT]
[COLOR=blue][FONT=Courier New]trace[/FONT][/COLOR][COLOR=black][FONT=Courier New]([/FONT][/COLOR][COLOR=blue][FONT=Courier New]e[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=blue][FONT=Courier New]target[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=blue][FONT=Courier New]name[/FONT][/COLOR][COLOR=black][FONT=Courier New])[/FONT][/COLOR]

[COLOR=blue][FONT=Courier New]switch[/FONT][/COLOR][COLOR=black][FONT=Courier New] ([/FONT][/COLOR][COLOR=blue][FONT=Courier New]e[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=blue][FONT=Courier New]target[/FONT][/COLOR][COLOR=black][FONT=Courier New].[/FONT][/COLOR][COLOR=blue][FONT=Courier New]name[/FONT][/COLOR][COLOR=black][FONT=Courier New]) {[/FONT][/COLOR]

[COLOR=blue][FONT=Courier New]case[/FONT][/COLOR][COLOR=red][FONT=Courier New]“c1_btn”[/FONT][/COLOR][COLOR=black][FONT=Courier New]:[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]TweenLite.[/COLOR][/FONT][COLOR=navy][FONT=Courier New]to[/FONT][/COLOR][COLOR=black][FONT=Courier New](contents1, [/FONT][/COLOR][COLOR=navy][FONT=Courier New]2[/FONT][/COLOR][COLOR=black][FONT=Courier New], {y:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]100[/FONT][/COLOR][COLOR=black][FONT=Courier New], alpha:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]1[/FONT][/COLOR][COLOR=black][FONT=Courier New]});[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]TweenLite.[/COLOR][/FONT][COLOR=navy][FONT=Courier New]to[/FONT][/COLOR][COLOR=black][FONT=Courier New](last_cont, [/FONT][/COLOR][COLOR=navy][FONT=Courier New]2[/FONT][/COLOR][COLOR=black][FONT=Courier New], {y:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]0[/FONT][/COLOR][COLOR=black][FONT=Courier New], alpha:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]0[/FONT][/COLOR][COLOR=black][FONT=Courier New]});[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]last_cont = contents1 as [/COLOR][/FONT][COLOR=blue][FONT=Courier New]MovieClip[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]break[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]case[/FONT][/COLOR][COLOR=red][FONT=Courier New]“c2_btn”[/FONT][/COLOR][COLOR=black][FONT=Courier New]:[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]TweenLite.[/COLOR][/FONT][COLOR=navy][FONT=Courier New]to[/FONT][/COLOR][COLOR=black][FONT=Courier New](contents2, [/FONT][/COLOR][COLOR=navy][FONT=Courier New]2[/FONT][/COLOR][COLOR=black][FONT=Courier New], {y:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]100[/FONT][/COLOR][COLOR=black][FONT=Courier New], alpha:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]1[/FONT][/COLOR][COLOR=black][FONT=Courier New]});[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]TweenLite.[/COLOR][/FONT][COLOR=navy][FONT=Courier New]to[/FONT][/COLOR][COLOR=black][FONT=Courier New](last_cont, [/FONT][/COLOR][COLOR=navy][FONT=Courier New]2[/FONT][/COLOR][COLOR=black][FONT=Courier New], {y:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]0[/FONT][/COLOR][COLOR=black][FONT=Courier New], alpha:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]0[/FONT][/COLOR][COLOR=black][FONT=Courier New]});[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]last_cont = contents2 as [/COLOR][/FONT][COLOR=blue][FONT=Courier New]MovieClip[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]break[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]case[/FONT][/COLOR][COLOR=red][FONT=Courier New]“c3_btn”[/FONT][/COLOR][COLOR=black][FONT=Courier New]:[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]TweenLite.[/COLOR][/FONT][COLOR=navy][FONT=Courier New]to[/FONT][/COLOR][COLOR=black][FONT=Courier New](contents3, [/FONT][/COLOR][COLOR=navy][FONT=Courier New]2[/FONT][/COLOR][COLOR=black][FONT=Courier New], {y:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]100[/FONT][/COLOR][COLOR=black][FONT=Courier New], alpha:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]1[/FONT][/COLOR][COLOR=black][FONT=Courier New]});[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]TweenLite.[/COLOR][/FONT][COLOR=navy][FONT=Courier New]to[/FONT][/COLOR][COLOR=black][FONT=Courier New](last_cont, [/FONT][/COLOR][COLOR=navy][FONT=Courier New]2[/FONT][/COLOR][COLOR=black][FONT=Courier New], {y:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]0[/FONT][/COLOR][COLOR=black][FONT=Courier New], alpha:[/FONT][/COLOR][COLOR=navy][FONT=Courier New]0[/FONT][/COLOR][COLOR=black][FONT=Courier New]});[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]last_cont = contents3 as [/COLOR][/FONT][COLOR=blue][FONT=Courier New]MovieClip[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]break[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]}[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]}[/COLOR][/FONT]

The as operator is used to perform conversions between compatible types. It’s like a cast except that it yields null on conversion failure instead of raising an exception.

The compiler probably doesn’t know that contents1 is a MovieClip so that is just a way to typecast it.

[QUOTE=yaim0310;2355434]The as operator is used to perform conversions between compatible types. It’s like a cast except that it yields null on conversion failure instead of raising an exception.

The compiler probably doesn’t know that contents1 is a MovieClip so that is just a way to typecast it.[/QUOTE]

Thank you!!

So, it is part of actionscript 3.0

content as MovieClip

is pretty much the same thing as

MovieClip(content)

You can also use the help in Flash, as it gives a decent enough explanation when it comes to detailing simpler language elements (eg. as, for, in etc. :))

From the description in: Programming AS3 / Language Elements / Operators / as

Evaluates whether an expression specified by the first operand is a member of the data type specified by the second operand. If the first operand is a member of the data type, the result is the first operand. Otherwise, the result is the value null.

An operand is just something that is used in an operation. It can be a number, a string, an object, whatever. For example, in the equation 5 + 3, the numbers 5 and 3 are operands.

Thanks you very much to all.