Copy link to clipboard
Copied
I have a menu bar which need to use the function multiple times, how can i make the function reusable in every scene/frame?
Copy link to clipboard
Copied
Scripts that are in frame 1 should be usable in any other frame. Do you have an example FLA that you can put online somewhere, that shows the problem you're having?
Copy link to clipboard
Copied
But I have different scene which need to use the same function as well.
Copy link to clipboard
Copied
The script in frame 1 of scene 1 should still work in scene 2. I tried this script in scene 1:
test();
function test(){
trace("test1");
}
and this in scene 2:
test();
stop();
It traced "test1" twice. So, scene 2 was able to use scene 1's function.
Copy link to clipboard
Copied
Okay, thanks. Can i know how to pause audio and play back from last position without declare
var mySound:Sound = new Sound();
I want to stop the frame and play it when click on "play" button.
Copy link to clipboard
Copied
Any sounds that you cut off with a blank keyframe in scene 1 will not be heard in scene 2.
Copy link to clipboard
Copied
Also, these lines of script will stop everything:
import flash.media.SoundMixer;
SoundMixer.stopAll();
Copy link to clipboard
Copied
SoundMixer.stopAll(); will stop all the sound but how can i pause it and play it from the last position? i tried as below
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
var myTransform = new SoundTransform();
var lastPosition:Number = 0;
myChannel = mySound.play();
myTransform.volume = 0.5;
myChannel.soundTransform = myTransform;
pause_btn.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void{
lastPosition = myChannel.position;
myChannel.stop();
}
play_btn.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void{
myChannel = mySound.play(lastPosition);
myChannel.soundTransform = myTransform;
}