# How do u know where to put A/s

**URL:** <https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568>\
**Category:** Uncategorized\
**Created:** [November 4, 2003, 1:30am UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568 "2003-11-04T01:30:41Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![NewbiEFlasheR](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@NewbiEFlasheR](https://forum.kirupa.com/u/NewbiEFlasheR)\
**Post date:** [November 4, 2003, 1:30am UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/1 "2003-11-04T01:30:41Z")

</div>

i was wondering where you put the a/s, in the layer or on the object. Whats the diffence to put a/s in the layer or on the object?

---

<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 4, 2003, 5:43am UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/2 "2003-11-04T05:43:37Z")

</div>

It depends completely on the AS and where it was meant to be put.

---

<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 4, 2003, 12:20pm UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/3 "2003-11-04T12:20:11Z")

</div>

It doesn’t really matter anymore. Now that you can give instance names to pretty much anything in Flash, it’s better to have layers of code, and nothing on the objects. That way, you can have a look at the entire code, and you’re sure you’re not forgetting anything you might have put on your objects. But it’s a matter of preference, really.

pom 🙂

---

<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 4, 2003, 12:42pm UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/4 "2003-11-04T12:42:38Z")

</div>

Maybe for most people, but I’m a fan of the “this” object hehe.

---

<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 4, 2003, 1:02pm UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/5 "2003-11-04T13:02:11Z")

</div>

And what does stop you from using it when coding on a layer?

I always code in external as files and use the ‘this’ object all the time!

hehe?

---

<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 4, 2003, 1:05pm UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/6 "2003-11-04T13:05:20Z")

</div>

I don’t think I can take code from a MC with something like this:  
[AS]  
onClipEvent(enterFrame) {  
this.\_x += 5;  
}  
[/AS]  
and put it on the layer… Unless I go through the entire code and change all the references to “this.” I guess that wouldn’t be that hard after all…

---

<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 4, 2003, 1:07pm UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/7 "2003-11-04T13:07:49Z")

</div>

And why don’t u use:  
[AS]

myMovieClip.onEnterFrame = function(){  
**trace("this: "+this);**  
this.\_x += 5;  
}  
[/AS]

---

<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 4, 2003, 1:11pm UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/8 "2003-11-04T13:11:42Z")

</div>

or even better:

[AS]  
myMovieClip.myParent = this;  
myMovieClip.onEnterFrame = function(){  
trace("this: "+this+ "this.myParent: "+this.myParent);  
this.\_x += 5;  
this.myParent.\_y -=5;  
}

[/AS]  
to have access at the same time to both myMovieClip and its parent regardless of where the MC sits

---

<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 4, 2003, 5:08pm UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/9 "2003-11-04T17:08:17Z")

</div>

I **always** code on timelines. Makes the use of variables so much easier. And, the double scope is very handy too :thumb:

---

<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 5, 2003, 7:24am UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/10 "2003-11-05T07:24:31Z")

</div>

> _Originally posted by eki_  
> \*\*or even better:

```auto
myMovieClip.myParent = this;
myMovieClip.onEnterFrame = function(){
        trace("this: "+this+ "this.myParent: "+this.myParent);
        this._x += 5;
this.myParent._y -=5;
}[/AS]
to have access at the same time to both myMovieClip and its parent regardless of where the MC sits**

... Don't you have the [[font=courier new]_parent[/font]](http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary561.html) property already!? :sigh:

:P
```

---

<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 6, 2003, 1:36am UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/11 "2003-11-06T01:36:43Z")

</div>

How do you do external AS files?

Make a file with extension .as and do a #include myfile.as in your movie? Can you put all your script into an external file then just include it? Are there any tutorials regarding this? I tried searching the forums for info on it, but couldnt really find a satisfying answer.

---

<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 6, 2003, 12:02pm UTC](https://forum.kirupa.com/t/how-do-u-know-where-to-put-a-s/34568/12 "2003-11-06T12:02:54Z")

</div>

[http://www.kirupa.com/developer/actionscript/tricks/include.htm](http://www.kirupa.com/developer/actionscript/tricks/include.htm)

Voetsjoeba \>\> Double scope? What do you mean?

Kode \>\> That’s a good question 😛
