PDA

View Full Version : how do u know where to put A/s



NewbiEFlasheR
November 3rd, 2003, 08:30 PM
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?

babywax
November 4th, 2003, 12:43 AM
It depends completely on the AS and where it was meant to be put.

pom
November 4th, 2003, 07:20 AM
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 :)

babywax
November 4th, 2003, 07:42 AM
Maybe for most people, but I'm a fan of the "this" object hehe.

eki
November 4th, 2003, 08:02 AM
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?

babywax
November 4th, 2003, 08:05 AM
I don't think I can take code from a MC with something like this:

onClipEvent(enterFrame) {
this._x += 5;
}

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...

eki
November 4th, 2003, 08:07 AM
And why don't u use:


myMovieClip.onEnterFrame = function(){
trace("this: "+this);
this._x += 5;
}

eki
November 4th, 2003, 08:11 AM
or even better:


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



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

Voetsjoeba
November 4th, 2003, 12:08 PM
I always code on timelines. Makes the use of variables so much easier. And, the double scope is very handy too :thumb:

kode
November 5th, 2003, 02:24 AM
Originally posted by eki
or even better:

[code]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 _parent (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary561.html) property already!? :sigh:

:P

Maizoon
November 5th, 2003, 08:36 PM
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.

pom
November 6th, 2003, 07:02 AM
http://www.kirupa.com/developer/actionscript/tricks/include.htm

Voetsjoeba >> Double scope? What do you mean?

Kode >> That's a good question :P