# Need help with this OOP thingy

**URL:** <https://forum.kirupa.com/t/need-help-with-this-oop-thingy/278684>\
**Category:** Uncategorized\
**Created:** [January 3, 2009, 6:10pm UTC](https://forum.kirupa.com/t/need-help-with-this-oop-thingy/278684 "2009-01-03T18:10:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixeldude](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pixeldude](https://forum.kirupa.com/u/pixeldude)\
**Post date:** [January 3, 2009, 6:10pm UTC](https://forum.kirupa.com/t/need-help-with-this-oop-thingy/278684/1 "2009-01-03T18:10:33Z")

</div>

Hi everyones…

I Was kind of at My Wit’s End…Im totally have no idea what happen???I have decide to using factory class to attach MovieClip from library.So far everythings its work great only when i try to add extra property it thrown this error…so hope someone can enlighten me what happen actually…is it because I cast the object to MovieClip???..

the fla:

```auto

var car:Main = new Main(stage);
car.attachCar("SubaruImpreza");

```

main.as

```auto

package{
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.display.DisplayObjectContainer;
    import flash.events.Event;

    public class Main extends Sprite{
        private var _stage:DisplayObjectContainer;
        private var totalcar:Number = 5;
        
        public function Main(stage_:DisplayObjectContainer){
            _stage = stage_;
        }
        
        public function attachCar(_carName:String):void{
            for(var i:int=0;i<totalcar;i++){
                var thecar:ICar = CarFactory.getCar(_carName);
                (thecar as MovieClip).x = Math.random()*500+25;
                (thecar as MovieClip).y = Math.random()*350+25;
**//the issues raiseup here...when I add this extra property its thrown this error**
[COLOR="black"][COLOR="black"]ReferenceError: Error #1056: Cannot create property anglez on SubaruImpreza.[/COLOR][/COLOR]
    at Main/attachCar()
    at thefla_fla::MainTimeline/thefla_fla::frame1()
                (thecar as MovieClip).anglez = Math.random()*6.28318531;
                _stage.addChild(thecar as MovieClip);
                thecar.speeding();
            }
        }
        
        
    }
    
}

```

factory class  
CarFactory.as

```auto

package{
    
    public class CarFactory{    
        public static function getCar(type:String):ICar{
            switch(type){
                case "SubaruImpreza":
                    return new SubaruImpreza();
                    break;
                case "Evo":
                    return new Evo();
                    break;
                case "FairLady":
                    return new FairLady();
                    break;
                default :
                    return null;
                    break;
            }//end switch
            
        }
        
    }
        
}

```

Interface

ICar.as

```auto

package{
    
    public interface ICar{
        function speeding():void;
    }
    
    
}

```

and the rest class Evo.as,SubaruImpreza.as,FairLady.as…  
I’ve been struggling to remedy to no avail so I really need help onthis at least point me for the rite path…

u can grab the file here…

[http://www.franzacollections.net/fifin04/forum/thewoes.zip](http://www.franzacollections.net/fifin04/forum/thewoes.zip)

Tq in advances
