Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-01-2010, 01:27 AM   PM User | #1
imiles
New Coder

 
Join Date: Jun 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
imiles is an unknown quantity at this point
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?
imiles is offline   Reply With Quote
Old 09-01-2010, 09:52 AM   PM User | #2
Stooshie
Regular Coder

 
Stooshie's Avatar
 
Join Date: Mar 2008
Location: Dundee, Scotland
Posts: 376
Thanks: 9
Thanked 39 Times in 39 Posts
Stooshie is on a distinguished road
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
Stooshie is offline   Reply With Quote
Reply

Bookmarks

Tags
as2, as3, classes, problem

Jump To Top of Thread


Thread Tools
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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:27 AM.


Advertisement
Log in to turn off these ads.