# ActionScript 2 hints

**URL:** <https://forum.kirupa.com/t/actionscript-2-hints/89467>\
**Category:** flash\
**Created:** [September 10, 2003, 2:15pm UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467 "2003-09-10T14:15:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Jr](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@Eric\_Jr](https://forum.kirupa.com/u/Eric_Jr)\
**Post date:** [September 10, 2003, 2:15pm UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/1 "2003-09-10T14:15:57Z")

</div>

Hello everybody,

I took the liberty to sum up a few Hints, tips, pointers, facts, call them whatever you want, about Flash ActionScript 2.  
This is the new ActionScript language, and it will raise alot of new questions here on the boards. Hopefully this thread will help out.

Please feel free to append as many tips as you want.

[list=1]  
[\*]**When using classes, each individual class should be in their own file. (with .as extension).**  
This also goes for subclasses, (classes that extend another class)

[\*] **The filename of a class should be the same as the classname.**  
When creating a instance of your class, Flash looks for the filenames when compiling the .swf.

[\*] **When importing classes, the path should also be defined inside the class**  
So importing a class from a subfolder, the class should be defined like:

```auto
class subfolder.classname{}

```

[\*] **ActionScript 2 is Case Sensitive**  
Variables, Classes, Objects, Functions, they should all be indentified with the declared name. Case sensitive.

[\*] **ActionScript 1 is Case Sensitive**  
Although ActionScript 1 remains the same, it is case sensitive if the SWF is published with ActionScript 2 support.  
So no more “movieclip.prototype”, cause the class movieclip is declared like “MovieClip”

[\*] **In classes, “this” refers the the instance, not to the class.**  
That means that “this” contains a different value in each instance, but as a property it behaves the same.

[\*] **Properties don’t require “this” in front of them.**  
When accessing Properties and Variables from a class, “this” isn’t required anymore, the var is recognized by the class.

[\*] **Constructors cannot have a return value.**  
When using constructor functions in a class, you cannot return a value. And if you use strict data typing:

```auto
function classname(): Void

```

will cause a compiler error aswell.

[\*] **Strict data typing is not required.**  
Just handy for the programmer! :p:

[\*] **Private vars are also accessible from subclasses.**  
Private vars and functions can be accessed from the class itself, or subclasses. You can even make a private var public from a subclass.

[\*] **"#include" inside a class adds the content to the body of that class.**  
It cannot be declared in a function though, it has to be in the body of the class.

[\*] **Properties should only be initialized in the constructor.**

```auto
var valuelist: Array = new Array();

```

Does work, but Flash gets mixed up if you use multiple instances in one keyframe.

[\*] **Flash MX built in classes are NOT dynamic.**  
So extending Math like this doesn’t work anymore.

```auto
Math.afunction = function() { }

```

[\*] **Interfaces cannot contain properties.**  
Variables and properties should be declared in the Class Header.

[\*] **Interfaces can only provide static public functions.**  
You can’t define any dynamic functions in an interface.

[\*] **Get and Set aren’t allowed in interfaces.**  
Because they make a function behave as a property, they are not allowed in interfaces.

[\*] **Interface functions can also be in subclasses**  
Although all functions that are declared in an interface must be defined, they do not have to be inside the class, but the instance. This means those functions can also be inherited by a superclass.

[\*] **Interfaces can be object types.**  
The following example is allowed:

```auto
var instance: Interfacename = new Classname(); is allowed.

```

[\*] **Classes should operate independantly of the .swf.**  
Don’t specify “\_root”, in a class, but set a parameter for the path instead. This is not required, but I’ve put this in because its a part of a class’ OOP interface.

[\*] **SetInterval only works on the instance, not on the class.**  
To add a interval to your instance, you need to give the instancename as a parameter to the SetInterval function.  
Call the instance name with “this”, like so:

```auto
setInterval(this, "functioname", interval, [additional parameters]);

```

[\*] **ActionScript 2 works in the latest Flash 6 Player.**  
Just 10 till 30 percent slower :crazy:

[\*] **ActionScript 2 doesn’t get highlighted on the Kirupa Forums et.**  
:azn:

[\*] **Macromedia acknowledged that ActionScript 2 is for experience ActionScript programmers.**  
Don’t attempt to learn it, if you do not fully comprehend all the aspects of ActionScript 1.  
[/list=1]

This turned out quite longer then I expected from myself.  
Maybe this would make a nice STICK thread 🙂

Many greetings, check my Review for more ActionScript 2 info  
[here](http://downloads.junioronline.us/flash_mx_review.html).

Eric Jr - junioronline!!!

==========================================

For more on Actionscript 2.0, don’t forget to check out the Kirupa AS2.0 tutorial here:  
[[color=blue]http://www.kirupa.com/developer/oop2/AS2OOPindex.htm[/color]](http://www.kirupa.com/developer/oop2/AS2OOPindex.htm)

and the _Flash MX 2004 and ActionScript 2.0 Tutorials: The Definitive List_ here:  
[[color=blue]http://www.actionscripthero.com/adventures/index.php?c=2[/color]](http://www.actionscripthero.com/adventures/index.php?c=2)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 2, 2003, 3:28pm UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/2 "2003-11-02T15:28:45Z")

</div>

In case you want to use some of the new components, here’s the new code hints (some at least…):  
\_acp = accordion pane  
\_txf = textfield  
\_sld = slider  
\_wkv = week view  
\_tbv = tab view

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 12, 2003, 3:44pm UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/3 "2003-11-12T15:44:38Z")

</div>

While the underscore+TLA still works to get code hints, the recommended technique is to use strong data typing. Not only do you get code hints, but you’ll have an easier time tracking down errors in your code if you make strong data typing habit.

:nerd:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 30, 2004, 11:12pm UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/4 "2004-07-30T23:12:31Z")

</div>

Hmm. I never learned AS1. Would I suck at AS2 if I bought a book on it and studied it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 30, 2004, 11:19pm UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/5 "2004-07-30T23:19:05Z")

</div>

you would understand AS2 better knowing AS1, and really, AS2 is just an extension, or an alternate means of class creation _for_ AS1. It replaces the methods used in OOP coding with AS1, though they still work when using AS2.

So learning AS2 is learning a part of AS, and if you get a book on AS2 that teaches not just AS2 but AS from a beginners level, then you wont miss much from not knowing how to do things (in OOP) the old fashioned way. You just have to make sure you have enough background to handle whatever is required for AS2 as said book intends to teach it.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 30, 2004, 11:58pm UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/6 "2004-07-30T23:58:01Z")

