Error when compiling Actor of Group Enters Screen Event

Roadcat

  • Posts: 46
When creating a new event:
Actor ->Enters or Leaves the Scene or Screen ->Member of Group
Stencyl throws an error stating that there is an unmatched { when compiling. I have attached screenshots of the error message, stencil blocks, logs and the code create under the 'Preview code' button.

Roadcat

  • Posts: 46
Attached is a game that throws the error on compile.

Hectate

  • *
  • Posts: 4643
I think I see the extra } but there's no clear way for it to get there.

Note, I say } and not { because what's happening is it finds an extra } and there isn't a matching opening one for it. A little backwards but that's the only one that's seemingly out of place, the line that reads:
Code: [Select]
});
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

captaincomic

  • *
  • Posts: 6108
Here's the code preview of that event
Code: [Select]
class SceneEvents_0 extends SceneScript
{         

 
  public function new(dummy:Int, engine:Engine)
{
super(engine);

}

override public function init()
{
addActorTypeGroupPositionListener(getActorGroup(4).ID + 1000000, function(list:Array, a:Actor, enteredScreen:Boolean, exitedScreen:Boolean, enteredScene:Boolean, exitedScene:Boolean):void
{
    if (wrapper.enabled && enteredScreen)
        {        /* "This doesn't compile" */}
});

}      

override public function forwardMessage(msg:String)
{

}
}
It looks to me like all the { and } are matching, but I also cannot spot any other syntax error or a reason why this wouldn't compile.

Roadcat

  • Posts: 46
I think Hectate is right. The problem is in the line:
});

The 2 brackets are the wrong way around. It should read:
)};

captaincomic

  • *
  • Posts: 6108
There is an ananyous function added as a listener, the brackets belong to the function body, and the braces are from the addActorTypeGroupPositionListener call.

addActorTypeGroupPositionListener(..., function(...)
{
...
});

I think the issue is somewhere else...

Edit: Oh, there is a "void" return type, where it should read "Void".

« Last Edit: February 07, 2013, 11:39:10 am by captaincomic »


Jon

  • *
  • Posts: 17524
Roadcat, please verify that this is fixed. Thanks.