Search code examples
flashactionscript-3actionscript

Call a public function (NOT in the MAIN) from another Class like showTheThumbs


Can I call a class public function from another class? What is the cleanest solution to do that?

for example:

Main -------------------------- Menu
                                  |---------- buttonClicks

     -------------------------- Thumbs
                                   |--------- showTheThumbs

a button which is instanced in Menu, run showTheThumbs method, in Thumbs.


Solution

  • use an event

    When working with Flex, you accomplish these things by dispatching an event and listening to it from another class.

    This way, your classes are loosely coupled and nothing will break when you'll change something.