Basically, use cacheAsBitmap (both set with AS2 or set in the Flash Environment Setting) when you want to animate a complex vector inside a MovieClip, but only on the X and Y axis. Scale and rotate is a no-no - it will undo the caching.
More so, shapes that use bitmap fills, and text are both considered complex vectors, so use cacheAsBitmap there as well.
Bitmaps created via AS do not take advantage of being cached as a bitmap.
From Kirupa's forum.
Thursday, April 29, 2010
Wednesday, April 14, 2010
Attaching & Playing Mp3 Files as Soundtracks
More dedicated to playing music loops as soundtracks.
1. Edit the MP3 file, and clear out the beginning and end empty spaces; try to achieve a good loop by doing this and testing out in the editing program.
2. Save the mp3 as a WAV.
3. Import the WAV into flash, and edit it's properties; set it's compression to MP3 - this will convert your WAV to an MP3. MP3 files automatically add the empty spaces when compressed into the MP3 format. Importing as a WAV without the spaces, and setting it's compression to MP3 will avoid the spaces.
4. Add an Linkage Identifier to the WAV file (in the following example code: "soundtrackFile") and don't export it on the first frame.
5. After the first frame (which i assume you are going to use to add a preloader, paste the sound on a frame and add a stop to the frame. Sometimes, for unknown reason to me, the sound still plays when the event isn't set to stop. Even when the frame is skipped.
This will give you a good control over the soundtrack.
//SOUNDTRACK CODE
var soundtrack:Sound = new Sound();//create the sound object
soundtrack.attachSound("soundtrackFile");
soundtrack.start(0,99);
soundtrackPlaying = true;
soundtrack.onSoundComplete = function() {
soundtrackPlaying = false;
}
When attaching an MP3 in an SWF that is afterwards loaded into another SWF, add this when creating the sound object:
//SOUNDTRACK CODE
var soundtrack:Sound = new Sound(this);
UPDATE: In Flash CS4 and CS5, you'll need to add an event to the frame, instead of the stop action.
1. Edit the MP3 file, and clear out the beginning and end empty spaces; try to achieve a good loop by doing this and testing out in the editing program.
2. Save the mp3 as a WAV.
3. Import the WAV into flash, and edit it's properties; set it's compression to MP3 - this will convert your WAV to an MP3. MP3 files automatically add the empty spaces when compressed into the MP3 format. Importing as a WAV without the spaces, and setting it's compression to MP3 will avoid the spaces.
4. Add an Linkage Identifier to the WAV file (in the following example code: "soundtrackFile") and don't export it on the first frame.
5. After the first frame (which i assume you are going to use to add a preloader, paste the sound on a frame and add a stop to the frame. Sometimes, for unknown reason to me, the sound still plays when the event isn't set to stop. Even when the frame is skipped.
This will give you a good control over the soundtrack.
//SOUNDTRACK CODE
var soundtrack:Sound = new Sound();//create the sound object
soundtrack.attachSound("soundtrackFile");
soundtrack.start(0,99);
soundtrackPlaying = true;
soundtrack.onSoundComplete = function() {
soundtrackPlaying = false;
}
When attaching an MP3 in an SWF that is afterwards loaded into another SWF, add this when creating the sound object:
//SOUNDTRACK CODE
var soundtrack:Sound = new Sound(this);
UPDATE: In Flash CS4 and CS5, you'll need to add an event to the frame, instead of the stop action.
Sunday, April 4, 2010
_global VS. _root
Generally, the use of _global is recommended.
_root
When you load a MovieClip into the root of your movie, all previous _root variables are lost;
_root variables can be called and set by using the _root. prefix;
_global
Aren't lost when you load a new MovieClip;
Applies to all movies within the player;
Can be called from anywhere by either using or not using the _global. prefix;
Local variables (local means on the timeline you are working on) with the same name as a global variable, have priority.
_root
When you load a MovieClip into the root of your movie, all previous _root variables are lost;
_root variables can be called and set by using the _root. prefix;
_global
Aren't lost when you load a new MovieClip;
Applies to all movies within the player;
Can be called from anywhere by either using or not using the _global. prefix;
Local variables (local means on the timeline you are working on) with the same name as a global variable, have priority.
Subscribe to:
Posts (Atom)