Re: [Flashcoders] OOP newbie question

2005-11-24 Thread JesterXL
It is.  It hangs "magically" off of the ActivationObject, and no one has a 
clue how nice that is with the Garbage Collector.  Instead, use a Delegate.

import mx.utils.Delegate;

function connect()
{
mySocket = new XMLSocket();
mySocket.onXML = Delegate.create(this, handleIncoming);
}

function handleIncoming(xmlStr)
{
// this is scoped correctly to the class
trace(this);
parseMessages(xmlStr);
}


>>function connect ()
>>
>>{
>>
>>mySocket = new XMLSocket ();
>> var _obj = this;
>>
>> mySocket.onXML = function ()
>> {
>> _obj.handleIncoming();
>>   }
>>}


- Original Message - 
From: "Andy Johnston" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Thursday, November 24, 2005 10:51 PM
Subject: Re: [Flashcoders] OOP newbie question


Nothing is "wrong" with it. Just seems an ugly way to deal with
differences in scope.

>Why what's wrong about it?
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Andy
>Johnston
>Sent: Friday, 25 November 2005 2:41 PM
>To: Flashcoders mailing list
>Subject: Re: [Flashcoders] OOP newbie question
>
>I never have a use for self refencing.. maybe thats just me, feels like
>a dirty hack.
>
>
>
>>Just create reference to your class. You will need that a lot ...
>>
>>
>>function connect ()
>>
>>{
>>
>>mySocket = new XMLSocket ();
>> var _obj = this;
>>
>> mySocket.onXML = function ()
>> {
>> _obj.handleIncoming();
>>   }
>>}
>>
>>
>>
>>
>>-Original Message-
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] On Behalf Of Jim
>>Phelan
>>Sent: Friday, 25 November 2005 2:27 PM
>>To: 'Flashcoders mailing list'
>>Subject: RE: [Flashcoders] OOP newbie question
>>
>>Hi,
>>
>>The problem here is scope. When you call parseMessages, you doing it in
>>the
>>scope of the mySocket object (where the method doesn't exist.)
>>
>>There's a pretty simple workaround for this using the Delegate utility
>>that
>>comes with Flash.
>>
>>At the top of your class file, do this : import mx.utils.Delegate;
>>
>>Change this line: mySocket.onXML = handleIncoming;
>>To this: mySocket.onXML = Delegate.create(this,handleIncoming);
>>
>>And that should solve your problem. Basically you're creating a proxy
>>function on the XMLSocket object that then invokes the handleIncoming
>>function on your OSC object. There are other ways to do this, but I
>>think
>>the Delegate method is generally considered the best practice.
>>
>>Hope that helps,
>>
>>Jim
>>
>>-Original Message-
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] On Behalf Of
>>
>>
>hbruyere
>
>
>>Sent: Thursday, November 24, 2005 10:19 PM
>>To: Flashcoders@chattyfig.figleaf.com
>>Subject: [Flashcoders] OOP newbie question
>>
>>Hi,
>>
>>
>>
>>Here is a OOP newbie question.
>>
>>
>>
>>I have a class (see below)..
>>
>>
>>
>>Everything works fine. but the method "handleIncoming" can not access
>>
>>
>()
>
>
>>or
>>maybe even find) the method "parseMessages".
>>
>>If I give the complete path to the instance of the OSC class (made in
>>
>>
>my
>
>
>>fla
>>- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.
>>
>>
>>
>>How should I code this to make it works ?
>>
>>
>>
>>
>>
>>class OSC
>>
>>{
>>
>>
>>
>>   var mySocket : XMLSocket;
>>
>>//
>>
>>//
>>
>>   public function OSC ()
>>
>>   {
>>
>>   connect ();
>>
>>   }
>>
>>   //
>>
>>   //
>>
>>   function connect ()
>>
>>   {
>>
>>   mySocket = new XMLSocket ();
>>
>>   mySocket.onXML = handleIncoming;
>>
>>   }
>>
>>//
>>
>>//
>>
>>   function handleIncoming (xmlIn)
>>
>>   {
>>
>>   parseMessages (xmlIn);
>>
>>
>>
>>   }
>>
>>//
>>
>>   funct

RE: [Flashcoders] OOP newbie question

2005-11-24 Thread Robin Burrer
It always worked for me though. I think in most cases it's just less
hassle than importing the delegate class. But I guess that's just a
matter of taste.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andy
Johnston
Sent: Friday, 25 November 2005 2:52 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OOP newbie question

Nothing is "wrong" with it. Just seems an ugly way to deal with 
differences in scope.

>Why what's wrong about it? 
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Andy
>Johnston
>Sent: Friday, 25 November 2005 2:41 PM
>To: Flashcoders mailing list
>Subject: Re: [Flashcoders] OOP newbie question
>
>I never have a use for self refencing.. maybe thats just me, feels like

>a dirty hack.
>
>  
>
>>Just create reference to your class. You will need that a lot ...
>>
>>
>>function connect ()
>>
>>{
>>
>>  mySocket = new XMLSocket ();
>>  var _obj = this;
>>
>> mySocket.onXML = function ()
>>  {
>>  _obj.handleIncoming();
>>}
>>}
>>
>>
>>
>>
>>-----Original Message-----
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] On Behalf Of Jim
>>Phelan
>>Sent: Friday, 25 November 2005 2:27 PM
>>To: 'Flashcoders mailing list'
>>Subject: RE: [Flashcoders] OOP newbie question
>>
>>Hi,
>>
>>The problem here is scope. When you call parseMessages, you doing it
in
>>the
>>scope of the mySocket object (where the method doesn't exist.) 
>>
>>There's a pretty simple workaround for this using the Delegate utility
>>that
>>comes with Flash.
>>
>>At the top of your class file, do this : import mx.utils.Delegate;
>>
>>Change this line: mySocket.onXML = handleIncoming;
>>To this: mySocket.onXML = Delegate.create(this,handleIncoming);
>>
>>And that should solve your problem. Basically you're creating a proxy
>>function on the XMLSocket object that then invokes the handleIncoming
>>function on your OSC object. There are other ways to do this, but I
>>think
>>the Delegate method is generally considered the best practice.
>>
>>Hope that helps,
>>
>>Jim
>>
>>-Original Message-
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] On Behalf Of
>>
>>
>hbruyere
>  
>
>>Sent: Thursday, November 24, 2005 10:19 PM
>>To: Flashcoders@chattyfig.figleaf.com
>>Subject: [Flashcoders] OOP newbie question
>>
>>Hi,
>>
>>
>>
>>Here is a OOP newbie question.
>>
>>
>>
>>I have a class (see below)..
>>
>>
>>
>>Everything works fine. but the method "handleIncoming" can not access
>>
>>
>()
>  
>
>>or
>>maybe even find) the method "parseMessages".
>>
>>If I give the complete path to the instance of the OSC class (made in
>>
>>
>my
>  
>
>>fla
>>- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.
>>
>>
>>
>>How should I code this to make it works ?
>>
>>
>>
>>
>>
>>class OSC
>>
>>{
>>
>>
>>
>>   var mySocket : XMLSocket;
>>
>>//
>>
>>//
>>
>>   public function OSC ()
>>
>>   {
>>
>>   connect ();
>>
>>   }
>>
>>   //
>>
>>   //
>>
>>   function connect ()
>>
>>   {
>>
>>   mySocket = new XMLSocket ();
>>
>>   mySocket.onXML = handleIncoming;
>>
>>   }
>>
>>//
>>
>>//
>>
>>   function handleIncoming (xmlIn)
>>
>>   {
>>
>>   parseMessages (xmlIn);
>>
>>
>>
>>   }
>>
>>//
>>
>>   function parseMessages (node)
>>
>>   {
>>
>>actions..
>>
>>}
>>
>>}
>>
>>
>>
>>Thanks for your attention,
>>
>>
>>
>>//h
>>
>>___
>>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
>
>
>  
>

___
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] OOP newbie question

