Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-25-2012, 06:37 PM   #1
tassiocaique
Registered User
 
Join Date: May 2012
Posts: 3
Default Problem with class definitions

Hello , I'm with a problem in class definition . The compiler presents the following errors :
...\Welcome.as(23): col: 4 Error: The private attribute may be used only on class property definitions.
...\Welcome.as(30): col: 4 Error: The public attribute can only be used inside a package.
...\Welcome.as(57): col: 4 Error: The public attribute can only be used inside a package.

I use the last version of the FlashDevelop, FP 11.2 , and AIR 3.2...

What the problem?
Thanks advance...

The code is the follow:

ActionScript Code:
package screens {     import starling.display.Button;     import starling.display.Image;     import starling.display.Sprite;     import starling.events.Event;         public class Welcome extends Sprite     {         private var bg:Image;         private var title:Image;         private var hero:Image;                 private var playBtn:Button;         private var aboutBtn:Button;                         public function Welcome()         {             //super();             this.addEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedToStage);                         private function onAddedToStage(event:Event):void             {                 trace ("WelcomeScreen to initialized");                                 drawScreen();             }                         public function drawScreen():void             {                 bg = new Image(Assets.getTexture("BgWelcome"));                 this.addChild(bg);                                 title = new Image(Assets.getTexture("WelcomeTitle"));                 title.x = 440;                 title.y = 20;                 this.addChild(title);                                 hero = new Image(Assets.getTexture("WelcomeHero"));                 this.addChild(hero);                 hero.x = -hero.width;                 hero.y = 100;                                 playBtn  = new Button(Assets.getTexture("WelcomePlayBtn"));                 this.addChild(playBtn);                 playBtn.x = 500;                 playBtn.y = 260;                                 aboutBtn = new Button(Assets.getTexture("WelcomeAboutBtn"));                 this.addChild(aboutBtn);                 aboutBtn.x = 410;                 aboutBtn.y = 380;                                             }                         public function initialize():void                   {                 this.visible = true;                                hero.x = -hero.width;                 hero.y = 100;             }         }     } }
tassiocaique is offline   Reply With Quote
Old 05-28-2012, 12:47 AM   #2
tango88
FlashByNight.com
 
tango88's Avatar
 
Join Date: Aug 2006
Posts: 289
Default

You forgot to close your Welcome() function.


Code:
public function Welcome() 
        {
            //super();
            this.addEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedToStage);
            
}// YOU FORGOT THIS LINE
__________________
Games and more:
Flashbynight.com | Tutes | Twitter
tango88 is offline   Reply With Quote
Old 05-28-2012, 01:53 AM   #3
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

He did not forget this line, instead he added all his function definitions inside the constructor. Inside a function definition you cannot use public, private and others. Note that nested function in AS3 is not recommended.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 05-28-2012, 06:14 AM   #4
arkitx
Senior Member
 
Join Date: Jan 2011
Posts: 703
Default

AS3 Class Structure:
ActionScript Code:
//Start Package package{     // Import External Classes     import flash.display.MovieClip;         //Start Class     public class ClassName extends MovieClip{         //Declare Properties         public var propertyName:String;                 //Start Constructor         public function ClassName(){             //.... constructor code         }//End Constructor         //Start Functions         public function functionNameA():void{             //....function A code         }         public function functionNameB():void{             //....function B code         }//End Functions     }//End Class }//End Package



__________________
Regards

arkitx

Last edited by arkitx; 05-28-2012 at 06:19 AM.
arkitx is offline   Reply With Quote
Old 05-30-2012, 10:59 AM   #5
tassiocaique
Registered User
 
Join Date: May 2012
Posts: 3
Default

Thank, the problem was solved... Thanks too for the tips , were extremely relavant to me ...
tassiocaique is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:28 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.