A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Help me understand this code!

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    2

    Help me understand this code!

    Here's the link with the example and code:
    http://www.zebra0.com/actionscript/e...all-cursor.php

    Basically, what happens is that the ball follows wherever you click. I'm pretty new to actionscript, and I'm trying to break this down and understand completely how it works. I know all the terminology ie where variables are declared, functions, eventlisteners, math etc, but i don't understand how this values allow it to work.

    For example, what's up with the variable "dx" and "dy"? Why are they 0 and if they are zero, then how come for the function "frame", the "minx" and "max" vars have Math.abs(dx/dy) added to it if dx=dy=0? Doesn't make sense. Thanks for clearing all of this stuff out.

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    923
    Quote Originally Posted by littlemonster View Post
    For example, what's up with the variable "dx" and "dy"? Why are they 0
    Only initially; you can see that they are reset to different value in setGoal() function.

    Quote Originally Posted by littlemonster View Post
    and if they are zero, then how come for the function "frame", the "minx" and "max" vars have Math.abs(dx/dy) added to it if dx=dy=0?
    There is no Math.abs(dx/dy) in the frame() code. Only Math.abs(dx) and Math.abs(dy).
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Quote Originally Posted by realMakc View Post
    Only initially; you can see that they are reset to different value in setGoal() function.

    There is no Math.abs(dx/dy) in the frame() code. Only Math.abs(dx) and Math.abs(dy).
    Well, thanks, that's what I meant for the second one because i was too lazy to write it all out

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center