To kill an AIR application launched for testing from Flash CS3 open the task manager and kill the process idl.exe.
When working within the Flash CS3 development environment, lightweight or utility windows spawned from an AIR application are not killed when the primary AIR application window is exited. In fact, they are not even killed when Flash CS3 is closed.
Further, as long as these lightweight/utility windows are open you will not be able to to test your application. There simply will be no result from pressing ctrl+enter. Launching the debugger will only offer the message, "debugger launch failed!" If any part of the AIR application is still running you simply will not be able to test your application. Hence, you must go to the task manager and kill idl.exe!
Thursday, 11 March 2010
Embedding Font in CS3 Components (Avoiding Disappearing Button Labels)
When a CS3 Component (i.e. a Button) appears under a mask the text disappears.
To fix this we simply embed the font in the Component. Unfortunately, this isn't like embedding font in a normal programatically generated TextField instance.
How To Embed Font in CS3 Components
(I will use the Button component for this example.)
1.First, we must embed the font in the swf. There are 2 ways to do this:
◦If you wish, you may simply create a TextField off stage and embed the font in that TextField.
◦Or if you have taste, you will open the library and select “new Font” from the library panel menu. Now, create a font symbol in the library. I chose Arial and set the linkage identifier for the font symbol to “ArialFont” exporting it for ActionScript.
2.With the font embedded in the swf, we now need to embed it in our component.
There is only one way to do this. Assuming that our button is named button_btn your ActionScript will look like this:
// you may replace new ArialFont().fontName with the string “Arial” if you prefer. (If you did not create a Font Symbol you must use the string “Arial”)
var tf:TextFormat = new TextFormat(new ArialFont().fontName);
button_btn.setStyle("embedFonts", true);
button_btn.setStyle("textFormat", tf);
button_btn.label = "fox";
3.That's it. The Font is now embedded in the CS3 Component.
A Note about things that don't work: components do not have a “fontFamily” style. The only way to control the style of text in components is to create an instance of TextFormat and set the Button's “textFormat” style to that instance of TextFormat. Also, you cannot set a style directly on the TextField object in the button component. (The CS3 Button Component's TextField can be retrieved through it's textField property.) Setting the style directly on the textField causes a runtime error. Also, setting the textField's defaultTextFormat object does not have an effect, as it is overwritten by the components default styles. Finally setting the textField.embedFonts property to true does not have any effect.
To fix this we simply embed the font in the Component. Unfortunately, this isn't like embedding font in a normal programatically generated TextField instance.
How To Embed Font in CS3 Components
(I will use the Button component for this example.)
1.First, we must embed the font in the swf. There are 2 ways to do this:
◦If you wish, you may simply create a TextField off stage and embed the font in that TextField.
◦Or if you have taste, you will open the library and select “new Font” from the library panel menu. Now, create a font symbol in the library. I chose Arial and set the linkage identifier for the font symbol to “ArialFont” exporting it for ActionScript.
2.With the font embedded in the swf, we now need to embed it in our component.
There is only one way to do this. Assuming that our button is named button_btn your ActionScript will look like this:
// you may replace new ArialFont().fontName with the string “Arial” if you prefer. (If you did not create a Font Symbol you must use the string “Arial”)
var tf:TextFormat = new TextFormat(new ArialFont().fontName);
button_btn.setStyle("embedFonts", true);
button_btn.setStyle("textFormat", tf);
button_btn.label = "fox";
3.That's it. The Font is now embedded in the CS3 Component.
A Note about things that don't work: components do not have a “fontFamily” style. The only way to control the style of text in components is to create an instance of TextFormat and set the Button's “textFormat” style to that instance of TextFormat. Also, you cannot set a style directly on the TextField object in the button component. (The CS3 Button Component's TextField can be retrieved through it's textField property.) Setting the style directly on the textField causes a runtime error. Also, setting the textField's defaultTextFormat object does not have an effect, as it is overwritten by the components default styles. Finally setting the textField.embedFonts property to true does not have any effect.
ReferenceError: Error #1056: Caused by Declaring Stage Instances Private
If you declare a stage instance private you get the message: "ReferenceError #1056 Cannot create property my_mc on StageIntanceDeclarationsClass"
This error occurs when you uncheck the "Declare Stage Instances Automatically" checkbox in the "ActionScript 3.0 Settings" dialogbox and proceed to declare stage instances as private variables in the class associated with the containing MovieClip.
A Note on Inheritances and Declaring Stage Instances:
You cannot choose to simply always declare stage instances automatically without forging the use of inheritance in classes linked to MovieClip Symbols. If you have a class APrime which is derived from class A and APrime is linked to a MovieClip Symbol, all stage instances used in the base class A must be manually declared in class A. "Declare Stage Instances Automatically" only declares instances in the class linked to the MovieClip Symbol and does NOT make those references available to any base classes.
Example:
Assume that the class StageIntanceDeclarations is set as the class associated with a MovieClip which c0ntains the MovieClip my_mc. Then the following code will cause ReferenceError #1056 at runtime.
package{
import flash.display.MovieClip;
public class StageIntanceDeclarations extends MovieClip
{
//Private Causes ReferenceError #1056
private var my_mc:MovieClip;
function StageIntanceDeclarations()
{
}
}
}
The output is as follows:
ReferenceError: Error #1056: Cannot create property my_mc on StageIntanceDeclarations.
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
at TestStageIntanceDeclarationsBase$iinit()
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
To avoid this error simply declare my_mc as public:
public var my_mc:MovieClip;
This error occurs when you uncheck the "Declare Stage Instances Automatically" checkbox in the "ActionScript 3.0 Settings" dialogbox and proceed to declare stage instances as private variables in the class associated with the containing MovieClip.
A Note on Inheritances and Declaring Stage Instances:
You cannot choose to simply always declare stage instances automatically without forging the use of inheritance in classes linked to MovieClip Symbols. If you have a class APrime which is derived from class A and APrime is linked to a MovieClip Symbol, all stage instances used in the base class A must be manually declared in class A. "Declare Stage Instances Automatically" only declares instances in the class linked to the MovieClip Symbol and does NOT make those references available to any base classes.
Example:
Assume that the class StageIntanceDeclarations is set as the class associated with a MovieClip which c0ntains the MovieClip my_mc. Then the following code will cause ReferenceError #1056 at runtime.
package{
import flash.display.MovieClip;
public class StageIntanceDeclarations extends MovieClip
{
//Private Causes ReferenceError #1056
private var my_mc:MovieClip;
function StageIntanceDeclarations()
{
}
}
}
The output is as follows:
ReferenceError: Error #1056: Cannot create property my_mc on StageIntanceDeclarations.
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
at TestStageIntanceDeclarationsBase$iinit()
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
To avoid this error simply declare my_mc as public:
public var my_mc:MovieClip;
Sound and NetStream bytesTotal is zero until the entire file is loaded in IE
The bytesTotal property only returns the total number of bytes after the sound or video file has completely loaded in both IE and Safari. However, in Firefox bytesTotal will return the total number of bytes in a sound or video file as soon as the file begins to load.
Further the loadProgress, ProgressEvent.PROGRESS, event of the sound object does not fire as it should in Internet Explorer and Safari. Adobe makes no mention of this in their documentation! To show load progress in browsers other than Firefox the bytesTotal/getBytesTotal properties cannot always be used. You may need to have the total bytes loaded from XML or elsewhere.
Further the loadProgress, ProgressEvent.PROGRESS, event of the sound object does not fire as it should in Internet Explorer and Safari. Adobe makes no mention of this in their documentation! To show load progress in browsers other than Firefox the bytesTotal/getBytesTotal properties cannot always be used. You may need to have the total bytes loaded from XML or elsewhere.
Magna Cum Laude Complete!
Today, final grades posted assuring that I will graduate Magna Cum Laude with a Bachelors of Science in Computer Science.
(Suma Cum Laude is not offered by Western Washington University, making Magna Cum Laude the highest academic honor awarded.)
Its has been 3 years since I graduated from junior college with a Presidents Medal across degrees in digital media communications and an associate of arts. During the years at WWU, I spent my time delving into advanced physics, mathematics, and computer science exploring the underlying academics on which our interactive arts are founded.
(Suma Cum Laude is not offered by Western Washington University, making Magna Cum Laude the highest academic honor awarded.)
Its has been 3 years since I graduated from junior college with a Presidents Medal across degrees in digital media communications and an associate of arts. During the years at WWU, I spent my time delving into advanced physics, mathematics, and computer science exploring the underlying academics on which our interactive arts are founded.
flash.media.Microphone.rate What are the acceptable bit rates (bitrates)?
Adobe appears to have forgotten to publish the acceptable values for the flash.media.Microphone.rate property in the ActionScript 3.0 edition of their documentation.
The Adobe documentation on the rate (bitrate) property is limited to the following,
“The rate at which the microphone is capturing sound, in kHz. The default value is 8 kHz if your sound capture device supports this value. Otherwise, the default value is the next available capture level above 8 kHz that your sound capture device supports, usually 11 kHz. “
But, what If you want a rate (bitrate) other than 8 or 11 kHz ? If you are looking for the acceptable bit rates look no further. I dug this out of a tech note.
Sampling rate
Approximate data rate
5
5.512 kHz
1378 bytes/sec, or 11.025 K bits/sec
8
8.000 kHz
2,000 bytes/sec, or 16 K bits/sec
11
11.025 kHz
2756 bytes/sec, or 22.05 K bits/sec
22
22.050 kHz
5,513 bytes/sec, or 44.1 K bits/sec
44
44.100 kHz
11,025 bytes/sec, or 88.2 K bits/sec
The Adobe documentation on the rate (bitrate) property is limited to the following,
“The rate at which the microphone is capturing sound, in kHz. The default value is 8 kHz if your sound capture device supports this value. Otherwise, the default value is the next available capture level above 8 kHz that your sound capture device supports, usually 11 kHz. “
But, what If you want a rate (bitrate) other than 8 or 11 kHz ? If you are looking for the acceptable bit rates look no further. I dug this out of a tech note.
Sampling rate
Approximate data rate
5
5.512 kHz
1378 bytes/sec, or 11.025 K bits/sec
8
8.000 kHz
2,000 bytes/sec, or 16 K bits/sec
11
11.025 kHz
2756 bytes/sec, or 22.05 K bits/sec
22
22.050 kHz
5,513 bytes/sec, or 44.1 K bits/sec
44
44.100 kHz
11,025 bytes/sec, or 88.2 K bits/sec
Maximum AS3 (FileReference) file upload size 100MB or more?
From the adobe docs we can can not be sure that flash supports file uploads larger than 100MB. In my testing I have found no limit. I would be very interested in hearing about the client os/flash version, and server used by anyone who has found a file so large that it would not upload.
Here is what Adobe docs say:
"Although Flash Player has no restriction on the size of files you can upload or download, the player officially supports uploads or downloads of up to 100 MB. You must call the FileReference.browse() or FileReferenceList.browse() method before you call this method. "
However, in another area on the same page adobe points out the following:
"Note: In the initial version of ActionScript 3.0, the [file] size property was defined as a uint object, which supported files with sizes up to about 4 GB. It is now implimented as a Number object to support larger files. "
So it appears that Adobe also believes uploads larger than 4GB are possible but will not stand behind it.
Both quotes are from this page: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/FileReference.html
Here is what Adobe docs say:
"Although Flash Player has no restriction on the size of files you can upload or download, the player officially supports uploads or downloads of up to 100 MB. You must call the FileReference.browse() or FileReferenceList.browse() method before you call this method. "
However, in another area on the same page adobe points out the following:
"Note: In the initial version of ActionScript 3.0, the [file] size property was defined as a uint object, which supported files with sizes up to about 4 GB. It is now implimented as a Number object to support larger files. "
So it appears that Adobe also believes uploads larger than 4GB are possible but will not stand behind it.
Both quotes are from this page: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/FileReference.html
Subscribe to:
Comments (Atom)