Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Class Not Working

    Hello, the following code causes the error "the private attribute may only be used on class property definitions".

    Code:
    package 
    {
    	import flash.display.Bitmap;
    	import flash.display.Sprite;
    	import flash.events.Event;
    	
    	/**
    	 * ...
    	 * @author Miles Mancinelli
    	 */
    	public class Main extends Sprite 
    	{
    		
    		public function Main():void 
    		{
    			if (stage) init();
    			else addEventListener(Event.ADDED_TO_STAGE, init);
    		}
    		
    		private function init(e:Event = null):void 
    		{
    			removeEventListener(Event.ADDED_TO_STAGE, init);
    			[Embed(source = "media/tile.png")]
    			private var Tile:Class;
    
    			var myVerySmallOneLineMap:Array = [1,1,1,0,1,1,1];
    			var tileHeight:int = 50;
    			var tileWidth:int = 50;
    
    			for (var i:int = 0; i < myVerySmallOneLineMap.length; i++)
    			{
    			if (myVerySmallOneLineMap[i] == 1)
    			{
    				var tile:Bitmap = new Tile();
    				tile.x = i * (tileWidth - 1);
    				tile.y = 0;
            
    				addChild();
    			}
    			
    			}
    		}
    		
    	}
    	
    }
    The error is somewhere in:

    Code:
    [Embed(source = "media/tile.png")]
    private var Tile:Class;
    Ideas?

  • #2
    Regular Coder Stooshie's Avatar
    Join Date
    Mar 2008
    Location
    Dundee, Scotland
    Posts
    378
    Thanks
    9
    Thanked 39 Times in 39 Posts
    In the method init you can't define the property Tile as private. Remove the private from the definition or define the property as private at the top of the class.
    Regards, Stooshie
    O


  •  

    Tags for this Thread

    Posting Permissions

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