RE: [Flashcoders] Dynamically setting properties...

2007-08-13 Thread Jesse Graupmann
//
//  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: flashcoders@chattyfig.figleaf.com
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

___
Flashcoders@chattyfig.figleaf.com
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

___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] Dynamically setting properties...

2007-08-09 Thread Ron Wheeler

I would think that the trace on a_sprite would be more interesting.
I am not sure what

  a_sprite[i] = obj[i];

is actually supposed to do.
The code extract does not show how a_sprite[i] comes into existence or 
what a_sprite[i] is.

To my untrained eye it looks like you are creating an array of  obj's.
To use them, you would need to do
   myobj=a_sprite[1]
   trace (myobj.getProperty1());  //show the value of property1 from 
the second obj in a_sprite.


I may be all wet but it would be helpful to see more of the code and to 
see the results of the traces.


Saying that you put traces in and everything is fine and matches up but 
still does not "work" does not give us much to go on.
The classical bug description would be helpful. "Here is what I did. 
This is what I expected. This is what happened"


Ron


Karim wrote:

Already added the trace, all props in my obj are fine and match up with the
getter/setters in the class. 


FYI: I am adding these properties to instances of classes ( that extend
movieclip, project is AS2)..


Karim


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of JOR
Sent: 08 August 2007 18:22
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Dynamically setting properties...

What is the error you're getting?

Maybe add a trace statement in there to see where it's breaking.  You 
could be trying to set a property that exists only in "obj" but not in 
"a_sprite".


for ( var i in obj ) {
   trace (i + " = " + obj[i]);
   a_sprite[i] = obj[i];
}

-- James


James O'Reilly  —  Consultant
Adobe Certified Flash Expert
http://www.jamesor.com
Design • Code • Train



Karim Beyrouti wrote:
  

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.?...


___
Flashcoders@chattyfig.figleaf.com
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

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.8/941 - Release Date: 07/08/2007

16:06
 


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.8/941 - Release Date: 07/08/2007

16:06
 
  



___
Flashcoders@chattyfig.figleaf.com
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

___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] Dynamically setting properties...

2007-08-08 Thread Karim
Already added the trace, all props in my obj are fine and match up with the
getter/setters in the class. 

FYI: I am adding these properties to instances of classes ( that extend
movieclip, project is AS2)..


Karim


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of JOR
Sent: 08 August 2007 18:22
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Dynamically setting properties...

What is the error you're getting?

Maybe add a trace statement in there to see where it's breaking.  You 
could be trying to set a property that exists only in "obj" but not in 
"a_sprite".

for ( var i in obj ) {
   trace (i + " = " + obj[i]);  
   a_sprite[i] = obj[i];
}

-- James


James O'Reilly  —  Consultant
Adobe Certified Flash Expert
http://www.jamesor.com
Design • Code • Train



Karim Beyrouti wrote:
> 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.?...
___
Flashcoders@chattyfig.figleaf.com
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

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.8/941 - Release Date: 07/08/2007
16:06
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.8/941 - Release Date: 07/08/2007
16:06
 
___
Flashcoders@chattyfig.figleaf.com
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

Re: [Flashcoders] Dynamically setting properties...

2007-08-08 Thread JOR

What is the error you're getting?

Maybe add a trace statement in there to see where it's breaking.  You 
could be trying to set a property that exists only in "obj" but not in 
"a_sprite".


for ( var i in obj ) {
  trace (i + " = " + obj[i]); 
  a_sprite[i] = obj[i];
}

-- James


James O'Reilly  —  Consultant
Adobe Certified Flash Expert
http://www.jamesor.com
Design • Code • Train



Karim Beyrouti wrote:

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.?...

___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] Dynamically setting properties...

2007-08-08 Thread Hans Wichman
Hi,
not entirely sure what you are trying to do, but it sounds like you should
either introduce a superclass for your objects, or add something to a
prototype.
Are you adding these properties to instances or classes?
greetz
JC


On 8/8/07, Karim Beyrouti <[EMAIL PROTECTED]> wrote:
>
> 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
>
> ___
> Flashcoders@chattyfig.figleaf.com
> 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
>
___
Flashcoders@chattyfig.figleaf.com
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


[Flashcoders] Dynamically setting properties...

2007-08-08 Thread Karim Beyrouti
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

___
Flashcoders@chattyfig.figleaf.com
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