2005-11-24 Thread Andy Johnston
Nothing is "wrong" with it. Just seems an ugly way to deal with 
differences in scope.


Why what's wrong about it? 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andy
Johnston
Sent: Friday, 25 November 2005 2:41 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OOP newbie question

I never have a use for self refencing.. maybe thats just me, feels like 
a dirty hack.


 


Just create reference to your class. You will need that a lot ...


function connect ()

{

mySocket = new XMLSocket ();
var _obj = this;

mySocket.onXML = function ()
{
_obj.handleIncoming();
  }
}




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jim
Phelan
Sent: Friday, 25 November 2005 2:27 PM
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OOP newbie question

Hi,

The problem here is scope. When you call parseMessages, you doing it in
the
scope of the mySocket object (where the method doesn't exist.) 


There's a pretty simple workaround for this using the Delegate utility
that
comes with Flash.

At the top of your class file, do this : import mx.utils.Delegate;

Change this line: mySocket.onXML = handleIncoming;
To this: mySocket.onXML = Delegate.create(this,handleIncoming);

And that should solve your problem. Basically you're creating a proxy
function on the XMLSocket object that then invokes the handleIncoming
function on your OSC object. There are other ways to do this, but I
think
the Delegate method is generally considered the best practice.

Hope that helps,

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
   


hbruyere
 


Sent: Thursday, November 24, 2005 10:19 PM
To: Flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] OOP newbie question

