Sunday, September 25, 2011
AS2, FP8 Fullscreen
fullscreenBtn.onRelease = function(){
if(Stage["displayState"] == "normal"){
Stage["displayState"] = "fullScreen";
}else{
Stage["displayState"] = "normal";
}
}
Thursday, September 22, 2011
Symbols Dissapear When Scrolling
In Flash Player 8 you cannot scroll a movie clip that contains a dynamic text or input text.
Monday, May 17, 2010
Double Line Breaks in Flash Dynamic Text
This is how i'm setting this up to have it work with the solution i provide: text is written in and submitted through a html textarea with no extra format and stored in a mysql database, with no special treatment, then outputted to flash, with php (used urlencode, which i don't think influences anyway), using LoadVars, without any extra encoding.
To the hour, i have not found out a way to avoid importing text into a flash dynamic text field with the correct line break format and i think there is no way to automatically handle this.
While html textareas work fine with the line break \r\n, treating both \r and \n as one single line break, flash reads the \r\n as two line breaks.
The only solution that appears to exist relies on replacing the line breaking characters, once loaded in flash. You can replace the line breaking characters, \r\n with a single \r or a single \n, or with a html <br> tag (in which case you must format the dynamic text to accept html text - see the example below). You can also replace the characters with the flash constant: newline.
Depending on your OS, you will get different line breaks - for linux or unix they are single \r or \n, as opposed to a windows machine which uses \r\n.
Another matter is that i think the text will always be brought into flash with the line breaks, even if you use the php's nl2br function to automatically replace the line breaks into a html <br> tag, but that's something i did not dwell on more.
Example 1 - Dynamic text field treated as HTML
TextField.html = true;
myRawString = "play rune again\r\nin a couple of years";
dynamicTextField.htmlText = myCorrectString;
Example 2 - Regular dynamic text field with \r or \n
myRawString = "play rune again\r\nin a couple of years";
dynamicTextField.text = myCorrectString;
Example 3 - Regular dynamic text field with flash line breaks
myRawString = "play rune again\r\nin a couple of years";
dynamicTextField.text = myCorrectString;
The dynamic text field has to be set to multiline for this.
To the hour, i have not found out a way to avoid importing text into a flash dynamic text field with the correct line break format and i think there is no way to automatically handle this.
While html textareas work fine with the line break \r\n, treating both \r and \n as one single line break, flash reads the \r\n as two line breaks.
The only solution that appears to exist relies on replacing the line breaking characters, once loaded in flash. You can replace the line breaking characters, \r\n with a single \r or a single \n, or with a html <br> tag (in which case you must format the dynamic text to accept html text - see the example below). You can also replace the characters with the flash constant: newline.
Depending on your OS, you will get different line breaks - for linux or unix they are single \r or \n, as opposed to a windows machine which uses \r\n.
Another matter is that i think the text will always be brought into flash with the line breaks, even if you use the php's nl2br function to automatically replace the line breaks into a html <br> tag, but that's something i did not dwell on more.
Example 1 - Dynamic text field treated as HTML
TextField.html = true;
myRawString = "play rune again\r\nin a couple of years";
//replace \r\n with <br>
myCorrectString = myRawString.split("\r\n").join("<br>");dynamicTextField.htmlText = myCorrectString;
Example 2 - Regular dynamic text field with \r or \n
myRawString = "play rune again\r\nin a couple of years";
//remove the \n. works the same with removing \r
myCorrectString = myRawString.split("\n").join("");dynamicTextField.text = myCorrectString;
Example 3 - Regular dynamic text field with flash line breaks
myRawString = "play rune again\r\nin a couple of years";
//replace the \r\n with the flash newline constant
myCorrectString = myRawString.split("\r\n").join(""+newline+"");dynamicTextField.text = myCorrectString;
The dynamic text field has to be set to multiline for this.
Friday, May 14, 2010
Playing Around With Buttons
First thing: dynamically changing the width of a button symbol, when this guy only has a hit area defined, will un-render the button from the stage. You will have to add content to the Up State of the button to undo this. Solution: add an invisible (alpha) shape to the button's Up State.
Saturday, May 1, 2010
Tip on Disabling Buttons
To disable buttons you can use mcInstanceName.enabled = false;
This property works on both button symbols and movieclip symbols acting as buttons.
If your button only has it's hit frame defined, or your moviclip serving as a button is _alpha = 0; , and you wish to enabled another button, which lies underneath use the _visible property instead;
mcInstanceName._visible = false;
Also, you can hide the default button cursor with mcInstanceName.useHandCursor = false;
This property works on both button symbols and movieclip symbols acting as buttons.
If your button only has it's hit frame defined, or your moviclip serving as a button is _alpha = 0; , and you wish to enabled another button, which lies underneath use the _visible property instead;
mcInstanceName._visible = false;
Also, you can hide the default button cursor with mcInstanceName.useHandCursor = false;
Thursday, April 29, 2010
On Caching As Bitmap
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.
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.
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.
Subscribe to:
Posts (Atom)