RE: [Flashcoders] First attempts at wirting code in AS2
Thanks Steven This extends MovieClip solution looks interesting, I will investigate this further. I am having trouble getting my head around the separation of the timeline elements with the classes. Thanks Paul -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: 17 July 2006 20:17 To: Flashcoders mailing list Subject: RE: [Flashcoders] First attempts at wirting code in AS2 You need to declare your class variables before you use them: class GameObject extends MovieClip { var little_stars_mc:MovieClip; var game_number:Number; function GameObject() { game_number = 1; little_stars_mc.gotoAndStop("game" + game_number); } } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] First attempts at wirting code in AS2
You need to declare your class variables before you use them: class GameObject extends MovieClip { var little_stars_mc:MovieClip; var game_number:Number; function GameObject() { game_number = 1; little_stars_mc.gotoAndStop("game" + game_number); } } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] First attempts at wirting code in AS2
Classes don't share scope with the main timeline. You should pass in little_stars_mc as an argument to the Constructor when you create your Class, then store it as a member variable so all your methods have access to it. The fact that it worked before with AS 1.0 was merely a side-effect of the less strict scoping rules. A little time spent reading some OOP books will save you hours of frustration in the long run. In addition to "Essential AS 2.0", you might check out "Object-Oriented Actionscript" from New Riders. By the way, this sort of question is probably more appropriate for the Flash Newbie board. :) -Adam On 7/14/06, Paul Steven <[EMAIL PROTECTED]> wrote: public function Initialise_Game1_Demo():Void { Game_Number = 1; little_stars_mc.gotoAndStop game" + Game_Number); } } I am getting the following error There is no method with the name 'little_stars_mc'. little_stars_mc.gotoAndStop("game" + Game_Number); I presume I am doing something fundamentally wrong here so would appreciate any advice. Many thanks Paul ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com