Hi,



Here is a OOP newbie question.



I have a class (see below)..



Everything works fine. but the method "handleIncoming" can not access
   


()
 


or
maybe even find) the method "parseMessages".

If I give the complete path to the instance of the OSC class (made in
   


my
 


fla
- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.



How should I code this to make it works ?





class OSC

{



  var mySocket : XMLSocket;

//

//

  public function OSC ()

  {

  connect ();

  }

  //

  //

  function connect ()

  {

  mySocket = new XMLSocket ();

  mySocket.onXML = handleIncoming;

  }

//

//

  function handleIncoming (xmlIn)

  {

  parseMessages (xmlIn);



  }

//

  function parseMessages (node)

  {

actions..

}

}



Thanks for your attention,



//h

___
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


 



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] OOP newbie question

2005-11-24 Thread Andy Johnston

http://www.javaworld.com/javaworld/javaqa/2001-09/01-qa-0914-delegate.html


Thanks for all your helps.
The Delegate class makes it works like a charm...

On the other hand the self referencing is not working.

Would it work that way (The Delegate class "solution") is an other OOP
language like Java or C++ ?

//h

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andy
Johnston
Sent: Thursday, November 24, 2005 10:41 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OOP newbie question

I never have a use for self refencing.. maybe thats just me, feels like 
a dirty hack.


 


Just create reference to your class. You will need that a lot ...


function connect ()

{

mySocket = new XMLSocket ();
var _obj = this;

mySocket.onXML = function ()
{
_obj.handleIncoming();
  }
}




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jim
Phelan
Sent: Friday, 25 November 2005 2:27 PM
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OOP newbie question

Hi,

The problem here is scope. When you call parseMessages, you doing it in
the
scope of the mySocket object (where the method doesn't exist.) 


There's a pretty simple workaround for this using the Delegate utility
that
comes with Flash.

At the top of your class file, do this : import mx.utils.Delegate;

Change this line: mySocket.onXML = handleIncoming;
To this: mySocket.onXML = Delegate.create(this,handleIncoming);

And that should solve your problem. Basically you're creating a proxy
function on the XMLSocket object that then invokes the handleIncoming
function on your OSC object. There are other ways to do this, but I
think
the Delegate method is generally considered the best practice.

Hope that helps,

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of hbruyere
Sent: Thursday, November 24, 2005 10:19 PM
To: Flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] OOP newbie question

Hi,



Here is a OOP newbie question.



I have a class (see below)..



Everything works fine. but the method "handleIncoming" can not access ()
or
maybe even find) the method "parseMessages".

If I give the complete path to the instance of the OSC class (made in my
fla
- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.



How should I code this to make it works ?





class OSC

{



  var mySocket : XMLSocket;

//

//

  public function OSC ()

  {

  connect ();

  }

  //

  //

  function connect ()

  {

  mySocket = new XMLSocket ();

  mySocket.onXML = handleIncoming;

  }

//

//

  function handleIncoming (xmlIn)

  {

  parseMessages (xmlIn);



  }

//

  function parseMessages (node)

  {

actions..

}

}



Thanks for your attention,



//h

___
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


 



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] OOP newbie question

