PDA

View Full Version : can someone please explain this better?



pixel_fiend
September 26th, 2002, 11:25 PM
hi,
i read this tutorial on dynamic event handlers on this site

i am still LOST as to how they work
if someone can explain this better to me (if thats possible)
i would really appreciate it

so go here and click on the dynamic event handler tute
http://www.kirupa.com/developer/actionscript/as_tricks.asp

things like :

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

make my head hurt - i WANT to understand this please help!!

thanks

flex
September 26th, 2002, 11:52 PM
From what I could understand:



onClipEvent (enterFrame){ // Every time flash starts a new frame
if (this._x<30) { // Check if the _x position of this is less than 30
this._x+=5; // and if it is move the x position 5 more to the right
}
}


this._x += 5 is the same as saying

this._x = this._x + 5.

Flash enters a new frame depending on the frames per second you have set.

pom
September 27th, 2002, 06:07 AM
Originally posted by pixel_fiend
if someone can explain this better to me (if thats possible)
i would really appreciate itAre you trying to say that I wasn't clear? http://www.kirupa.com/forums/smileys_files/grim.gif

No seriously, I tried to make it step by step. The only thing that is tricky here is the += thing, and I explained it in another AS trick.... Unfortunately the order of the articles is not correct. Sorry about that.

pom :P

eilsoe
September 27th, 2002, 07:33 AM
Actually it's not more than a week ago i figured out += and -= and so on...

It does actually save code + time...

p-fiend: Just fiddle around with it for a few days, it sinks in pretty quickly :P