A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: movie clip inheritance?

  1. #1
    Member
    Join Date
    May 2000
    Location
    germany
    Posts
    55

    movie clip inheritance?

    hello out there!

    anybody knows if it is possible to accomplish
    the following task in actionscript?

    [1] create a movieClip [name: circle
    [2] create a couple of instances with actionscript on the stage
    [3] change the tint of MC circle with actionscript
    [4] all instances should inherit the new tint of parent MC circle

    ...do i need to create a new component?
    ...any ideas/help appreciated

    regards,

    deeno
    2B II ! 2B

    ...shakespear adapted to c++

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    Here you go.
    Attached Files Attached Files

  3. #3
    Member
    Join Date
    May 2000
    Location
    germany
    Posts
    55
    hi, thank you!
    really nice approach but i was thinking of a solution
    which is more elegant, using 'Object.registerClass' or
    something similar... is it possible this way or am i
    trying to accomplish something impossible and the best
    solution is the one you suggested?
    regards,
    deeno
    2B II ! 2B

    ...shakespear adapted to c++

  4. #4
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    well tint isnt aquired through a property, its given through a method of a Color object. Because of that, you would have to call that method on every instance of that clip to have each obtain the new desired color.

    Setting up your own class and handling it through that is doable. Here is an example.
    Attached Files Attached Files

  5. #5
    Member
    Join Date
    May 2000
    Location
    germany
    Posts
    55
    now this one i call an elegant solution!!!
    perfect! exactly what i was searching for!

    thank you so much!

    this helped me a lot to understand classes-objects-inheritance a bit more...

    but there are still a few questions...
    i hope you have the time to help a bit more...

    please find attached the modified .fla

    here my questions:

    question1: do i need to define a circles class for each of the 3 circles (as i did) or is there a way around that?

    question2: is it possible to control the transparency of each circle as well? how am i gonna add a new property for the transparency?

    question3: see line number 156 in frame 1

    question4: is there any good tutorial or book about classes, objects, inheritance?

    regards,
    deeno
    Attached Files Attached Files
    2B II ! 2B

    ...shakespear adapted to c++

  6. #6
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    question1: do i need to define a circles class for each of the 3 circles (as i did) or is there a way around that?

    No, not really, but you would want seperate ASBroadcaster initialized objects for each group. You could then pas in which broadcasting object is used for each instance in the constructor (or call a method to assign it - or use the init object since you are attching clips to be associated with cirlces

    question2: is it possible to control the transparency of each circle as well? how am i gonna add a new property for the transparency?

    Yeah, set up in the same manner. Properties you wouldnt have to setup like this are properties which are initially handled by a prototype value to start - these like useHandCursor and... umm cant think of any others right now

    question3: see line number 156 in frame 1

    because 'this' there refers to your button object, not the scope where your cirlces exist. For that youd want to use _root[item]. Or as I sometimes do, since that might not always be _root, timeline[item] where, at the top of the script (not in any functions) timeline is set to ... well the timeline : timeline = this; Then in that function timeline will reference that timeline whether its _root or not

    question4: is there any good tutorial or book about classes, objects, inheritance?

    ASDG is pretty much the best book to get (so I hear). Robins online Flash 5 OOP documentation is really good... but, again, its Flash 5 and a lot doesnt apply to MX. Also, search the boards. A lot has been asked about it. You'll find links and whatnot. Alternatively, you can always ask Im currently working on an intro to MX OOP but its pretty basic - for the non programmers so I dont know how much of a help it would be. To be honest Im kind of stuck with it because its hard to know just what to expect other people to know and be able to understand. we'll see

  7. #7
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    heres an adjusted file

    ... when you start getting into more properties like this, it might be easier to use just a function call rather than setting up getter/setter properties. Already its starting to get a little bulky up there with that setup.
    Attached Files Attached Files

  8. #8
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    Dear Senocular, you are the Great Master and Tutor. But do not try to teach the man algebra, if he still does not know arithmetic.
    Last edited by sergwiz; 06-08-2003 at 04:25 PM.

  9. #9
    Member
    Join Date
    May 2000
    Location
    germany
    Posts
    55
    thanx senocular!
    this is really great!

    as for sergwizs comment, i think it is a bit too ironic...
    ...how can you know what i know if you do not know what you know?...

    i think you (sergwiz) should consider that not every person
    on this planet is learning the same way...
    for me, it is easier to set a question and when i see
    the answer, i can learn from it, i can understand it...
    (otherwise i would not set my question the way i did it!)
    for me it is much easier than sitting in front of my screen
    trying to solve a problem, using a way that i know it is
    possible (OOP) but not very well documented in flashMX-help
    or elsewhere

    it is great to have persons like senocular trying to teach
    people things they want to know!

    i think this circle.fla is a good example for a tutorial about
    OOP... it has every basic question answered somebody is coming
    up with when starting with MX OOP... what do you think senocular?
    please keep me up to date about your tut.

    again thank you,
    best regards,
    deeno
    2B II ! 2B

    ...shakespear adapted to c++

  10. #10
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    Hi Deeno, I beg your pardon. I was really too ironic.
    It seemed to me that you yet didn't have enough knowledge. But if you understood Senocular's example and learned from it, - my respect.

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