Author Topic: "The public attribute can only be used inside a package"  (Read 3888 times)

nicktarist

  • Member
  • **
  • Posts: 16
  • Karma: +0/-0
    • View Profile
I'm very new to any sort of programming.  About the most I could do was make a menu program in my TI-83 in high school.  But I decided to buckle down this year and start learning how to program, as game development is something I've always been interested in.  But I am in dire need of a hand to hold and a pillow to cry on.

I'm following the EZPlatformer tutorial over at flash game dojo and I'm having a small problem with public packages: specifically, the public function needs to be within the package.  I get that, but look:

Code: [Select]
package
{
import org.flixel.*;

public class PlayState extends FlxState
{
public var level:FlxTilemap;
public var player:FlxSprite;

override public function create():void
{
FlxG.bgColor = 0xffaaaaaa;

var data:Array = new Array(

//this is the matrix where the level design goes

level = new FlxTilemap();
level.loadMap(FlxTilemap.arrayToCSV(data,40), FlxTilemap.ImgAuto, 0, 0, FlxTilemap.AUTO);
add(level);

player = new FlxSprite(FlxG.width/2 - 5);
player.makeGraphic(10,12,0xffaa1111);
player.maxVelocity.x = 80;
player.maxVelocity.y = 200;
player.acceleration.y = 200;
player.drag.x = player.maxVelocity.x*4;
add(player);

override public function update():void
{
player.acceleration.x = 0;
if(FlxG.keys.LEFT)
player.acceleration.x = -player.maxVelocity.x*4;
if(FlxG.keys.RIGHT)
player.acceleration.x = player.maxVelocity.x*4;
if(FlxG.keys.SPACE && player.isTouching(FlxObject.FLOOR))
player.velocity.y = -player.maxVelocity.y/2;

super.update();

FlxG.collide(level,player);
}
}
}
}

This line seems to be the one causing all the trouble:

Code: [Select]
override public function update():void
It tells me that the public function can only be used inside the package.  But that's just it: I don't know how it is not inside the package.  Am I formatting it wrong?  Do I need another brace somewhere?

Also, when the 'public' function affects the visibility of another function or code, what exactly does that mean?  Is it a function or a programmer that needs to see the code?  I just don't understand!

bpercevic

  • Member
  • **
  • Posts: 87
  • Karma: +2/-0
    • View Profile
you forgot to close the create function.  missing }

nicktarist

  • Member
  • **
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Thank ye, my good sire!  I would marry thee if you so desired!