A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Noob OOP Question

  1. #1
    I have an icon and U dont! johnwun's Avatar
    Join Date
    Nov 2000
    Location
    Santa Cruz, CA
    Posts
    258

    Noob OOP Question

    This is a general conceptual question. I've got two objects on the stage, each has been assigned a base class.

    How can I get my objects to communicate?

    I feel like I'm not getting some key concept of encapsulation here.

    I create complex inheritance chains, I use interfaces, and aggregation, but when I for instance want my "Blender" class to make my "Toaster" object toast (using "toasterInstance.toast()" ) , They may as well be in separate countries.

    Instantiating a copy of my Toaster object inside of Blender doesn't seem to make sense... What am I missing? How can Blender see my Toaster Object?
    [a.fun>b.fun ? trace("do(a)") : trace("do(b)");

    wundes.com

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    You should fire an event up to your Chef class which knows how to operate both the Blender and Toaster.

  3. #3
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,131
    He's right.
    Or if you're the type who likes your appliances to simply leverage all the other appliances around them, you can just have a Kitchen singleton class that keeps a reference to each one as a public static var, and then blender can call Kitchen.toaster and toaster can call Kitchen.blender...

  4. #4
    I have an icon and U dont! johnwun's Avatar
    Join Date
    Nov 2000
    Location
    Santa Cruz, CA
    Posts
    258
    Cool thanks... That makes more sense.
    -J
    [a.fun>b.fun ? trace("do(a)") : trace("do(b)");

    wundes.com

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