2005-11-24 Thread hbruyere
Thanks for all your helps.
The Delegate class makes it works like a charm...

On the other hand the self referencing is not working.

Would it work that way (The Delegate class "solution") is an other OOP
language like Java or C++ ?

//h

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andy
Johnston
Sent: Thursday, November 24, 2005 10:41 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OOP newbie question

I never have a use for self refencing.. maybe thats just me, feels like 
a dirty hack.

>Just create reference to your class. You will need that a lot ...
>
>
>function connect ()
>
>{
>
>   mySocket = new XMLSocket ();
>   var _obj = this;
>
>  mySocket.onXML = function ()
>   {
>   _obj.handleIncoming();
> }
>}
>
>
>
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Jim
>Phelan
>Sent: Friday, 25 November 2005 2:27 PM
>To: 'Flashcoders mailing list'
>Subject: RE: [Flashcoders] OOP newbie question
>
>Hi,
>
>The problem here is scope. When you call parseMessages, you doing it in
>the
>scope of the mySocket object (where the method doesn't exist.) 
>
>There's a pretty simple workaround for this using the Delegate utility
>that
>comes with Flash.
>
>At the top of your class file, do this : import mx.utils.Delegate;
>
>Change this line: mySocket.onXML = handleIncoming;
>To this: mySocket.onXML = Delegate.create(this,handleIncoming);
>
>And that should solve your problem. Basically you're creating a proxy
>function on the XMLSocket object that then invokes the handleIncoming
>function on your OSC object. There are other ways to do this, but I
>think
>the Delegate method is generally considered the best practice.
>
>Hope that helps,
>
>Jim
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of hbruyere
>Sent: Thursday, November 24, 2005 10:19 PM
>To: Flashcoders@chattyfig.figleaf.com
>Subject: [Flashcoders] OOP newbie question
>
>Hi,
>
> 
>
>Here is a OOP newbie question.
>
> 
>
>I have a class (see below)..
>
> 
>
>Everything works fine. but the method "handleIncoming" can not access ()
>or
>maybe even find) the method "parseMessages".
>
>If I give the complete path to the instance of the OSC class (made in my
>fla
>- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.
>
> 
>
>How should I code this to make it works ?
>
> 
>
> 
>
>class OSC
>
>{
>
> 
>
>var mySocket : XMLSocket;
>
>//
>
>//
>
>public function OSC ()
>
>{
>
>connect ();
>
>}
>
>//
>
>//
>
>function connect ()
>
>{
>
>mySocket = new XMLSocket ();
>
>mySocket.onXML = handleIncoming;
>
>}
>
>//
>
>//
>
>function handleIncoming (xmlIn)
>
>{
>
>parseMessages (xmlIn);
>
> 
>
>}
>
>//
>
>function parseMessages (node)
>
>{
>
>actions..
>
>}
>
>}
>
> 
>
>Thanks for your attention,
>
> 
>
>//h
>
>___
>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


RE: [Flashcoders] OOP newbie question

2005-11-24 Thread Robin Burrer
Why what's wrong about it? 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andy
Johnston
Sent: Friday, 25 November 2005 2:41 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OOP newbie question

I never have a use for self refencing.. maybe thats just me, feels like 
a dirty hack.

>Just create reference to your class. You will need that a lot ...
>
>
>function connect ()
>
>{
>
>   mySocket = new XMLSocket ();
>   var _obj = this;
>
>  mySocket.onXML = function ()
>   {
>   _obj.handleIncoming();
> }
>}
>
>
>
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Jim
>Phelan
>Sent: Friday, 25 November 2005 2:27 PM
>To: 'Flashcoders mailing list'
>Subject: RE: [Flashcoders] OOP newbie question
>
>Hi,
>
>The problem here is scope. When you call parseMessages, you doing it in
>the
>scope of the mySocket object (where the method doesn't exist.) 
>
>There's a pretty simple workaround for this using the Delegate utility
>that
>comes with Flash.
>
>At the top of your class file, do this : import mx.utils.Delegate;
>
>Change this line: mySocket.onXML = handleIncoming;
>To this: mySocket.onXML = Delegate.create(this,handleIncoming);
>
>And that should solve your problem. Basically you're creating a proxy
>function on the XMLSocket object that then invokes the handleIncoming
>function on your OSC object. There are other ways to do this, but I
>think
>the Delegate method is generally considered the best practice.
>
>Hope that helps,
>
>Jim
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of
hbruyere
>Sent: Thursday, November 24, 2005 10:19 PM
>To: Flashcoders@chattyfig.figleaf.com
>Subject: [Flashcoders] OOP newbie question
>
>Hi,
>
> 
>
>Here is a OOP newbie question.
>
> 
>
>I have a class (see below)..
>
> 
>
>Everything works fine. but the method "handleIncoming" can not access
()
>or
>maybe even find) the method "parseMessages".
>
>If I give the complete path to the instance of the OSC class (made in
my
>fla
>- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.
>
> 
>
>How should I code this to make it works ?
>
> 
>
> 
>
>class OSC
>
>{
>
> 
>
>var mySocket : XMLSocket;
>
>//
>
>//
>
>public function OSC ()
>
>{
>
>connect ();
>
>}
>
>//
>
>//
>
>function connect ()
>
>{
>
>mySocket = new XMLSocket ();
>
>mySocket.onXML = handleIncoming;
>
>}
>
>//
>
>//
>
>function handleIncoming (xmlIn)
>
>{
>
>parseMessages (xmlIn);
>
> 
>
>}
>
>//
>
>function parseMessages (node)
>
>{
>
>actions..
>
>}
>
>}
>
> 
>
>Thanks for your attention,
>
> 
>
>//h
>
>___
>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


Re: [Flashcoders] OOP newbie question

2005-11-24 Thread Andy Johnston
I never have a use for self refencing.. maybe thats just me, feels like 
a dirty hack.



Just create reference to your class. You will need that a lot ...


function connect ()

{

mySocket = new XMLSocket ();
var _obj = this;

 mySocket.onXML = function ()
{
_obj.handleIncoming();
  }
}




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jim
Phelan
Sent: Friday, 25 November 2005 2:27 PM
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OOP newbie question

Hi,

The problem here is scope. When you call parseMessages, you doing it in
the
scope of the mySocket object (where the method doesn't exist.) 


There's a pretty simple workaround for this using the Delegate utility
that
comes with Flash.

At the top of your class file, do this : import mx.utils.Delegate;

Change this line: mySocket.onXML = handleIncoming;
To this: mySocket.onXML = Delegate.create(this,handleIncoming);

And that should solve your problem. Basically you're creating a proxy
function on the XMLSocket object that then invokes the handleIncoming
function on your OSC object. There are other ways to do this, but I
think
the Delegate method is generally considered the best practice.

Hope that helps,

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of hbruyere
Sent: Thursday, November 24, 2005 10:19 PM
To: Flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] OOP newbie question

Hi,



Here is a OOP newbie question.



I have a class (see below)..



Everything works fine. but the method "handleIncoming" can not access ()
or
maybe even find) the method "parseMessages".

If I give the complete path to the instance of the OSC class (made in my
fla
- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.



How should I code this to make it works ?





class OSC

{



   var mySocket : XMLSocket;

//

//

   public function OSC ()

   {

   connect ();

   }

   //

   //

   function connect ()

   {

   mySocket = new XMLSocket ();

   mySocket.onXML = handleIncoming;

   }

//

//

   function handleIncoming (xmlIn)

   {

   parseMessages (xmlIn);



   }

//

   function parseMessages (node)

   {

actions..

}

}



Thanks for your attention,



//h

___
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


RE: [Flashcoders] OOP newbie question

2005-11-24 Thread Robin Burrer
Just create reference to your class. You will need that a lot ...


function connect ()

{

mySocket = new XMLSocket ();
var _obj = this;

  mySocket.onXML = function ()
{
_obj.handleIncoming();
  }
}




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jim
Phelan
Sent: Friday, 25 November 2005 2:27 PM
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OOP newbie question

Hi,

The problem here is scope. When you call parseMessages, you doing it in
the
scope of the mySocket object (where the method doesn't exist.) 

There's a pretty simple workaround for this using the Delegate utility
that
comes with Flash.

At the top of your class file, do this : import mx.utils.Delegate;

Change this line: mySocket.onXML = handleIncoming;
To this: mySocket.onXML = Delegate.create(this,handleIncoming);

And that should solve your problem. Basically you're creating a proxy
function on the XMLSocket object that then invokes the handleIncoming
function on your OSC object. There are other ways to do this, but I
think
the Delegate method is generally considered the best practice.

Hope that helps,

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of hbruyere
Sent: Thursday, November 24, 2005 10:19 PM
To: Flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] OOP newbie question

Hi,

 

Here is a OOP newbie question.

 

I have a class (see below)..

 

Everything works fine. but the method "handleIncoming" can not access ()
or
maybe even find) the method "parseMessages".

If I give the complete path to the instance of the OSC class (made in my
fla
- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.

 

How should I code this to make it works ?

 

 

class OSC

{

 

var mySocket : XMLSocket;

//

//

public function OSC ()

{

connect ();

}

//

//

function connect ()

{

mySocket = new XMLSocket ();

mySocket.onXML = handleIncoming;

}

//

//

function handleIncoming (xmlIn)

{

parseMessages (xmlIn);

 

}

//

function parseMessages (node)

{

actions..

}

}

 

Thanks for your attention,

 

//h

___
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] OOP newbie question

2005-11-24 Thread Andy Johnston

import mx.utils.Delegate;

class OSC {
   var mySocket : XMLSocket;

   public function OSC () {
connect ();
   }

   function connect () {
mySocket = new XMLSocket ();
mySocket.onXML = Delegate.create(this,handleIncoming);
   }

   function handleIncoming (xmlIn){
parseMessages (xmlIn);
   }

   function parseMessages (node){

   }
}


Hi,



Here is a OOP newbie question.



I have a class (see below)..



Everything works fine. but the method "handleIncoming" can not access () or
maybe even find) the method "parseMessages".

