Q
Q
qwertyspit2014-08-24 13:30:18
ActionScript
qwertyspit, 2014-08-24 13:30:18

ActionScript 3 - "Call to a possibly undefined method"?

Hello, I started learning Flex, trying to simulate inheritance.
I use Adobe Flash Builder 4.6 under Windows 8.1 x64.
Here is the code (test.as file):

package
{
  import flash.display.Sprite;
  
  public class test extends Sprite
  {
    public function test()
    {
      
    }
  }
  
  internal class LivingThing
  {
    public function Breath():String
    {
      return "I can breath";
    }
    
    public function Eat():String
    {
      return "I can eat";
    }
  }
  
  internal class Animal extends LivingThing
  {
    
  }
  
  internal class Dolphin extends Animal
  {
    public function Dolphin() { }		
  }
}

In the MXML file I use the following code (test.mxml file):
protected function btnStart_clickHandler(event:MouseEvent):void
{			
  var d = new Dolphin();
  richTB.text = "Dolphin eating: " + d.Eat() + " Dolphin breathing: " + d.Breath();				
}

As a result, I get an error on the Dolphin object creation line:
1180: Call to a possibly undefined method Dolphin. test.mxml /test/src line 14 Flex Problem
The Internet is full of posts with such an error, but so far, out of dozens of answers, not a single solution has come up ... I have been suffering for the second day (

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Q
qwertyspit, 2014-08-25
@qwertyspit

Everything was solved when I removed the test.as file from the package (perhaps the problem was that I had two files with the same names - test.as and test.mxml).

import Dolphin;
probably forgotten.

After adding some more error appeared, something like "cannot find method Dolphin".
more correctly
var d:Dolphin = new Dolphin();
it's not for you to write haxe.

Thank you, I'll take it into account :)
I came from C #)

A
Alexander Taratin, 2014-08-24
@Taraflex

import Dolphin;
probably forgotten.
more correctly
var d:Dolphin = new Dolphin();
it's not for you to write haxe.
Flex is dead, don't waste your time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question