//
//      ver 1
//

props = { _isActive:'blah blah' };
// myclass_mc | AS2.0 Class = myclass
var mc = this.attachMovie( 'myclass_mc', 'mc', 1, props ); 
trace( mc.isActive ); // blah blah


//
//      ver 2
//

var mc = this.attachMovie( 'myclass_mc', 'mc', 1 ); // AS2.0 Class = myclass
trace( mc.isActive ); // false
props = { isActive:true };
mc.setProps ( props );
trace( mc.isActive ); // true



//
//      myclass.as
//

class myclass extends MovieClip
{
        private var _isActive = false;
        public function myclass ()
        {
        }
        public function get isActive():Boolean { return _isActive }
        public function set isActive( b:Boolean ){ _isActive = b }
        public function setProps ( props:Object ):Void
        {
                for ( var i in props )
                {
                        if ( typeof (this[i]) != undefined && props[i] !=
undefined ) this[i] = props[i];
                }
        }
}



_____________________________

Jesse Graupmann
www.jessegraupmann.com 
www.justgooddesign.com/blog/    
_____________________________



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Karim
Beyrouti
Sent: Wednesday, August 08, 2007 10:09 AM
To: [email protected]
Subject: [Flashcoders] Dynamically setting properties...

Hi List,


I am trying to add values to properties a classes, the classes properties
are defined like this:

        function get isActive():Boolean{ return _isActive; }
        function set isActive( val:Boolean):Void{ _isActive= val; }

 so instead of douing this to add values to the class:

        if ( obj.isActive!= undefined ) myClass.isActive = obj.isActive

I am trying to do something like this ( as I have quite a lot of properties
/ different classes ):

        for ( var i in obj ) {
                                                
                a_sprite[i] = obj[i]
                                
        }

But no joy... and well... has anyone been there with this one.?...



Regards


Karim

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to