Flash/Actionscript 3 - embedded sound play/stop? -


how play/stop embedded music file in flash/as3 via button?

this have:

import flash.events.event;   import flash.events.mouseevent; import flash.display.movieclip;   import flash.media.sound; import flash.media.soundchannel;  var mymusic:sound = new themesong();  var channel:soundchannel = mymusic.play();  startbutton.addeventlistener(mouseevent.click, onstartclick); stopbutton.addeventlistener(mouseevent.click, onstopclick);  function onstartclick(event:mouseevent):void{     mymusic.play(); }  function onstopclick(event:mouseevent):void{     mymusic.stop(); } 

themesong name of class assigned music file (import -> libraries -> properties -> export -> class name). startbutton , stopbutton identifiers buttons.

if run i'll error saying:

"scene 1, layer 'actions', frame 1, line 69 1061: call possibly undefined method stop through reference static type flash.media:sound." 

thanks.

you're close flash wonky sometimes:

import flash.events.event;   import flash.events.mouseevent; import flash.display.movieclip;   import flash.media.sound; import flash.media.soundchannel;  var mymusic:sound = new themesong();  var channel:soundchannel = mymusic.play();  startbutton.addeventlistener(mouseevent.click, onstartclick); stopbutton.addeventlistener(mouseevent.click, onstopclick);  function onstartclick(event:mouseevent):void{     channel = mymusic.play(); }  function onstopclick(event:mouseevent):void{     channel.stop(); } 

http://help.adobe.com/en_us/flashplatform/reference/actionscript/3/flash/media/soundchannel.html#stop()


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -