Archive for ‘ActionScript 3.0’

June 4th, 2010

Tips for code hints in Flash CS5

by Jen deHaan

There are a number of forum posts about code hinting not showing up as expected in Flash CS5 documents. There are a number of possibilities about why code hints do not show up, but the following post will collect some troubleshooting tips that may help you out.

May 5th, 2010

Buttons in Flash using ActionScript 3.0: Going to next frame and previous frame

by Jen deHaan

Some people have been asking how to create button code in Flash (CS3, CS4, or CS5) that progresses the playhead in a SWF to the next or previous frame using ActionScript 3.0. This is not too difficult, and is a super simple code modification from any other button in AS3 (and is actually a touch easier than AS2 due to scoping issues).

This post includes an example of how to create two buttons that click between a few different frames. I’ll also include a (CS4) FLA file for you to look at and the AS2 equivalent.

May 5th, 2010

Getting started with the TLFTextField class in ActionScript 3.0 and Flash CS5

by Peter deHaan (ActionScriptExamples.com)

The following examples show how you can get started with the TLFTextField class in ActionScript in Adobe Flash Professional CS5.

July 24th, 2009

Controlling the window target a button click opens using ActionScript 3.0 in Flash

by Jen deHaan

One of my frequently asked questions in the comments is how to control what window a button click opens using ActionScript 3.0. For example, you might want your button to open in the same window, a particular part of your frames layout, or a new window. It’s similar to ActionScript 2.0, but there is a bit of a difference.

In ActionScript 2.0, you set a target for your button using code such as the following:

The following steps for ActionScript 3.0 will apply to either Flash CS3 or Flash CS4, just make sure that your document is an ActionScript 3.0 button and you’re adding the code to a frame.

  1. Create your button in your FLA, and give it an instance name in the Property inspector, such as my_btn.
  2. Select a frame on the timeline at the same frame number of your button.
  3. Open the Actions panel, and add the following code:
    my_btn.addEventListener(MouseEvent.MOUSE_DOWN, myHandler);
    function myHandler(event:MouseEvent):void {
        navigateToURL(new URLRequest("http://www.adobe.com/devnet/flash/"), "_self");
    }
  4. Publish preview your work in HTML (File > Publish Preview > HTML). Note: When testing locally, you will need to set your security to allow access to the SWF. If you haven’t set this up, click Settings in the dialog that opens when you first test your FLA, select a directory on your hard drive, and save the FLA to that same directory and test again.
  5. By default, without adding this parameter, ActionScript assumes _blank which opens a new window. You can modify the _self in the code above to be _top or _parent (or _blank if you want). Here’s what each of them does:

    • _self opens the link in the current frame of the current browser window.
    • _blank opens the link in a new window (or tab if that’s what the user has their browser set to do).
    • _parent opens the link in the parent of the current frame.
    • _top opens the link in the top-level frame of the current browser window.

December 10th, 2008

Flash CS4 example: Spray Brush, Tween instance, new motion, AS3, fancy JSFL… Profit!

by Jen deHaan

In the previous blog entry, I linked to a new JSFL that automatically gives instance names to selected instances in a smart way. You can go read about and download the JSFL from this page. This entry shows you how to use this command along with some of the new features in Flash CS4.

November 21st, 2008

Want to layout your text better? You can download the beta Text Layout Framework / component (use with Flash CS4 now)

by Jen deHaan

Today the Text Layout Framework went live for Flash Player 10. This will help you layout your text in new and much better ways in your applications. You may have seen some demos at MAX (like the Herald Tribune demo) where the text flow, direction, etc was handled way better – now the functionality is on LABS. Check it out here:

http://labs.adobe.com/technologies/textlayout/

Note that you can download FLA examples from the presentation at the top of the page, to help you understand how to use the component.

To quote the page,

“The Text Layout Framework is an extensible library, built on the new text engine in Adobe® Flash® Player 10, which delivers advanced, easy-to-integrate typographic and text layout features for rich, sophisticated and innovative typography on the web. The framework is designed to be used with Adobe Flash CS4 Professional or Adobe Flex®, and is already included in the next version of Flex, code named Gumbo. Developers can use or extend existing components, or use the framework to create their own text components.”

You can download and install the component in Flash CS4, try it out for yourself.

http://labs.adobe.com/downloads/textlayout.html

October 19th, 2008

Movie clip buttons in a fight: it’s AS2 vs. AS3 (again)

by Jen deHaan

You might have created movie clip buttons in Flash CS3 or Flash CS4 (or Flash 8 or 7 or…) before to get those animations on your buttons. Either way, creating one would have proceeded a bit like the following if you used ActionScript 2.0.

* Create a button, and give it an instance name (in the following case, myMc).
* Along the Timeline, add frame labels _up, _over, _down, and _hit (if you want a hit area for the button).
* Put stop actions at each frame label, and change the graphics and/or add some animation at each state.
* Add this code to frame 1 in the actions panel:

myMC.onRelease = function() {
 trace ("You clicked me.");
}

(For full instructions on creating a movie clip button, you can refer to something I wrote for docs waaay back in Flash 8 days here updated for CS3).

More after the jump.

October 12th, 2008

New motion and Tween instances: Flash CS4 presentation (FlashCamp)

by Jen deHaan

Yesterday at FlashCamp, I gave a presentation on using the new motion model in Flash CS4. The files are linked on this post. This is a general synopsis of what I covered, and I’ll detail how I did a few things in the presentation. Please comment with any questions you have.

More after the jump.

October 11th, 2008

Flash CS4 files for motion tween presentation at FlashCamp

by Jen deHaan

Here are the FLA and SWF files (Flash CS4 and Player 10) for today’s presentation at FlashCamp on new motion in Flash and using Tween instance (contains that ActionScript).

FlashCamp files for motion tween presentation

The next post will be a bit more about these files and the stuff used in them.

UPDATE: Here it is! For a bunch of information about the presentation and the files in that ZIP above, read this.

Enjoy!

September 4th, 2008

(Flash CS3) Masking using ‘donut’ shapes within movie clips or with AS3 – it’s possible, and not too bad either

by Jen deHaan

You may have tried creating a shape that has a hole in it for a mask in Flash, and it may not have worked. Or maybe it did work and sometimes it didn’t, and you grew some extra gray hairs and threw your laptop at a wall. Or maybe you’re thinking “what the hell is she talking about now?”. I’ll start from (almost) the beginning [if you're not sure about making masks in Flash, read this super old tech support article.. it hasn't changed].

More after the jump.