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: <[email protected]>
> > 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
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> >
> >
> > _______________________________________________
> > Flashcoders mailing list
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders