Question

when I click the button I get out of the flash application. on which I want is when I click on the sound of his voice sounded and after completion, then exit of the flash application.

this is my code

Exit.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_4);
function fl_MouseClickHandler_4(event:MouseEvent):void
{
var button:button1 = new button1();
var myChannel:SoundChannel = button.play();

if (myChannel !=null)
{
    fscommand("quit");
}

}

What should i do whit these code

yeah i already get this this is my code that works

import flash.events.MouseEvent;
import flash.media.Sound;

function fl_MouseClickHandler_4(event:MouseEvent):void
{
    var button:button2 = new button2();
    var myChannel1:SoundChannel = button.play();

myChannel1.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete); 
}

function onPlaybackComplete(event:Event) 
{ 
    fscommand("quit");
}
Était-ce utile?

La solution

There is some wierd button1 class of which you haven't provided any details, and you trying to call a play() method on it. Maybe you did have implemented it and this method delegates the play command to appropriate sound object but I will assume that you haven't. Your code should look like this:

function fl_MouseClickHandler_4(event:MouseEvent):void
{
    var snd:Sound = new Sound(new URLRequest("yourSound.mp3")); 

    var channel:SoundChannel = snd.play();
    channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete); 
}

function onPlaybackComplete(event:Event) 
{ 
    fscommand("quit");
}

I suggest you to read the following article on playing sounds if you'll encounter any other problems: Playing sounds. ActionScript 3.0 Developer's Guide

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top