Results 1 to 7 of 7
-
May 2nd, 2012, 05:00 PM #12Registered User
postsQuestion 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.
It's works now but i'm wondering if there are better ways to do this.Code:public function build_menu(e:MouseEvent,info_format:TextFormat,c_menu:MovieClip,STAGE:Stage):void {here is code}
I tried parent.stage but that didn't work.
Thnx in advance.
-
May 2nd, 2012, 07:23 PM #2
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 . . .
-
May 5th, 2012, 06:38 PM #3106Registered User
postsI 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}
-
May 5th, 2012, 08:28 PM #4
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 . . .
-
May 5th, 2012, 10:03 PM #5106Registered User
posts
-
May 6th, 2012, 02:27 AM #6
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 . . .
-
May 6th, 2012, 05:26 AM #72Registered User
postsHey 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.

Reply With Quote


Bookmarks