EventListeners do not work

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

EventListeners do not work

haxemdks.10.maischus
Hi,

I was creating a little application (HaXe Flash) that should play some
sound bites, but somehow I cannot get the EventListeners (ContextMenu
and Play/Stop Button) to work. Has somebody experienced similar
problems? It compiles without any errors.

Paweł

Here the relevant parts of my code:

import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.Event;

import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.ContextMenuEvent;

import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;

class SoundPlayer extends flash.display.Sprite {
        ...
       
        public function showCopyright(e:ContextMenuEvent) {
                flash.Lib.getURL(new URLRequest("http://www.company.com/") );
        }

    static function main() {
                new SoundPlayer("file.mp3");
    }
       
        //Constructor
        public function new(url:String) {
                ....
               
                //GUI
                var cm:ContextMenu = new ContextMenu();
                var cmi:ContextMenuItem = new ContextMenuItem("(c) 2009 Company");
                cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, showCopyright);
                cm.customItems.push(cmi);
               
                var playIcon = flash.Lib.attach("playIcon");
                var playButton:Sprite= new MovieClip();
                playButton.buttonMode = true;
                playButton.addEventListener(MouseEvent.CLICK, playpause);
                playButton.addChild(playIcon);
               
                var stopIcon = flash.Lib.attach("stopIcon");
                stopIcon.x=14;
                var stopButton:Sprite = new Sprite();
                stopButton.buttonMode = true;
                stopButton.addEventListener(MouseEvent.CLICK, stop);
                stopButton.addChild(stopIcon);
               
                var spr:flash.display.Sprite = flash.Lib.current;
                spr.addChild(stopButton);
                spr.addChild(playButton);
                spr.contextMenu = cm;
                super();
        }
       
        private function playpause(e:MouseEvent) {
                ...
        }
       
        private function stop(e:MouseEvent) {
                ....
        }
        ....
}


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: EventListeners do not work

Armén
Did you try to remove the copyright from the context menu? I heard
sometimes it helps.

On Tue, Aug 18, 2009 at 17:55, <[hidden email]> wrote:

> Hi,
>
> I was creating a little application (HaXe Flash) that should play some
> sound bites, but somehow I cannot get the EventListeners (ContextMenu
> and Play/Stop Button) to work. Has somebody experienced similar
> problems? It compiles without any errors.
>
> Paweł
>
> Here the relevant parts of my code:
>
> import flash.media.Sound;
> import flash.media.SoundLoaderContext;
> import flash.media.SoundChannel;
> import flash.net.URLRequest;
> import flash.events.IOErrorEvent;
> import flash.events.ProgressEvent;
> import flash.events.Event;
>
> import flash.display.Sprite;
> import flash.display.MovieClip;
> import flash.events.MouseEvent;
> import flash.events.ContextMenuEvent;
>
> import flash.ui.ContextMenu;
> import flash.ui.ContextMenuItem;
>
> class SoundPlayer extends flash.display.Sprite {
>        ...
>
>        public function showCopyright(e:ContextMenuEvent) {
>                flash.Lib.getURL(new URLRequest("http://www.company.com/") );
>        }
>
>    static function main() {
>                new SoundPlayer("file.mp3");
>    }
>
>        //Constructor
>        public function new(url:String) {
>                ....
>
>                //GUI
>                var cm:ContextMenu = new ContextMenu();
>                var cmi:ContextMenuItem = new ContextMenuItem("(c) 2009 Company");
>                cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, showCopyright);
>                cm.customItems.push(cmi);
>
>                var playIcon = flash.Lib.attach("playIcon");
>                var playButton:Sprite= new MovieClip();
>                playButton.buttonMode = true;
>                playButton.addEventListener(MouseEvent.CLICK, playpause);
>                playButton.addChild(playIcon);
>
>                var stopIcon = flash.Lib.attach("stopIcon");
>                stopIcon.x=14;
>                var stopButton:Sprite = new Sprite();
>                stopButton.buttonMode = true;
>                stopButton.addEventListener(MouseEvent.CLICK, stop);
>                stopButton.addChild(stopIcon);
>
>                var spr:flash.display.Sprite = flash.Lib.current;
>                spr.addChild(stopButton);
>                spr.addChild(playButton);
>                spr.contextMenu = cm;
>                super();
>        }
>
>        private function playpause(e:MouseEvent) {
>                ...
>        }
>
>        private function stop(e:MouseEvent) {
>                ....
>        }
>        ....
> }
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: EventListeners do not work

Pimm Hogeling
Hello there,

Skimming your code, I don't see any common problems. If you'd place a trace call in both mouseevent handling-methods (playpause and stop), what would happen?

On Tue, Aug 18, 2009 at 18:39, [hidden email] <[hidden email]> wrote:
Did you try to remove the copyright from the context menu? I heard
sometimes it helps.