</div>

> [@bet444](#):
>
> Is there a way to choose between AS1 and AS2 in MX 2004?  
> Sorry for the stupid question, but I prefer AS1. So I`d like to know…

You can not really use the new components with out at least compiling to AS2.

-Ken

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 31, 2004, 12:10am UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/7 "2004-07-31T00:10:48Z")

</div>

> [@MilkMonkey](#):
>
> Hmm. I never learned AS1. Would I suck at AS2 if I bought a book on it and studied it?

The procedural programming in AS2 is very much like AS1. The OOP of AS2 in classes is pretty different then AS1 an in many ways more strait forward and similar to other programming languages. Any book you get on AS2 should cover what you need from AS1 before getting into the topics specific to AS2. If you don’t have a need to code specifically to Player 6 then you would be better off just diving right in.

Good luck!

-Ken

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2004, 1:23am UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/8 "2004-08-01T01:23:59Z")

</div>

Ok thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2004, 1:24am UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/9 "2004-08-01T01:24:32Z")

</div>

Anybody know of any good AS2 books?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 10:50am UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/10 "2004-08-27T10:50:16Z")

</div>

hello Friends  
i know that what is “lMouseover” in this code.

onClipEvent ( enterFrame ) {  
if (lMouseover) {  
\_root.sText3.scroll += 1;  
}  
}

with Regards  
Manish kumar

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 11:15am UTC](https://forum.kirupa.com/t/actionscript-2-hints/89467/11 "2004-08-27T11:15:37Z")

</div>

its a custom variable originally set somewhere else.

Please ask your unrelated questions in a new thread. Thanks 😉
