Hi Aaron,

yeah.. tricky.

best i could come up with was to use the prototype of onMouseUp since i guess it is rarely used for MovieClips, and then hitTest. this'll only work for MovieClips though as Buttons have no hitTest method.

class ReleaseListener {
        
        private var __clips : Array ;
        
        public function ReleaseListener ( ) {
                
                __clips = [ ] ;
                
                Mouse.addListener ( this ) ;
                var listener = this ;
                MovieClip.prototype.onMouseUp = function ( ) {
                        if ( this.hitTest ( _root._xmouse , _root._ymouse ) ) {
                                listener.addClip ( this ) ;
                        }
                }
        }
        
        public function addClip ( o : MovieClip ) {
                if ( o != _root ) __clips.push ( o ) ;
        }
        
        public function onMouseUp ( Void ) : Void {
                for ( var i : Number = 0 ; i < __clips.length ; i ++ ) {
                        trace ( __clips[ i ] + " onRelease" ) ;
                }
                __clips = [ ] ;
        }
        
}

sorry i have no better solution.... anyone?

cheers, Alisdair


On 25 Nov 2005, at 10:32, Aaron Haines wrote:


Hi Alisdair

I want to create a class which would be able to detect which movieclip or
button has been clicked whenever any movieclip or button is clicked.

I want this class to exist independently of any onRelease functions which
have been assigned directly to movieclip instances.

i.e. I don't want to have to include a call to my class in the onRelease function of every movieclip instance - I just want my class to listen for any onRelease events, and then do some action depending on which clip was
clicked.

The idea is that I could then include this class in movies which have
already been created without having to go back through and add a call to my
class into every button and movieclip onRelease function.

If I set the MovieClip.prototype.onRelease as you suggest this would
presumably then be overwritten by the direct assignment of the onRelease to
the movieclip instance.

I can make all movieclips broadcasters by using AsBroadcaster on the
MovieClip.prototype, but this doesn't make them automatically broadcast the
onRelease event.

I was wondering if there was a way to do this with EventDispatcher or
something similar..?

Thanks
a.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Alisdair
Mills
Sent: 25 November 2005 08:46
To: Flashcoders mailing list
Subject: Re: [Flashcoders] enable all movieclips to broadcast theironRelease
event

could you provide more detail on what you want to achieve?

the following would make a Class object receive all MovieClip
onRelease events. and would do so for a timeline with slightly
modified code. not sure this is what you mean though?

public function initOnRelease ( Void ) : Void {
        var listener = this ;
        MovieClip.prototype.onRelease = function ( ) { listener.sayHello
( ) ; } ;
}
public function sayHello ( Void ) : Void {
        trace ( "HELLO!!!!" ) ;       
}

cheers, Alisdair



On 24 Nov 2005, at 19:25, Aaron Haines wrote:



Is this possible..?

Anyone know how to do it..?



I want to be able to add a listener with an onRelease function to any
movieclip.

The onRelease of the listener would be triggered whenever the
onRelease of
the movieclip is triggered.



Any help much appreciated.



a.



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to