'The private attribute may be used only on class property definitions.' Flash CS5 error?

Go To StackoverFlow.com

0

Here's my code:

http://pastebin.com/nSkVkTJT

The errors are one line 123 and 128.

I've googled the error, but I still can't fix it, it's got me baffled for an hour now! I've tried adding curly brace's but still same error.

Help please, thank you!

I left line 123 and 128 like this

    function _update(e:Event):void
    {
        _helicopter.update(_mouseDown);
    }

     function onEnterFrame(e:Event):void
    {'

But I'm getting an error stating that _update is not defined

2012-04-05 21:02
by Adzi


0

In the code you posted you are missing 2 trailing "}" It would be easier for you to find if you formatted your code better.

private function onEnterFrame(e:Event):void{
  if (startme){
    x -= speed;
  }

  // make me start again when I go off-screen
  if (x < -42){
    speed = Math.floor(Math.random() * 9 + 5);
    height = Math.floor(Math.random() * 200 + 5);
    x = 551;
    if(updown == 2){
      y = 0;
    }else{
     y = 400 - height;
    }
  }// <------ you are missing this
}// <-------- you are missing this
2012-04-05 22:09
by The_asMan


0

When defining nested functions, I don't believe you can specify an access modifier.

public class X extends MovieClip
{

    public function f():void
    {
        /* illegal - nested function with private modifier not allowed */
        private function nested():void {};

        /* valid - nested function */
        function nested():void {};
    }

}

So, if you're defining a function within a function, drop the private access modifier keyword and it should compile.

Personally, I'd recommend pulling those functions to the scope of the main class definition.

2012-04-05 21:14
by Jason Sturges
So can you please show me how you would write out the code within the 'public function f():void {}' . Please! Because I'm still getting errors, which means I must be doing something wrong. Thank yo - Adzi 2012-04-05 21:24
On lines 123 and 128 just remove the "private" keyword, and you should be okay - Jason Sturges 2012-04-05 21:27
It's giving me a new error 'Line 32 1120: Access of undefined property _update. - Adzi 2012-04-05 21:41
You event listener can't find the _update function. Given the complexity of that class, I'd recommend not nesting functions inside other functions. Keep all functions scoped to your class definition, and you'll be okay - Jason Sturges 2012-04-05 21:43
I'm confused. I appreciate your help but, what the hell man I've no idea what to do. - Adzi 2012-04-05 21:47
Updated pastebin at: http://pastebin.com/wUrLWNM - Jason Sturges 2012-04-05 21:50
Ads