# General coding questions

**URL:** <https://forum.kirupa.com/t/general-coding-questions/265000>\
**Category:** flash\
**Created:** [July 2, 2008, 8:51pm UTC](https://forum.kirupa.com/t/general-coding-questions/265000 "2008-07-02T20:51:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aforeigner](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@aforeigner](https://forum.kirupa.com/u/aforeigner)\
**Post date:** [July 2, 2008, 8:51pm UTC](https://forum.kirupa.com/t/general-coding-questions/265000/1 "2008-07-02T20:51:40Z")

</div>

I’m a noob when it comes to coding, and I’m wondering if there’s a book or online resource that I can look at for a general coding guide, because everything I know comes from either this site or from some javaScript, asp, and htmlDOM tutorials.

Some specific questions, specifically referencing Kirupa’s Animating Dynamic MovieClips in CS3:

-When do I need to label a function’s output as void? such as:  
function Main() or function ZoomCircle(e:Event):void

-I’m thinking that circleMC:MovieClip is adding circleMC to the MovieClip class, but I’m not sure what the e.target accomplishes. e seems to come up a lot, followed by a “.” or a “:” but I don’t know why it needs a “.” versus a “:”  
var circleMC:MovieClip = MovieClip (e.target);  
[slight change to the question. I’m thinking that “e” is a local variable, but I still don’t understand e.target]

anyways, thanks for the help.

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [July 2, 2008, 9:35pm UTC](https://forum.kirupa.com/t/general-coding-questions/265000/2 "2008-07-02T21:35:53Z")

</div>

> -When do I need to label a function’s output as void? such as:  
> function Main() or function ZoomCircle(e:Event):void

You never _need_ to give a function a return type unless you’re overriding an older method. However, it is considered best practice to type functions, and _void_ is used to indicate that no value is ever returned from the function. That means that you either use the _return_ statement somewhere in your function with no value after it, or you never use the return statement at all.

> -I’m thinking that circleMC:MovieClip is adding circleMC to the MovieClip class, but I’m not sure what the e.target accomplishes. e seems to come up a lot, followed by a “.” or a “:” but I don’t know why it needs a “.” versus a “:”  
> var circleMC:MovieClip = MovieClip (e.target);

In this context, the colon use is part of ActionScript’s postcolon syntax for declaring the type of a variable. _circleMC_ isn’t really being added to the MovieClip class, but the compiler is being told what to expect from that variable in terms of which methods it has and where it should be used.

_e_ is usually the name of the parameter of a function that’s being used as a handler as part of AS3’s event system. It stores information relevant to the event that has just occurred. The Event class’s _target_ property is described pretty well in the documentation: The event target. This property contains the target node. For example, if a user clicks an OK button, the target node is the display list node containing that button.

The dot accesses object properties.

---

<div class="post-metadata">

**Author:** ![aforeigner](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@aforeigner](https://forum.kirupa.com/u/aforeigner)\
**Post date:** [July 2, 2008, 11:31pm UTC](https://forum.kirupa.com/t/general-coding-questions/265000/3 "2008-07-02T23:31:13Z")

</div>

thanks for the description.

as for _e_, are you saying that it is just common practice to use that when dealing with an event? I was looking at some other tutorials, and they were using _evt_ in that spot.

as for the different properties, methods, and parameters, is there a list somewhere online that just has a list of different options, and which classes they apply too?

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [July 2, 2008, 11:56pm UTC](https://forum.kirupa.com/t/general-coding-questions/265000/4 "2008-07-02T23:56:03Z")

</div>

It’s just a variable name. _e_ is nice and short, and a good convention, but it could be almost anything. If you like calling your events _monkeyToes_ that’d work too.

```auto

function onMouseClick(monkeyToes:MouseEvent):void
{
     trace("I should have used 'e'!");
}

```

---

<div class="post-metadata">

**Author:** ![dthought](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dthought/32/3573_2.png) [@dthought](https://forum.kirupa.com/u/dthought)\
**Post date:** [July 3, 2008, 12:15am UTC](https://forum.kirupa.com/t/general-coding-questions/265000/5 "2008-07-03T00:15:21Z")

</div>

Personally, I tend to not use just the letter “e” for event returns (using “evt” instead as “event” is a reserved word) - single letter variables are best left as loop iterators (counters) 🙂

I’d recommend you grab a copy of Essential ActionScript 3.0 by Colin Moock, pub. O’Reilly. Lots of good information in there.

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [July 3, 2008, 12:24am UTC](https://forum.kirupa.com/t/general-coding-questions/265000/6 "2008-07-03T00:24:13Z")

</div>

It’s really a personal choice. As far as I’m concerned, there’s no good reason to type more than a single character, and _e_ does the trick nicely. _evt_ is fine too, but really, why make it longer? There are still 25 other letters if you need loop iterators.

---

<div class="post-metadata">

**Author:** ![matlevy](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@matlevy](https://forum.kirupa.com/u/matlevy)\
**Post date:** [July 3, 2008, 12:47am UTC](https://forum.kirupa.com/t/general-coding-questions/265000/7 "2008-07-03T00:47:03Z")

</div>

[QUOTE=aforeigner;2352633]  
-When do I need to label a function’s output as void? such as:  
function Main() or function ZoomCircle(e:Event):void  
[/QUOTE]

It’s general practice (expecially when writing classes) that you type functions. A Type void indicates there is no returned type from the function.

[QUOTE=aforeigner;2352633]  
-I’m thinking that circleMC:MovieClip is adding circleMC to the MovieClip class, but I’m not sure what the e.target accomplishes. e seems to come up a lot, followed by a “.” or a “:” but I don’t know why it needs a “.” versus a ":"  
var circleMC:MovieClip = MovieClip (e.target);  
[/QUOTE]

(e) is a general parameter name when constructing functions as for event listeners, eg.

```auto
foo.addEventListener(SomeEvent.Type, myFunction)

function myFunction(e:SomeEvent):void
{
  e.target
}

```

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [July 3, 2008, 10:31am UTC](https://forum.kirupa.com/t/general-coding-questions/265000/8 "2008-07-03T10:31:02Z")

</div>

> [@aforeigner](#):
>
> as for the different properties, methods, and parameters, is there a list somewhere online that just has a list of different options, and which classes they apply too?

Well… there is the language reference: [http://livedocs.adobe.com/flex/3/langref/index.html](http://livedocs.adobe.com/flex/3/langref/index.html)

> [@Anogar](#):
>
> There are still 25 other letters if you need loop iterators.

…and something is probably wrong in your code if you are running out of letters for nested iterators. 😛
