PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[AS3] Error 1061
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [AS3] Error 1061

  1. #1
    Member
    Join Date
    May 2005
    Posts
    95

    [AS3] Error 1061

    Hey there,

    Working on a new game, and while it LOOKS like everything is happy scrappy... it's not.

    When I test run I keep getting the following error:

    1061: Call to a possibly undefined method hitTestObject through a reference with static type Class.

    What I THINK this means is that I dont have the actual file *pointing* to the Dungeon Manager class I created. Since it looks to me like the hitTestObject method is correct.


    Any insight would be fantastic,

    Heres the project:
    http://www.filefactory.com/file/b54f...O_DIABOLIK.rar

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    916
    it says, you are calling method on the class, not the instance of the class
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Member
    Join Date
    May 2005
    Posts
    95
    Okay, that kind of helped. But according to the book I am going from, A method call calls a trigger directives in the method's function definition.

    Isn't that what I want here? Plus, what is the difference between a method call and instance call and how can you tell which is needed?

  4. #4
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    916
    A method call calls a trigger directives in the method's function definition
    A "method" is simply a synonym for function which is defined as a part of class vs "standalone" function, which is called just "function". so calling a method, or calling a function, triggers statements in its body - that's what your book said, probably.

    what is the difference between a method call and instance call
    methods may be defined for the class (and then you cal ClassName.methodName()) or for an instance of the class (and then you call instance.methodName()). In this case, you are trying to call the method defined for an instance as if it was defined for the class.

    how can you tell which is needed?
    you look up the declaration of method. if it has the word "static" in it, e.g.

    Code:
    public static function methodName (blah):blah {
    then it's ClassName.methodName() you want to call, and

    Code:
    public function methodName (blah):blah {
    means you want to call instance.methodName().

    p.s. maybe you need to read the chapter that deals with instances vs classes 1st. like specific apple (instance) vs kind of all possible apples (class) stuff, from there you can see the above difference between method calls better.
    Last edited by realMakc; 02-08-2011 at 08:03 PM.
    who is this? a word of friendly advice: FFS stop using AS2

  5. #5
    When you know are. Son of Bryce's Avatar
    Join Date
    Aug 2002
    Location
    Los Angeles
    Posts
    839
    hitTestObject() is a function on a MovieClip or Sprite. When you create a new class, it doesn't have any of the properties or methods of a MovieClip initially, unless you're extending Movieclip. Just make sure whatever class you're creating that needs to have called with hitTestObject() extends MovieClip like this...

    Actionscript Code:
    public class Main extends MovieClip
        {
           
            public function Main():void {
            }
    Now your new class has all of the functionality of a MovieClip.

  6. #6
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    916
    this reply by Son of Bryce made me think that it is indeed might be simpler than I thought, so I downloaded your files. your immediate problem is that player mc is not named (set it to "player" in properties) and then player symbol in library has its class set to "player", when it should have been "Player".
    who is this? a word of friendly advice: FFS stop using AS2

  7. #7
    Member
    Join Date
    May 2005
    Posts
    95
    Thank you so much! on my version player.mc had 'player' in the properties window but I missed that capital 'P' sending it to the correct .as file.

    I still wrote down all the notes you both gave me for distinction between calling methods and calling instances since I am sure I will need to reference those differences quite often.

    Again, thanks to you both for your insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center