Copy link to clipboard
Copied
hi
i have AS3 mp3 player , in a specific Frame i need to pause sound and when i exit this frame the sound play again
the paues-play is put on 1 movieclip with instance name controller
the frame one in controller is show pause icon and frame 2 is play
i put these functions to my button that must sound paused :
controller.gotoAndStop(2); | |||
pausePosition = sndChannel.position; | |||
sndChannel.stop(); | |||
isPlaying = false; |
anyway i put the event Event.REMOVED_FROM_STAGE and put these funcions in the frame that i want to sound play again after exit frame :
controller.gotoAndStop(1); | |
sndChannel = soundClip.play(pausePosition); | |
isPlaying = true; |
These code works well in Flash but my Problem is On Swfkit ( third party Tools to create Desktop Application ) , the exe application made by swfkit run without error , but when i want to Exit From frame (that sound Pause and play on exit) the Application Not responding and the swfkit Has Stop working apeard
i check all code and find the line that make this happend is :
controller.gotoAndStop(1);
it`s very strange and wired cause when i remove this code or even i change the frame number to 2 this problem not apear at all !!
so i`m really curious about that
is this something in my code cause this happend ? anyone have idea ?
i put the mp3 code here too , maybe it help someone find where could be cause this problem :
//imports the necessary as events
import flash.events.Event
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
var isPlaying:Boolean = new Boolean();
var pausePosition:Number = new Number();
//Create an instance of the Sound class
var soundClip:Sound = new Sound();
//Create a new SoundChannel Object
var sndChannel:SoundChannel = new SoundChannel();
//Load sound using URLRequest
soundClip.load(new URLRequest("song.mp3"));
//Create an event listener that wll update once sound has finished loading
soundClip.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
controller.addEventListener(MouseEvent.MOUSE_DOWN, btnPressController, false, 0, true);
stop_btn.addEventListener(MouseEvent.MOUSE_DOWN, btnPressStop, false, 0, true);
function onComplete(evt:Event):void {
//Play loaded sound
sndChannel = soundClip.play();
isPlaying = true;
}
function btnPressController(evt:MouseEvent):void
{
switch(isPlaying)
{
case true:
controller.gotoAndStop(2);
pausePosition = sndChannel.position;
sndChannel.stop();
isPlaying = false;
break;
case false:
controller.gotoAndStop(1);
sndChannel = soundClip.play(pausePosition);
isPlaying = true;
break;
}
}
function btnPressStop(evt:MouseEvent):void
{
pausePosition = 0;
sndChannel.stop();
controller.gotoAndStop(2);
isPlaying = false;
}
i try to contact swfkit and hope to recieve any suggestion or tips but no success at all and this forum is my only chance
Copy link to clipboard
Copied
when I try to compile your code I get an error:
"isPlaying:conflict in namespace"
you shouldn`t use a static property (in this case the MovieClip class` isPlaying)
and name your own Boolean property with it.
rename all your Booleans in
ifPlaying
and see if that solves your problem
Copy link to clipboard
Copied
Thanks Dear moccamaximum for take a look at my problem
i rename all booleans to ifPlaying
but nothing change and still get Projector CLosed at Exit Frame
it really strange that
controller.gotoAndStop(1);
cause this !! is this possible to run this script after a few second ? maybe it help
Copy link to clipboard
Copied
you can delay the execution of a function with setTimeout
Find more inspiration, events, and resources on the new Adobe Community
Explore Now