dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [F9] Overriding x and y in Sprite-extending class?

  1. #1
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188

    [Resolved] [F9] Overriding x and y in Sprite-extending class?

    I have a class that's extending the Sprite class. I was trying to create getter/setter functions for x and y, that would return/modify super.x and super.y, and do some other things - but apparantly x and y are final properties, so I can't override them.

    There doesn't seem to be an event for this either, so I'm a bit stuck. Off course I could create some other properties (myX and myY for instance), but that's not very clean. Any other options?

    Thanks!
    Last edited by Fall_X; 07-15-2006 at 08:28 PM.

  2. #2
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    Nevermind, still not completely used to AS3, so I didn't know I had to use the override keyword. I thought a property would override by default if it had the same name. Pretty stupid
    Last edited by Fall_X; 07-15-2006 at 08:29 PM.

  3. #3
    Member
    Join Date
    Jul 2006
    Posts
    50
    Uhm... I'm not gonna look into AS3 until my AS2 knowledge gets a lot better, but after looking into the migration tutorial on Adobe site I've seen addProperty which was used to use at same time a getter and setter has been removed. Wasn't addProperty a good idea or efficient at all? dunno, it seems so to me. Again, as I said in a thread some time ago, my OOP knowledge is basic, know a bit of applying it using AS1 through _prototype, __proto__ and all that (some time after I decided to learn AS I was given the old New Riders' 'OOP Programming with ActionScript' book), but haven't looked into classes, and OOP with flash 8.

    Well... anyway, surely my suggestion of using addProperty wouldn't have worked even tho heh.
    Last edited by Neverbirth; 07-15-2006 at 09:50 PM.

  4. #4
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    I think addProperty has been removed since actionscript 2
    haven't looked into classes, and OOP with flash 8.
    AS2 isn't a flash8 thing, it was there in mx (well, mx 2004 professional anyway, not sure at which point it was added).

    I suggest you start learning AS2 or AS3, AS1 is showing it's age. You can still make games with it off course, but you're really limiting yourself.

  5. #5
    Senior Member
    Join Date
    Jun 2001
    Posts
    290
    but from what I read/hear, AS1 is often faster then AS2 ......

  6. #6
    Member
    Join Date
    Jul 2006
    Posts
    50
    Quote Originally Posted by Fall_X
    I think addProperty has been removed since actionscript 2
    AS2 isn't a flash8 thing, it was there in mx (well, mx 2004 professional anyway, not sure at which point it was added).
    I know, just that most tutorials I have are titled as "OOP in Flash 8" and I guess that got "engraved" in my mind heh.

    Quote Originally Posted by Fall_X
    I suggest you start learning AS2 or AS3, AS1 is showing it's age. You can still make games with it off course, but you're really limiting yourself.
    I know, don't worry :P, I'm doing "so", dunno, I learn both things, sometimes I like reading old tutorials and then advance to newer ones like if I were learning when AS2 was just released (a stupid obsessions I have... :P), also, I try to learn a bit of everything, well, I like games, and in fact that was the reason that brought my attention to learn Flash programming, but I also "play" with the programming of any other sort of thing (except for sound... in fact, I know nothing of sound with Flash yet... but it's mainly because I have no sound card since several months ago ^^U lol).

  7. #7
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    Quote Originally Posted by pentru
    but from what I read/hear, AS1 is often faster then AS2 ......
    Haven't done any benchmarking, I heard AS2 was two times faster than AS1, but I doubt it since AS2 is compiled into AS1. So yeah, some aspects of AS2 are probably slower than AS1, but I doubt it would make much of a difference. Creating an object might take a tiny bit longer, but you usually don't create multiple objects each frame.
    I personally couldn't do a project without OO anymore. It might be faster to get up and running sometimes, but as the project grows, it gets harder and harder to maintain. So for a quick prototype I might still do it so I don't have to create multiple files, but as soon as I decide to make the game, I would convert everything into objects, or start over alltogether.

    If performance is that much of an issue, you should go for AS3 anyway, which is a lot faster and completely OO.

  8. #8
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Moved to AS3 forum.

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