import flash.external.ExternalInterface;
ExternalInterface.addCallback( "playMusic" , playMusic);
ExternalInterface.addCallback( "stopMusic" , stopMusic);
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
var _sound:Sound;
var _channel:SoundChannel;
function playMusic(file:String= '' , count: int =0)
{
_sound = new Sound( new URLRequest(file));
_channel=_sound.play(0,count);
}
function stopMusic() {
_channel.stop();
}
* This source code was highlighted with Source Code Highlighter .
function musicLoad()
{
swfobject.embedSWF( "/swf/music.swf" , "sound" , "0" , "0" , "9.0.0" );
}
function musicPlay (file, count)
{
if (!file)
{
file= '/sound/default.mp3' ;
}
if (!count)
{
count=1;
}
document .getElementById( 'sound' ).playMusic(file, count);
}
function musicStop ()
{
document .getElementById( 'sound' ).stopMusic();
}
* This source code was highlighted with Source Code Highlighter .
musicPlay( '/sound/123.mp3' );
musicStop();
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/67786/