Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
MultyInit for NativeSignal
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Leezarius  
View profile  
 More options Oct 24 2011, 9:04 am
From: Leezarius <leep...@gmail.com>
Date: Mon, 24 Oct 2011 06:04:14 -0700 (PDT)
Local: Mon, Oct 24 2011 9:04 am
Subject: MultyInit for NativeSignal
Hi EveryBody!
I see signals and find strange situation:

...
                public var clicked:NativeSignal;

                public function ButtonSound(_view:MovieClip)
                {
                        view = _view;
                        init();
                }

                private function init():void
                {

                        clicked = new NativeSignal(view, MouseEvent.CLICK, MouseEvent);
                        clicked.add(changeState);
                        clicked = new NativeSignal(view, MouseEvent.ROLL_OVER, MouseEvent);
                        clicked.add(overHandler);
                        clicked = new NativeSignal(view, MouseEvent.ROLL_OUT, MouseEvent);
                        clicked.add(outHandler);
...

And its work!
My button duspatch all 3 state.
trace(clicked.numListeners)// output:"1"
This means the signal keeps copies of all assigned without the
possibility of their removal?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Richardson  
View profile  
 More options Oct 24 2011, 11:03 am
From: Simon Richardson <stickup...@gmail.com>
Date: Mon, 24 Oct 2011 16:03:51 +0100
Local: Mon, Oct 24 2011 11:03 am
Subject: Re: [as3-signals] MultyInit for NativeSignal
The NativeSignal wraps addEventListener, so the changeState, overHandler, outHandler get passed to the native method. So when the view clicked all three methods would be called (this is expected). Ideally the gc would collect this when the view is removed and the class (which the native signals are in) is gc'd, but when this might happen is a guess.

My solution would be to use different variables for the the NativeSignals (nativeClicked, nativeRollOver, nativeRollOut, etc) and this would prevent the leak, but if this situation does occur then you could just use the view.removeEventListener(MouseEvent.CLICK, changeState), but then you have to rely on gc for the original signals being cleared.

But from what I'm seeing, I think you're trying to do the following:

public const signals : Vector.<NativeSignal> = new Vector.<NativeSignal>(3, true);

signals[0] = new NativeSignal(view, MouseEvent.CLICK, MouseEvent);
signals[0].add(changeState);
signals[1] = new NativeSignal(view, MouseEvent.ROLL_OVER, MouseEvent);
signals[1].add(overHandler);
signals[2] = new NativeSignal(view, MouseEvent.ROLL_OUT, MouseEvent);
signals[2].add(outHandler);

If this is the aim, I would suggest making a immutable class that has 3 getters for each NativeSignal and having a method on it to determine how many signals are used in total. (get numListeners())

(other options exist as well, this is just how I would do it.)

Cheers
si

On 24 Oct 2011, at 14:04, Leezarius wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Penner  
View profile  
 More options Oct 24 2011, 11:17 am
From: Robert Penner <rob...@robertpenner.com>
Date: Mon, 24 Oct 2011 08:17:35 -0700
Local: Mon, Oct 24 2011 11:17 am
Subject: Re: [as3-signals] MultyInit for NativeSignal

If you're using several NativeSignals, have a look at the new base classes,
e.g. SignalMovieClip:

https://github.com/robertpenner/as3-signals/blob/master/src/org/osfla...

// view extends SignalMovieClip
view.signals.click.add(onClick);
view.signals.rollOver.add(onRollOver);
view.signals.rollOut.add(onRollOut);

Robert

On Mon, Oct 24, 2011 at 8:03 AM, Simon Richardson <stickup...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leezarius  
View profile  
 More options Oct 24 2011, 11:47 am
From: Leezarius <leep...@gmail.com>
Date: Mon, 24 Oct 2011 08:47:11 -0700 (PDT)
Local: Mon, Oct 24 2011 11:47 am
Subject: Re: MultyInit for NativeSignal
Simon Thanks!
I used three different signal

 public var clicked:NativeSignal;
 public var overed:NativeSignal;
 public var outed:NativeSignal;

But I was wrong when copying and did not change signal names when
initializing.
I understand that the signal is a wrapper, but I think it's a bad
situation.
In the following case, for example, I have only one array
var customArray:Array;
customArray=[1,1,1];
customArray=[2,2,2];
customArray=[3,3,3];
And this array is [3,3,3]

In the case of a signal I can add any number of events and a problem
with garbage collector or uncontrolled behavior of the object.
Thanks.

On Oct 24, 7:03 pm, Simon Richardson <stickup...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leezarius  
View profile  
 More options Oct 24 2011, 11:49 am
From: Leezarius <leep...@gmail.com>
Date: Mon, 24 Oct 2011 08:49:25 -0700 (PDT)
Local: Mon, Oct 24 2011 11:49 am
Subject: Re: MultyInit for NativeSignal
Hi Robert!
Many respects for your code!
I try SignalMovieClip, thank you.

On Oct 24, 7:17 pm, Robert Penner <rob...@robertpenner.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stray  
View profile  
 More options Oct 24 2011, 11:54 am
From: Stray <dailystray...@googlemail.com>
Date: Mon, 24 Oct 2011 16:54:41 +0100
Local: Mon, Oct 24 2011 11:54 am
Subject: Re: [as3-signals] Re: MultyInit for NativeSignal
True, but what you're comparing (with the signals) is more like:

var customArray:Array;

customArray = [view]
customArray[0].addEventListener(MouseEvent.CLICK...);
customArray = [view]
customArray[0].addEventListener(MouseEvent.MOUSE_DOWN...);
customArray = [view]
customArray[0].addEventListener(MouseEvent.MOUSE_UP...);

Which would behave in just the same way as the Signals do...

Stray

On 24 Oct 2011, at 16:47, Leezarius wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Penner  
View profile  
 More options Oct 24 2011, 11:58 am
From: Robert Penner <rob...@robertpenner.com>
Date: Mon, 24 Oct 2011 08:58:28 -0700
Local: Mon, Oct 24 2011 11:58 am
Subject: Re: [as3-signals] Re: MultyInit for NativeSignal

That's the thing with listeners: the event source has a reference to them.
It can't tell when you've nulled or replaced one of the references to the
listening object. You need to clean up afterwards and this applies beyond
Signals. At least removeAll() makes it easy.

Robert


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leezarius  
View profile  
 More options Oct 24 2011, 12:38 pm
From: Leezarius <leep...@gmail.com>
Date: Mon, 24 Oct 2011 09:38:03 -0700 (PDT)
Local: Mon, Oct 24 2011 12:38 pm
Subject: Re: MultyInit for NativeSignal
True if we remember(know) that the signal is not an independent
entity.
Thanks.

On Oct 24, 7:54 pm, Stray <dailystray...@googlemail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leezarius  
View profile  
 More options Oct 24 2011, 12:38 pm
From: Leezarius <leep...@gmail.com>
Date: Mon, 24 Oct 2011 09:38:23 -0700 (PDT)
Local: Mon, Oct 24 2011 12:38 pm
Subject: Re: MultyInit for NativeSignal
Thank Roberts.

On Oct 24, 7:58 pm, Robert Penner <rob...@robertpenner.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stray  
View profile  
 More options Oct 24 2011, 12:40 pm
From: Stray <dailystray...@googlemail.com>
Date: Mon, 24 Oct 2011 17:40:55 +0100
Local: Mon, Oct 24 2011 12:40 pm
Subject: Re: [as3-signals] Re: MultyInit for NativeSignal
:) And it's a good thing to call out to people learning Signals - so nicely picked up!

On 24 Oct 2011, at 17:38, Leezarius wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »