Copy link to clipboard
Copied
I have a problem with function start sound(startstart). I cant compile the program before getting an error.
var channel:SoundChannel = new SoundChannel();
I have 3 similar functions as NRKP1
mcButikker.btnNRKP1.addEventListener(MouseEvent.CLICK, NRKP1);
function NRKP1(e:MouseEvent){
var SoundNRKP1:Sound = new Sound();
channel.stop();
var req:URLRequest = new URLRequest("http://lyd.nrk.no/nrk_radio_p1pluss_mp3_m");
SoundNRKP1.load(req);
channel = SoundNRKP1.play();
}
When I added start/stop buttons for starting and stopping I got the error. But when I dont have them, and choose one of the 3 functions, it will stop the sound, and play another sound. "channel.start(); is the issue here. I have tried several ways around this but nothing seems to work.
btnStart.addEventListener(MouseEvent.CLICK, startstart);
function startstart(e:MouseEvent){
channel.start();
}
btnStopp.addEventListener(MouseEvent.CLICK, stopstop);
function stopstop(e:MouseEvent){
channel.stop();
}
Here is the complete code for reference:
...import flash.events.MouseEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.display.SimpleButton;
import flash.events.Event;
var bgmList:Vector.<String> = new <String>
[
"https://website.com/Beat_Your_Competition.mp3",
"bgm/Bounce_House.mp3",
"bgm/Chess_Pieces.mp3"
];
var sound:Sound;
var sChannel:SoundChannel;
var sTransform:SoundTransform;
var channelPosition:Number
Copy link to clipboard
Copied
Play the music, it seems nothing happens when I push the soundbuttons. Yeah, I have traced alot
Copy link to clipboard
Copied
OK! Here we go.
animate_cc_as3_playlist_from_json_jc.zip - Google Drive
Basically:
- You were adding individual listeners for the buttons but was checking for clicks as the event listeners had been added to the containers. I changed it and added the listeners to the containers.
- I added names to the buttons from the list ("song0", "song1", and so on). This is needed to get the index for the current song.
- I also set the buttons' (list) mouseChildren property to false so the text inside is not selectable.
I might have done other changes, but I don't really remember now. xP
Copy link to clipboard
Copied
Thank you so much!
I had to take a few hours to look at the changes and correct a minor issue.
I got a issue with the channel not changing the song. After a while I understood it was the 10 first songs all playing the same song,
the traces all showed up "0" for the 10 first buttons. I changed the "name.slice" from 5 to 4, and it solved the problem Thank you so much!
I have another question to ask. Because when I scroll up/down it almost all the time choose the channel my thumb is when I remove my thumb after scrolling, if you understand. For me it looks like the scroll is too sensitive. The same happens in the emulator on the pc when using a mouse. Is there a way to code around this? Because it is kinda annoying
Yet again, thank you!