I made it quite simplyer.
I named all class variables that could be possibly set from outside
class with leading "_", so if I have
private var _property:whatEverDataType = null;
it's setter is named same name just without "_" so a little check for
if(this["_"+i] != undefined){
this[i] = iniObject[i];
}
All variables must have initial value and thats it, it's working

2005/11/30, Ian Thomas <[EMAIL PROTECTED]>:
> You could do it backwards... iterate through 'this' rather than through
> initObject (but it's almost certainly not as fast, and doesn't let you check
> for 'unused'/wrong keys in initObject):
>
>  for(var i:String in this){
>                         if(initObject[i]!=undefined)
>                         {
>                                 this[i] = initObject[i];
>                         }
>                 }
>
> On 11/30/05, Janis Radins <[EMAIL PROTECTED]> wrote:
> >
> > Explination to why I need this is very simple.
> > The actual class I have looks like this:
> >
> > class foo {
> >         function foo(initObject:Object){
> >                 for(var i:String in initObject){
> >                         if(setter named same as i exists){
> >                                 this[i] = initObject[i];
> >                         } else {
> >                                 trace("error, invalid value in
> > initObject")
> >                         }
> >                 }
> >         }
> > }
> >
> > As I allready said I have alternative solution so this is what I
> > expected and doesnt make any problem.
> >
> > Thankyou for response.
> >
> > 2005/11/30, Dimitrios Bendilas <[EMAIL PROTECTED]>:
> > > Hi Janis,
> > >
> > > As far as I can see from the class declaration,
> > > this is not a dynamic class.
> > >
> > > So, why would you want to check if a property is "declared"?
> > > You are the one who sets the declared variables inside the class.
> > >
> > > Is there something I'm not getting?
> > >
> > > Dimitrios
> > >
> > > ----- Original Message -----
> > > From: "Janis Radins" <[EMAIL PROTECTED]>
> > > To: <Flashcoders@chattyfig.figleaf.com>
> > > Sent: Wednesday, November 30, 2005 3:24 PM
> > > Subject: [Flashcoders] lil OOP question
> > >
> > >
> > > hey ppl
> > >
> > > I'm wondering is there a way to chech wether some class function
> > > exists from constructor?
> > > smthn like:
> > > class foo {
> > > function foo(){
> > > if(this class has property named fooProperty) dothis()
> > > else doThat()
> > > }
> > > public function set fooProperty (smthn):Void {
> > > someFooProperty = smth;
> > > }
> > > }
> > >
> > > As far as I've tried it this["fooProperty"] returns only undefined.
> > >
> > > I know more than one possible workaround, just this way seems to me
> > > more elegant.
> > >
> > > Tnx in advance.
> > >
> > > Janis
> > > _______________________________________________
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > >
> > >
> > > _______________________________________________
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > _______________________________________________
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to