A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Cant use extended classes variables or methods?

  1. #1
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254

    Cant use extended classes variables or methods?

    I have this problem from time to time with AS3 where I extend a Class and then try call methods and variables which are public from the new class but I get errors that method or variable doesn't exist. My IDE recognises the methods and variables though.

    Heres an example

    PHP Code:
    //I have a base class
    public class Box {

       public var 
    id:int;

       public function 
    somemethod() {}

    }

    //Then I extend the class
    public class BiggerBox extends Box {}

    //Then in a separate class I try this
    var bigBox:BiggerBox = new BiggerBox();

    trace(bigBox.id);

    bigbox.somemethod(); 
    When I run the script flash hates it. I thought when you extend a class it was supposed to inherit its properties and methods?

    Does anyone else have these problems? I shouldn't have to cast it as Box. I swear I have this working in a project but cant see the different in setup?
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Where do you have the package in your classes? The code should otherwise work.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Well, Box and BiggerBox both site inside the same package

    package com.site.boxes {}

    but the class calling the bigbox.somemethod(); is inside another package

    package com.site.logic {}
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  4. #4
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Actually I just searched and it was sort of a package problem.

    The logic package already contained a class called bigbox and even though I imported com.site.boxes.BigBox;

    The one in the package was overriding it.

    Thanks for the help cancerinform. I appreciate it.
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Had to be something like that, because otherwise it would not have made sense.
    - The right of the People to create Flash movies shall not be infringed. -

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