Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Flash (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2004, 08:54 AM
Authorized User
 
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default mouse listener trouble

Hi,

im using falsh mx 2004 pro and am having a bit trouble with using a mouse listener. I have two buttons, on to add the listener and the other to remove it. The add one works fine but the remove one doesnt. I have spent ages looking around to see what I am doing wrong but have been unsuccessfull. Can anyone help me?

I have this code in it -

function add_mouse_listener() {

    var select_listener:Object = new Object();
    select_listener.onMouseUp = selection_check;

    Mouse.addListener(select_listener);
    //Mouse.removeListener(select_listener);

}

function remove_mouse_listener() {

    trace("remove_mouse_listener() called");
    Mouse.removeListener(select_listener);

}

function selection_check() {

    trace("mouse listener active");

}

and on the buttons I have

on(release){
    trace("button released");

    _root.add_mouse_listener();

}

and on the other

on(release){
    trace("button released");

    _root.remove_mouse_listener();

}

Any help would be appreciated. Thanks for your time
 
Old October 22nd, 2004, 04:50 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

I don't really know anything about this as I'm only a Flash designer. However, you may want to ask this at Flash Kit You may get help there.

Just a quick warning: In order to use the Flash Kit forums, you need to register but the good thing is that you don't have to pay to use the Flash Kit forums


Hope this helps,



Ben Horne
-------------------------
I don't want to sound like I haven't made any mistakes. I'm confident I have.

Welcome to the New Age
 
Old October 25th, 2004, 05:09 AM
Authorized User
 
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just thought I would post the solution to this problem rather than just leaevining it blank, incase anyone else has this problem. The problem was that I was declaring the listener object in the add_mouse_listener function and therefore the object was accessible only to that object - it should have been ddeclared before the function. Stupid mistake really. But this is how it should have looked.


var select_listener:Object = new Object();

function add_mouse_listener() {

    select_listener.onMouseUp = selection_check;

    Mouse.addListener(select_listener);

}

function remove_mouse_listener() {

    trace("remove_mouse_listener() called");
    Mouse.removeListener(select_listener);

}

function selection_check() {

    trace("mouse listener active");

}


Now both functions have access to the listener object.
 
Old October 28th, 2004, 02:09 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

Glad you got it figured out.

Remember that you always have Flash Kit as a place to go to for help if we can't solve your problem here.

Ben Horne
-------------------------
I don't want to sound like I haven't made any mistakes. I'm confident I have.

Welcome to the New Age





Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementing a Queue Server Listener pdistant Java Basics 0 July 3rd, 2008 06:17 AM
HTTP Listener aveekb BOOK: Professional Java Development with the Spring Framework 2 May 7th, 2008 04:03 PM
Webservice listener dcrooks .NET Web Services 0 February 18th, 2005 05:33 PM
PHP IIS5 listener stew998 Pro PHP 0 February 9th, 2005 11:36 AM
XML Listener rodmcleay VB How-To 2 June 25th, 2003 08:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.