RE: [Flashcoders] Setting a property in a class from another class

2009-10-20 Thread Merrill, Jason
I think it would be better to loosely couple these two classes instead.
Have class B dispatch a custom event when you want to change the
property in class A. Create a listener in Class A for it.  As for the
value, make the value public in class B and when class A hears the
event, grab it, or, pass the value through the event.


Jason Merrill 

Bank of  America   Global Learning 
Learning & Performance Soluions

Monthly meetings on making the most of the Adobe Flash Platform -
presented by bank associates, Adobe engineers, and outside experts in
the borader multimedia community - join the Bank of America Flash
Platform Community  (note: this is for Bank of America employees only)




-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Hans
Wichman
Sent: Tuesday, October 20, 2009 6:22 AM
To: Flash Coders List
Subject: Re: [Flashcoders] Setting a property in a class from another
class

Hi,

your class B instance will need a reference to an instance of Class A,
unless your nextPrev property is static.

If nextPrev is static, Class B can do ClassA.nextPrev (assuming the
property
is public).
If nextPrev is not static, you'll need to do new ClassB
(myClassAInstance)
and access the instance of A within B.

Another option is a separate method doSomething (pClassA:ClassA) {
pClassA.nextPrev = whatever; }

JC

On Tue, Oct 20, 2009 at 12:03 PM, Sajid Saiyed
wrote:

> Hi,
> I have a basic problem that I cant figure out how...
>
> I have a ClassA and ClassB (both extend Sprite)
>
> ClassA has a property called "nextPrev:Boolean"
>
> Inside ClassA I create an instance of ClassB like this:
>
> public var myB:ClassB = new ClassB();
>
> Now, is it possible that I can have a method inside ClassB that can
> set the "nextPrev" property inside ClassA?
> Dont know if this is possible...
> 4
> Regards
> ___
> 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


Re: [Flashcoders] Setting a property in a class from another class

2009-10-20 Thread Hans Wichman
Hi,

your class B instance will need a reference to an instance of Class A,
unless your nextPrev property is static.

If nextPrev is static, Class B can do ClassA.nextPrev (assuming the property
is public).
If nextPrev is not static, you'll need to do new ClassB (myClassAInstance)
and access the instance of A within B.

Another option is a separate method doSomething (pClassA:ClassA) {
pClassA.nextPrev = whatever; }

JC

On Tue, Oct 20, 2009 at 12:03 PM, Sajid Saiyed wrote:

> Hi,
> I have a basic problem that I cant figure out how...
>
> I have a ClassA and ClassB (both extend Sprite)
>
> ClassA has a property called "nextPrev:Boolean"
>
> Inside ClassA I create an instance of ClassB like this:
>
> public var myB:ClassB = new ClassB();
>
> Now, is it possible that I can have a method inside ClassB that can
> set the "nextPrev" property inside ClassA?
> Dont know if this is possible...
> 4
> Regards
> ___
> 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


Re: [Flashcoders] Setting a property in a class from another class

2009-10-20 Thread Glen Pike

Sajid Saiyed wrote:

Hi,
I have a basic problem that I cant figure out how...

I have a ClassA and ClassB (both extend Sprite)

ClassA has a property called "nextPrev:Boolean"

Inside ClassA I create an instance of ClassB like this:

public var myB:ClassB = new ClassB();

Now, is it possible that I can have a method inside ClassB that can
set the "nextPrev" property inside ClassA?
Dont know if this is possible...
4
Regards
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


  
yes, just create a setter method that then calls the method in your 
composed class:


public function set nextPrev(np:Boolean):void {
   myB.nextPrev = np;
}
public function get nextPrev():Boolean {
   return myB.nextPrev;
}
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Setting a property in a class from another class

2009-10-20 Thread Cor
It is possible, you have to override the function in ClassA from within
ClassB

HTH

Regards
Cor

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Sajid Saiyed
Sent: dinsdag 20 oktober 2009 12:04
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Setting a property in a class from another class

Hi,
I have a basic problem that I cant figure out how...

I have a ClassA and ClassB (both extend Sprite)

ClassA has a property called "nextPrev:Boolean"

Inside ClassA I create an instance of ClassB like this:

public var myB:ClassB = new ClassB();

Now, is it possible that I can have a method inside ClassB that can
set the "nextPrev" property inside ClassA?
Dont know if this is possible...
4
Regards
___
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] Setting a property in a class from another class

2009-10-20 Thread Sajid Saiyed
Hi,
I have a basic problem that I cant figure out how...

I have a ClassA and ClassB (both extend Sprite)

ClassA has a property called "nextPrev:Boolean"

Inside ClassA I create an instance of ClassB like this:

public var myB:ClassB = new ClassB();

Now, is it possible that I can have a method inside ClassB that can
set the "nextPrev" property inside ClassA?
Dont know if this is possible...
4
Regards
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders