all groups > flash actionscript > april 2006 >
You're in the

flash actionscript

group:

Help me make sense of this actionscript! Simple question.



Re: Help me make sense of this actionscript! Simple question. tralfaz
4/9/2006 3:11:07 PM
flash actionscript: [quoted text, click to view]

trace means "show me the value of..."
Just get rid of the trace to make the ball move.

this.ball.onEnterFrame=function() {
this.ball._x+=5;
}

Most likely you are using 'this' needlessly too..

ball.onEnterFrame=function() {
_x+=5;
trace(_x);
}

tralfaz

Re: Help me make sense of this actionscript! Simple question. tralfaz
4/9/2006 7:09:57 PM
[quoted text, click to view]

Sometimes you need an object reference to the left of the dot and you can use 'this' instead of the object name. It's highly
over-used though.
It just means 'the current object', but you have to be sure what the current object is.

// main timeline code
trace(this); // _level0 shows that 'this' is _level0

// frame code, not attached code
thing.onEnterFrame = function()
{
trace(this); // _level0.thing
this._x+=5; // 'this refers to 'thing'
_x += 5; // current object is 'thing' so it does the same thing
}

tralfaz


Help me make sense of this actionscript! Simple question. guttyguppygmail
4/9/2006 10:00:08 PM
I have a movie clip named ball on the stage. I have this script:

this.ball.onEnterFrame=function() {
trace ("hello");
}

Great, it traces hello a million times. So, why doesn't this make the ball
move across the stage?

this.ball.onEnterFrame=function() {
trace (this.ball._x+=5);
}
Argg!

Re: Help me make sense of this actionscript! Simple question. guttyguppygmail
4/9/2006 10:02:54 PM
Re: Help me make sense of this actionscript! Simple question. guttyguppygmail
4/10/2006 1:51:20 AM
Originally posted by: Newsgroup User

trace means "show me the value of..."
Just get rid of the trace to make the ball move.


Yeah, the first post was I typo; I didn't mean to say that; I guess I'm just
looking for a clear definition of "this"; when do you need it?


AddThis Social Bookmark Button