I am brand new to flash and AS3, and everything else code related. I've built a simple file with text and audio. The audio is an external file, and it plays with a mouse click. Everything tests fine in flash. I also placed the file in Dreamweaver and previewed in a browser - that's working. But... I've now uploaded the file to a live site. The text shows up but it doesn't play. Where should I look for the problem?

firstly I would add the event listener to the button that's activating playback. Not to the stage unless you want any portion of the stage to activate playback.

I must assume that fl_toPlay is the button?

also, are you nesting swf's? Or is this file your only file that is referencing the audio directly on the server. Check to make sure that your audio is named properly on your server and that your directory structure is proper.

I can't think of anything off hand besides what I mentioned. Are you using a local server or a server located on the internet? If it's a server on your local network it may not work properly. I have had this happen when trying to play FLV's over my local network. On the internet it works fine.

What device(s) are you using to test your playback functionality? If your mp3 is large it may not cache properly on Flash-enabled smartphones or tablet devices.

any portion of the stage activates playback, and that's ok as I'm just using it at this point to read paragraphs of text. I'd like to figure out how to click sentence by sentence and highlight the text eventually, but this is my starting point.

I am not nesting swf's. this is the only file that is referencing the audio directly on the server. I'll triple check directory link, but I think its ok.

I'm using an internet server when I have the problem. The file plays fine on my local machine.

As far as per-sentence audio cues are concerned you could use a similar technique that is used by Flash Video wrapper components that use cuepoints to go to a particular video section or trigger a stage event at that particular cue point. At least I'm guessing you could.

You could also use a combination of substring conditional statements that search for a particular combination of substrings within the given text but you would have to feed your text into the actionscript to do so. Simply having audio wouldn't be an effective way to do it because voice recognition is very very complex. And I haven't come across any voice recognition in Flash although someone has probably done it. But you would feed the matching text that is based on the audio into a searchable string. You could probably use XML or something also to check for text phrases and trigger highlighting. I'm brainstorming.

I will have to use your code and test it out on my end to see if I can get it to play, if in fact your directory structure works and your server is up and running properly and playing back the audio normally.

Can you test something for me?

Can you code the following in Dreamweaver?:

<html>

<head>

<title>test audio</title>

</head>

<body>

<a href="[the path and name of your mp3]">my audio link</a>

</body>

</html>

See if that webpage plays back the href link within the browser. You can use Google's browser to test since it usually automatically detects mp3's.

In the line that you are defining your SoundChannel variable you have to declare it as such:

var mySoundChannelVar:SoundChannel=new SoundChannel();

you can keep the same variable name you have but you have to not only type the variable as a soundchannel but also make sure you define it with the new keyword as an instance.

Also, I would if I were using Booleans define the variable as a Boolean as such:

var myPlaybackBoolean:Boolean;

I also experienced some lag time before the audio started playing when I used my own audio mp3. You have to note that the audio file is data that progressively downloads and in many cases it would be good practice to use a preloader to show that the audio is loading and the user doesn't click away from the page to a different website.

Now, granted I could not upload to my http server and test but given this is not video it should work with the extra parameters I included in the code in this post. Try it and report back. I am off to sleep.

As for using "Flash Video wrapper components", since the .flv is just a container file (it can contain a video file & an audio file, just video, or just audio), you could use it to contain just an audio file, the mp3, and then have the full interactivity available with cue points, popping text up at various points in the audio file, (event type cue point), or navigate to various sections of the file (navigation type cue point).

You have all been so helpful. I am having a terrible time understanding ActionScript, and taking things from tutorials and putting them into practice.

Before I move onto the cue points and highlighting, I need to get this to play on my server. I did a simple test file where the audio is embedded. That seems to work fine when uploaded. What I'm struggling with now is combining the code for the click to play stop, and the embedded audio.

Can you tell me how to change the code that I have so that the audio file is embedded from the library, and plays/stops when clicked? I've basically used what I had above and changed the URL lines to indicate the audio fromt he library but it's not working. Here's what it lookes like:

stage.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound);

var fl_SC:SoundChannel;

//This variable keeps track of whether you want to play or stop the sound