Flash CS6 Importing sounds - actionscript-3

I'm working on a Flash project in CS6 and need to import a sound to my library but I'm having endless problems with it. I'm using external files in Actionscript 3.0 (e.g. I cannot do a URLRequest as it won't work externally, need to import)
I'm using a sound that should work, some errors go in that it can't be over 160kbps, this is only at 32 in the MP3 file. I converted it to an AIFF, no success, a WAV? no success.
If it's an MP3 I simply get "Couldn't import "
If it's a AIFF or WAV I get "One or more files were not imported because there was a problem reading them"
Adobe suggest you need to files under 160kbps, all are set at 32kbps to be safe.
Another suggestion said you needed Quicktime 7.7.1 (or newer) and iTunes 10.5.5.3 (or newer) for this to work with an MP3 file. I have Quick 7.7.3 and iTunes 11.0 so I really have no idea of the problem.
Can anyone help, this project needs finished quickly.
Thanks.
John.

Could be to do with bitrates.
I was running into issues with some mp3 files that I had converted from wav using Audacity. It was a specific few that wouldn't work, so I went back to Audacity and compared the working-mp3-yielding wavs to the non-working. I noticed that the working wavs had a bitrate of 44100Hz the non-working had 48000Hz. Setting the project rate ( bottom left corner ) to 44100Hz before exporting yielded mp3s that imported into flash with no problem.
In short:
48000 Hz = naughty
44100 Hz = nice

This is a weird problem here's a simple code snippet that load and play an MP3 sound AS3 doesn't support WAV natively :
//sound object
var sound:Sound = new Sound(new URLRequest("music.mp3"))
var soundChannel:SoundChannel = sound.play();
Hope this help :)

This post is kind of old but I thought I would post an answer after running into the same problem. I am also using Flash Pro in CS6. What you want to do is to embed the sound into your FLA so that when your SWF is compiled the sound will go with it. Khaled's answer is great but this issue needs a little more TLC.
What worked for me was to get an application that edits sound clips. I downloaded the open source 'Audacity.' In the bottom left corner of Audacity you can edit the project rate. Take it down to about 1600 or lower. Then save the project and export the sound as an mp3.
Finally, make sure that your sound clip is in the same folder as your FLA. Import into your FLA (this should work now) and export your sound for actionscript by right clicking the sound in the library, going to properties. Change the name of the class to whatever you want (at least get rid of the '.mp3' from the class name).
Then use the following code (which is different from the typical URL loader for sounds):
//sound is a constructor variable under your document class
public class DocumentClass extends MovieClip
{
var yourSound:yourSoundClass;
public function DocumentClass()
{
init();
}
function init():void
{
yourSound = new yourSoundClass();
}
}
Then play your sound by using yourSound.play(); This technique will embed your sound within the SWF so it will go wherever the SWF goes. I hope that helps anyone who runs into this.

Related

How can I prevent MovieClips existing throughout multiple frames? (Flash, AS3)

Heyya, Community!
So, I've been programming in Flash ActionScript 3.0 for a few years, gradually relearning everything. However, I can't figure this out for the life of me -- I've been forced to use inefficient work-arounds since now. And I just needed to know, how can I stop MovieClips added via The Stage consisting through frames?
Code;
Frame 1;
import flash.display.MovieClip;
var block_mc:MovieClip = new Block();
addChild(block_mc);
block_mc.x = 100;
block_mc.y = 100;
And then, on Frame 2...
stop();
How can I stop this issue from happening? If you want a more specific example, you can download the supplied .fla file.
Is there an efficient work-around other than creating for() loops to delete my greater-than 100 MovieClips? Is there no work-around? Please help!
Please note, to open the file you need a version of Adobe Flash Professional; I recommend using Adobe Flash Professional CC if you have it, since I used it.
If you need any more details, just ask! <3
Link to FLA: http://www.mediafire.com/download/tczfyj3jg3sofsj/Problem.fla

Controlling Sound / Volume

I added a sound to the Flash Professional CC library and had the program convert it to MP3. If I create a layer and drag-and-drop the sound onto the stage the sound plays fine (even after passing it through Swiffy), however that is all I am able to do so far.
I need some way to control when the sound plays as well as volume. I tried the giving the sound a class (Sound Properties -> ActionScript -> Export for ActionScript and assigned a class name mySound).
Then added this ActionScript to the first frame:
var myAudio:Sound = new mySound();
myAudio.play();
However, after passing it through Swiffy, I get the following errors:
The ActionScript class flash.media.Sound is not supported.
The ActionScript method flash.media.Sound.play() is not supported.
So I can't use the base Sound class in Flash? Is there another base class that can be used and is it compatible with the flash.media.Sound class? Is there some other way to control playback so that it can be played at a specific time -- such as on mouse roll-over or when something is clicked?
You could try using SoundJS. BTW, Flash Pro CC does have an HTML Canvas document type that uses CreateJS (which SoundJS is part of) under the hood. It won't convert AS3 to JS, though, you have to write the JS code yourself.

FLVPlayback VideoEvent.COMPLETE triggers before the video reaches the end, and the video stops playing