On Tue, Aug 18, 2009 at 17:55, <[hidden email]> wrote:
> Hi,
>
> I was creating a little application (HaXe Flash) that should play some
> sound bites, but somehow I cannot get the EventListeners (ContextMenu
> and Play/Stop Button) to work. Has somebody experienced similar
> problems? It compiles without any errors.
>
> Paweł
>
> Here the relevant parts of my code:
>
> import flash.media.Sound;
> import flash.media.SoundLoaderContext;
> import flash.media.SoundChannel;
> import flash.net.URLRequest;
> import flash.events.IOErrorEvent;
> import flash.events.ProgressEvent;
> import flash.events.Event;
>
> import flash.display.Sprite;
> import flash.display.MovieClip;
> import flash.events.MouseEvent;
> import flash.events.ContextMenuEvent;
>
> import flash.ui.ContextMenu;
> import flash.ui.ContextMenuItem;
>
> class SoundPlayer extends flash.display.Sprite {
>        ...
>
>        public function showCopyright(e:ContextMenuEvent) {
>                flash.Lib.getURL(new URLRequest("http://www.company.com/") );
>        }
>
>    static function main() {
>                new SoundPlayer("file.mp3");
>    }
>
>        //Constructor
>        public function new(url:String) {
>                ....
>
>                //GUI
>                var cm:ContextMenu = new ContextMenu();
>                var cmi:ContextMenuItem = new ContextMenuItem("(c) 2009 Company");
>                cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, showCopyright);
>                cm.customItems.push(cmi);
>
>                var playIcon = flash.Lib.attach("playIcon");
>                var playButton:Sprite= new MovieClip();
>                playButton.buttonMode = true;
>                playButton.addEventListener(MouseEvent.CLICK, playpause);
>                playButton.addChild(playIcon);
>
>                var stopIcon = flash.Lib.attach("stopIcon");
>                stopIcon.x=14;
>                var stopButton:Sprite = new Sprite();
>                stopButton.buttonMode = true;
>                stopButton.addEventListener(MouseEvent.CLICK, stop);
>                stopButton.addChild(stopIcon);
>
>                var spr:flash.display.Sprite = flash.Lib.current;
>                spr.addChild(stopButton);
>                spr.addChild(playButton);
>                spr.contextMenu = cm;
>                super();
>        }
>
>        private function playpause(e:MouseEvent) {
>                ...
>        }
>
>        private function stop(e:MouseEvent) {
>                ....
>        }
>        ....
> }
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: EventListeners do not work

haxemdks.10.maischus
In reply to this post by haxemdks.10.maischus
Thank you for your quick responses. I took out the context menu, but
the buttons still do not work. Traces in both methods are not
show/executed.

> Hello there,
>
> Skimming your code, I don't see any common problems. If you'd place a trace
> call in both mouseevent handling-methods (playpause and stop), what would
> happen?
>
> On Tue, Aug 18, 2009 at 18:39, [hidden email] <[hidden email]>wrote:
>
> > Did you try to remove the copyright from the context menu? I heard
> > sometimes it helps.
> >
> > On Tue, Aug 18, 2009 at 17:55, <[hidden email]> wrote:
> > > Hi,
> > >
> > > I was creating a little application (HaXe Flash) that should play some
> > > sound bites, but somehow I cannot get the EventListeners (ContextMenu
> > > and Play/Stop Button) to work. Has somebody experienced similar
> > > problems? It compiles without any errors.
> > >
> > > Paweł
> > >
> > > Here the relevant parts of my code:
> > >
> > > import flash.media.Sound;
> > > import flash.media.SoundLoaderContext;
> > > import flash.media.SoundChannel;
> > > import flash.net.URLRequest;
> > > import flash.events.IOErrorEvent;
> > > import flash.events.ProgressEvent;
> > > import flash.events.Event;
> > >
> > > import flash.display.Sprite;
> > > import flash.display.MovieClip;
> > > import flash.events.MouseEvent;
> > > import flash.events.ContextMenuEvent;
> > >
> > > import flash.ui.ContextMenu;
> > > import flash.ui.ContextMenuItem;
> > >
> > > class SoundPlayer extends flash.display.Sprite {
> > >        ...
> > >
> > >        public function showCopyright(e:ContextMenuEvent) {
> > >                flash.Lib.getURL(new URLRequest("http://www.company.com/")
> > );
> > >        }
> > >
> > >    static function main() {
> > >                new SoundPlayer("file.mp3");
> > >    }
> > >
> > >        //Constructor
> > >        public function new(url:String) {
> > >                ....
> > >
> > >                //GUI
> > >                var cm:ContextMenu = new ContextMenu();
> > >                var cmi:ContextMenuItem = new ContextMenuItem("(c) 2009
> > Company");
> > >                cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
> > showCopyright);
> > >                cm.customItems.push(cmi);
> > >
> > >                var playIcon = flash.Lib.attach("playIcon");
> > >                var playButton:Sprite= new MovieClip();
> > >                playButton.buttonMode = true;
> > >                playButton.addEventListener(MouseEvent.CLICK, playpause);
> > >                playButton.addChild(playIcon);
> > >
> > >                var stopIcon = flash.Lib.attach("stopIcon");
> > >                stopIcon.x=14;
> > >                var stopButton:Sprite = new Sprite();
> > >                stopButton.buttonMode = true;
> > >                stopButton.addEventListener(MouseEvent.CLICK, stop);
> > >                stopButton.addChild(stopIcon);
> > >
> > >                var spr:flash.display.Sprite = flash.Lib.current;
> > >                spr.addChild(stopButton);
> > >                spr.addChild(playButton);
> > >                spr.contextMenu = cm;
> > >                super();
> > >        }
> > >
> > >        private function playpause(e:MouseEvent) {
> > >                ...
> > >        }
> > >
> > >        private function stop(e:MouseEvent) {
> > >                ....
> > >        }
> > >        ....
> > > }


--
haXe - an open source web programming language
http://haxe.org