TextArea Masking

You can mask the TextArea component if you set the Cache as Bitmap option. Select the TextArea on the stage and find the option labeled as: use runtime bitmap caching, in the Property Inspector.

Selecting this option allows the TextArea to be masked. However it doesn’t seem to allow you to set the alpha. Still looking for an answer to that…

TextArea and Embbeded Fonts

The subject of embedding fonts in the TextArea Component came up yesterday. I didn’t know the answer. But, after some research I found the following works with regular text.

Create a TextArea on the stage. Add some text to the text property in the Component Inspector.

Give the TextArea the Instance name: a_txt.

Create a new Font in the Library, by clicking the little button in the upper right of the library. Choose New Font. Choose the Font and size. Click OK. Find the find in the Library, right click, choose: Linkage. In the Linkage box select Export for ActionScript. Note the Class name. In my example it was Font1.

Add the following on a frame or in class that can access the text Area.

var font:Font = new Font1() as Font;
var tf:TextFormat = new TextFormat();
tf.font = font.fontName;

a_txt.textField.embedFonts = true;
a_txt.setStyle( “textFormat”, tf );

SimpleScrollText

Here’s a class that creates a Scrollbar and TextField, that requires no AS at all. The example inlcudes all of the Classes in a package. The classes include, SimpleScrollBar, SimpleScrollText and ScrollBarEvent.

These classes look for MovieClips with the names up_mc, down_mc, drag_mc, track_mc and scroll_txt. You can leave up_mc and down_mc if you do not want these buttons. Or use only the buttons and leave out drag_mc and track_mc.

Assign the SimpleScrollText or SimpleScrollBar class to the Base Class of the MovieClip that contains the Scrollbar elements.

simplescrolltext

Printing an SWF

A question about Joshua Davis and his techniques came up in my online Class. I thought I post to the answer here as others might be interested in how to print the stage in an SWF.

Joshua Davis is pretty inspiring. I like the idea of creating art with Flash via an automated system. He uses a script that creates art automatically by crating movieclips on the stage dynamically. THen he prints these our.

This is not so hard to and doesn’t require any special software other than flash. You can also import the work into Illustrator and work with it there.

Note that randomly generated art may or may not be art. The color choices and other elements may need to be adjusted and added or removed to make a really artful design. That said the process can add interesting elements to your work.

Try it for yourself. Follow these steps.

1) create a Flash movie with some art on the stage. You could just place elements on the stage for now. As you learn AS you can write a script that generates things on the stage.

2) Launch the SWF.

3) Right Click the stage and choose Print…
In the print dialog box print to PDF. This option may show up in different places on different systems.

But the secret is that the PDF can be imported into Illustrated. Printing to the PDF format creates a record of the current content on the stage as vectors in the PDF document.

Note that Illustrator will change a few things or not interpret them correctly. Stroke weight for example, is scaled in Flash but not scaled in Illustrator.

Testing navigateToURL locally

I noticed that navigateToURL (this replaces getURL in AS2) doesn’t seem to work locally, if you want to open a link in the same window (_self). I found this note on the Adobe site. It seems that you need to set “allowScriptAccess” to “always” in the HTML parameters. This needs to be set in both the param tags as below: <param name=”allowScriptAccess” value=”always” /> and in the embed tag: <embed allowScriptAccess=”always” />

SimpleScrollBar class AS3

Here’s an AS3 class that creates a simple scroll bar. Set this as the Base Class for any movie clip. The container clip must have two movie clips named drag_mc and track_mc. These clips act as the dragger and track for the scroll bar

Add an event listener to call a handler when the scroll bar is dragged. SimpleScrollBar dispatches the ScrollBarEvent.UPDATE which includes the property scroll_value. This property holds a value from 0 to 1 representing the position of the dragger.

Here’s some example code. Assume that scroll_mc is a movie clip that contains two clips drag_mc and track_mc. This clip has SimpleScrollBar set as it’s base class.

scroll_mc.addEventListener( ScrollBarEvent.UPDATE, on_update );
function on_update( e:ScrollBarEvent ):void {
	var n:Number = e.scroll_value; // Get the value of scroll bar
	scroll_txt.scrollV = Math.round( ( scroll_txt.maxScrollV - 1 ) * n ) + 1;
}

Download the sample: simplescrollbar-class