If I give the complete path to the instance of the OSC class (made in my fla
- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.



How should I code this to make it works ?





class OSC

{



   var mySocket : XMLSocket;

//

//

   public function OSC ()

   {

   connect ();

   }

   //

   //

   function connect ()

   {

   mySocket = new XMLSocket ();

   mySocket.onXML = handleIncoming;

   }

//

//

   function handleIncoming (xmlIn)

   {

   parseMessages (xmlIn);



   }

//

   function parseMessages (node)

   {

actions..

}

}



Thanks for your attention,



//h

___
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] OOP newbie question

2005-11-24 Thread Jim Phelan
Hi,

The problem here is scope. When you call parseMessages, you doing it in the
scope of the mySocket object (where the method doesn't exist.) 

There's a pretty simple workaround for this using the Delegate utility that
comes with Flash.

At the top of your class file, do this : import mx.utils.Delegate;

Change this line: mySocket.onXML = handleIncoming;
To this: mySocket.onXML = Delegate.create(this,handleIncoming);

And that should solve your problem. Basically you're creating a proxy
function on the XMLSocket object that then invokes the handleIncoming
function on your OSC object. There are other ways to do this, but I think
the Delegate method is generally considered the best practice.

Hope that helps,

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of hbruyere
Sent: Thursday, November 24, 2005 10:19 PM
To: Flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] OOP newbie question

Hi,

 

Here is a OOP newbie question.

 

I have a class (see below)..

 

Everything works fine. but the method "handleIncoming" can not access () or
maybe even find) the method "parseMessages".

If I give the complete path to the instance of the OSC class (made in my fla
- for example "_root.OSC_Obj.parseMessages (xmlIn);" ) it works.

 

How should I code this to make it works ?

 

 

class OSC

{

 

var mySocket : XMLSocket;

//

//

public function OSC ()

{

connect ();

}

//

//

function connect ()

{

mySocket = new XMLSocket ();

mySocket.onXML = handleIncoming;

}

//

//

function handleIncoming (xmlIn)

{

parseMessages (xmlIn);

 

}

//

function parseMessages (node)

{

actions..

}

}

 

Thanks for your attention,

 

//h

___
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