Results 1 to 7 of 7

Thread: Question about stage.addchild from within a class.

  1. #1

    Question about stage.addchild from within a class.

    Hi, i'm trying to teach me some flash i've done some .net programming mostly data Analysis and control program for lab equipment, well now to the point.

    I'm trying to make a little strategy game. And i've made a class that displays a menu when you click on a city it also controls what's shown in that menu basically display data that's in the "city" class. I haven't used classes before for anything except storing data so i had problems adding the menu to the stage but fixed it by adding everything that was null as an argument.
    Code:
    public function build_menu(e:MouseEvent,info_format:TextFormat,c_menu:MovieClip,STAGE:Stage):void {here is code}
    It's works now but i'm wondering if there are better ways to do this.
    I tried parent.stage but that didn't work.
    Thnx in advance.

  2. #2
    TheCanadian's Avatar
    10,245
    posts
    Noo doot aboot it, eh?
    I don't know if I'd call it a better way, but I'd try and remove dependency on the stage from within the class. I also wouldn't add any children directly to the stage.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  3. #3
    I wouldn't use Stage ether. I have my Registry class to hold display Containers references there. you function will be
    Code:
    public function build_menu(e:MouseEvent,info_format:TextFormat,c_menu:MovieClip,container:DisplayObjectContainer):void {here is code}

  4. #4
    TheCanadian's Avatar
    10,245
    posts
    Noo doot aboot it, eh?
    Well I was trying to say that I'd remove dependency from as many objects as possible.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  5. #5
    Quote Originally Posted by TheCanadian View Post
    Well I was trying to say that I'd remove dependency from as many objects as possible.

    What is dependency means?

  6. #6
    TheCanadian's Avatar
    10,245
    posts
    Noo doot aboot it, eh?
    I doubt I'd explain it better than a dictionary
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  7. #7
    Hey thanks for all the replies. Yeah i will try to remove most dependency. Half of the stuff i could just put into the class itself.
    I have one layer that's a map that serves as the container for units ,cities and info that appears on mouse over.
    I was adding menus to the stage so they would stay on top in the same position without having to do much coding.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012