Copy link to clipboard
Copied
I am building an mp3 playing in flash cs6 using actionscript 3. I keep receiving this error message
ReferenceError: Error #1065: Variable TCMText is not defined.
Here is my code: Note that the third variable "var isPlaying:Boolean = false;" is what is causing the problem because it worked fine before this. I am trying to prevent the audio from overlapping if the play button is pressed again while it is already playing
var mySound:Sound;
var myChannel:SoundChannel;
var isPlaying:Boolean = false;
mySound = new Sound;
mySound.load(new URLRequest("media/OnImpulse.mp3"));
btn_play.addEventListener(MouseEvent.CLICK, playSound);
btn_stop.addEventListener(MouseEvent.CLICK, stopSound);
//pause_btn.addEventListener(MouseEvent.CLICK, runTracer);
function stopSound(myEvent:MouseEvent):void {
myChannel.stop();
isPlaying = false;
}
function playSound(myEvent:MouseEvent):void {
if (!isPlaying) {
myChannel = mySound.play();
isPlaying = true;
}
}
Copy link to clipboard
Copied
The code you say is causing the problem appears to be fine. That it is able to name a variable that doesn't appear in your code makes me think there is a component issue somewhere, or as a minimum somewhere else than the code you show.
Go into your Flash Publish Settings and select the option to Permit Debugging. Run the file again and show the entire error message that you get.
Copy link to clipboard
Copied
thanks a lot, apparently the "isPlaying" is a default video code already so i changed all "isPlaying" instances to "soundIsPlaying" and it worked! However now when i return to the home screen, the pause button will no longer work.
Copy link to clipboard
Copied
You didn't show or explain anything regarding the pause button beyond its event listener so I can't say much about that. A pause is usually just a stop function that remembers where it stopped.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now