must override another method error

DoctorMikeReddy

  • *
  • Posts: 180
It's been a while - I've been implementing a game on v2.0 - and (fortunately) kept a backup when upgrading to 2.2 via 2.1 manual download, and was able to revert to a working version. The problem is that in V2.2 I hit the "override" problem, where Stencyl complains about not overriding functions. Hence, I removed all but the first override (for the init function), which is the suggested solution, and also deleted blank public functions (another suggestion). However, I cannot test the game or export flash now; I get the usual "helpful" alert about incompatible sound files, when we all know that this is probably due to malformed AS3 source. Are there any other things I should consider apart from removing "override"s when told to, or removing blank public functions? I've tried this 'fix' with simple examples and they seem fine, but I am using JSON and embedded javascript web pages to host the games, so it may be some AS3 functions that are fine in V2.0 but not v2.2. Log attached


coleislazy

  • *
  • Posts: 2607
Here is the error:
Quote
[LOG] PREVIEW FAILED
[LOG] Behavior: JSON at line 82
[LOG] Method marked override must override another method.
[LOG]       override public function update():void
[LOG] Behavior: JSON at line 86
[LOG] Method marked override must override another method.
[LOG]       override public function draw(g:Graphics, x:Number, y:Number):void
[LOG] Behavior: JSON at line 90
[LOG] Method marked override must override another method.
[LOG]       override public function handleCollision(event:Collision):void

The problem is you're trying to override functions that existed in 1.x, but were changed for 2.x onward. Instead of having update(), draw(), and handleCollision(), each behavior now registers event listeners to call specific functions. Take a look at the code preview of a design-mode behavior to see how it is done. Basically, you'll just want to point the listeners to those functions, but you'll also have to change the arguments for draw, I believe (it should be "draw(list:Array, x:Number, y:Number, g:Graphics)", I think).

Don't forget to remove the "override" in front of each function as well.

jpeterson

  • Posts: 17
helped a lot thanks  :o