import fl.video.*;
var player:FLVPlayback = new FLVPlayback();
addChild(player);
player.skin = "someSkin.swf";
player.source = "http://someDomian/some.flv";
Here's the code. I just load and play some flv from server, and when I test it via Flash (just press ctrl+enter), the video will stop at about 90% of the video and dispatch the COMPLETE event. Any one knows why? Try it again, the time where the video stops is the same, just about 90%.
I searched it, and I tried to change playheadUpdateInterval of player, set totalTime explictly, or set bufferTime longer. All those solutions make no difference.
I tried to load another movie from the same server, same problem. Any chances something wrong with the server?
EDIT:
I sent the swf to someone else, and the video plays as it's supposed to do. Then another guy, and the same result. So, I guess there's something wrong with my settings? Is there some setting will cause this strange action? But when I tried it on my laptop, the video stops unexpectedly. Why this seems to work on everyone's computer except mine?
before CLOSE:
Eventually my colleagues found the strange reason causes this problem, if changing the publish setting to FP10 & 10.1 or FP9, it'll work as we expect. FP10.2 and up, videos on that server seem not have the talent to find their ending. The videos are H.264/AAC, if I convert them to VP60/MP3, all the FP versions will work. Since I can't modify the setting about the codecs, I'll just change the publish setting and leave the codecs thing alone. Although I'm just frustrated by this, if you see this and so lucky that you happen to know the codecs thing why the "early complete" appears, please please tell me.
The problem could be with the .FLV file, sometimes there could be problems while encoding any video file(AVI,MOV,MP4,3GP,WMV) in to .FLV format that results in skipped frames. Try your code with some other .FLV file if that works good then you need to re-encode your FLV file.
You can also try capturing the video Complete Event by tracking the Video Playback Progress.
import fl.video.*;
var player:FLVPlayback = new FLVPlayback();
addChild(player);
player.skin = "someSkin.swf";
player.source = "http://someDomian/some.flv";
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
function enterFrameHandler(event:Event):void {
if(player.playheadPercentage>=99)
{
//On Video Playback Complete Actions here
}
}

Embedded Sounds cut off early

I have a combined Flash Builder/Flash Pro project. Because of the hassles involving in maintaining sound assets on the timeline, my sounds are all embedded into Class files, like:
[Embed (source="/mp3/Welcome_01_V.mp3", mimeType="audio/mpeg")]
private static const WELCOME_1:Class;
These files are then referenced by the base Classes for the symbols that need them, embedded for Actionscript on Frame 10 (because the second frame label is on Frame 10 to give space for you to read the first one).
What I'm finding is that a few of these Sounds don't play all the way through, but the SoundChannel dispatches the "soundComplete" event, and its final position matches the Sound's length.
All sounds are converted from wav to mp3 at 44Hz / 16 kbps. I faked out the compiler to avoid a reference to Flex by including a dummy SoundAsset that extends Sound.
I don't know what other steps to take to debug this. Is there a way to figure out whether the problem is on the compile side or on the run side?
Updated
More things I have tried:
Looked at the Size report: The nonworking sounds were smaller in
their embedded form than the source mp3
Got rid of my own BitmapAsset and let Flash link in the Flex Framework and do whatever that does (definitely worse)
Dropped the encoding from 44 kHz to 22 kHz (no improvement or worse)
Dropped the bit rate to 8kbps (the lowest dbPowerAmp, the tool I use, supports). This usually helps somewhat, but I still usually use a word or two from the end of the file
Dropped both parameters in the encoding. This helped a few that just dropping the bit rate didn't, but not all files. Plus it sounds tinny.
Thanks!
For Flash audio, I recommend importing the sound assets into a FLA using wav files if you have the high quality source wavs. Otherwise, you can consider converting your mp3 into a wav as well. Then set the FLA export settings to the quality you want and Flash will convert your wavs into its own format at the quality you set with hopefully less issues.
Once you do that, you can export the sound symbol for actionscript in your library and set a class name just like how you would embed it.
One other trick I use is I have one FLA just for sound assets which can be used to store as big waves as I want. And when I export that, it becomes a small SWF file which I can then embed in my main application. That way, I never have Flash reconvert the wavs to the swf every single time I export the swf. Instead it just copies the swf data which is much faster as well.
[Embed(source="Audio/Sfx.swf", symbol="WELCOME_1_WAV")]
private static const WELCOME_1:Class;
If you are having audio cut off issues in Flash Pro, you may want to check your frame rate.
I had an issue with sounds cutting off (in Flash pro CC 2014). My issue turned out to be related to the frame rate being set to 25 rather than the default 24. I have been using 25 to resolve an issue unrelated to anything in this project, so my solution was to change the FPS to 24, which invoked the necessity to move all of the synchronized animations to re-align with the corresponding audio.
Why long(ish) audio tracks get cut off at the end when the frame rate is at 25 regardless of using proper keyframing is a mystery. This solved the symptoms however, so if you are having audio cut off issues in Flash Pro, you may want to check your frame rate.
My symptoms were specifically when an audio clip was particularly long, and deep into the time line.
What worked for me: I opened the audio files in an audio editor and added a few seconds of silence to the end.
Good luck! - J.Hall

Issue loading AS2 .swf that uses XML into AS3 .fla

I'm making a website for a client where they purchased a flash template that was written in "AS 1.0 & AS 2.0" and then asked me to add a googlemap to the contact us page. However, the googlemap API only works in AS3. My options were to translate the entire website to AS3 OR to make an AS3 file that imported the AS2 website and then added the googlemap bit.
I decided to go with option 2 since it seemed easier...
Anyway, I'm using the Loader class in the AS3 file.
var myLoader:Loader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("main_v8.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
addChild(myLoader);
The problem is the AS2 swf file uses XML to load the background images. It works on its own but when loaded into the AS3 file the background images do not appear. All the buttons and external links work, its just the loading of the XML.
I've been looking all over for help on this and while there are lots of people with issues playing AS2 swf in AS3 I couldn't find anything to help with this.
Any advise or solutions would be appreciated!
Thanks!
Havent face such a problem but, if you find out the problem you ca solve it. You can check some conditions:
check network for , does xml loaded. (might be crossdomain problem)
check if images loaded. ( as3 security problem)
check as2 file really inits. ( you can use as3 bridge to as2)