A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] override protected getter?

  1. #1
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429

    resolved [RESOLVED] override protected getter?

    I have 3 classes set up. An abstract, a concrete and a utility that needs access to the concretes getter. When I try to access the property of the concrete from within the utility it throws an error.

    //abstract
    PHP Code:
    package{
      
    import flash.errors.IllegalOperationError;
      class{
        protected function 
    get left():Number{
          throw new 
    IllegalOperationError("Abstract method: must be overridden in a subclass");
        }
      }

    //concrete
    PHP Code:
    package{
      class extends abstract{
        
    override protected function get left():Number{
          return 
    someVal;
        }
      }

    //utility
    PHP Code:
    package{
      class 
    utility{
        private var 
    concrete:abstract;
        public function 
    utility(concreteClass:abstract){
          
    this.concrete concreteClass;
          
    init();
        }
        private class 
    init():void{
          
    trace(concrete.left); //1178: Attempted access of inaccessible property left through a reference with static type abstract.
        
    }
      }

    //client
    PHP Code:
    package{
      class{
        public function 
    client():void{
          var 
    = new concrete();
          var 
    = new utility(c);
        }
      }

    Any idea how to gain access?
    Last edited by jAQUAN; 12-07-2008 at 04:49 PM.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Usually your working class extends the abstract class. There you throw the error and in your working class you override the method.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Isn't that exactly what I'm doing?

  4. #4
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    nm, I figured it out. Was trying to access the property from a class that was not a subclass. Needed to be internal or public for that.

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Not really, because you are jumping over the concrete class directly to the abstract class in your utility class and in the init function you call the getter from the abstract class.
    - 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