Note that there are some explanatory texts on larger screens.

plurals
  1. POStreaming sound control in Flex (Newbie)
    primarykey
    data
    text
    <p>I'm assuming my lack of knowledge (I just started learning Flex yesterday, hah!) is the reasoning behind my inability to figure out how to make this work correctly - it may even just be a code positioning issue.</p> <p>I've got several MP3 files I'm trying to stream. Right now I'm just trying to start and stop the main MP3. I've got the MP3 successfully playing, but stopping it is the issue I'm having. Here's my current code:</p> <pre><code>&lt;mx:Script&gt; &lt;![CDATA[ import flash.events.Event; import flash.media.*; import flash.media.Sound; import flash.media.SoundLoaderContext; import flash.net.URLRequest; import mx.controls.Button; //set current track &amp; load song var currentTrack:Number = 1; var song:Sound = new Sound(); var req:URLRequest = new URLRequest("../assets/0"+currentTrack+".mp3"); var context:SoundLoaderContext = new SoundLoaderContext(8000, true); //CREATE BUTTONS (being loaded in mx:application on load) private function createControls():void { var playButton:Button = new Button(); playButton.label = "PLAY"; playButton.id = "playButton"; playButton.addEventListener(MouseEvent.CLICK, clickPlayHandler); playerControls.addChild(playButton); var stopButton:Button = new Button(); stopButton.label = "STOP"; stopButton.id="stopButton"; stopButton.addEventListener(MouseEvent.CLICK, clickStopHandler); playerControls.addChild(stopButton); } //HANDLE CLICKS private function clickPlayHandler(event:Event):void { var button:Button = event.currentTarget as Button; song.load(req, context); song.play(); } private function clickStopHandler(event:Event):void { var button:Button = event.currentTarget as Button; //This is not working... song.close(); } ]]&gt; </code></pre> <p></p> <p>So I've got the song.play working, but the song.close doesn't stop the stream, it does nothing. Any clue how I could do this correctly/what I'm doing wrong?</p> <p>Thanks! :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload