Archive for the 'ActionScript 3.0' Category

Building Click-and-Rotate Content in Flash

Tuesday, June 24th, 2008
Flash ActionScript 2.0 ActionScript 3.0

In one implementation of the QuickTime VR format, known as QTVR Object Movies, the user can click-and-drag an image to seemingly rotate it, as if spinning the real-life object on a lazy Susan.  This simulated 3D interactivity can improve multimedia curb appeal, and makes for a nifty way to showcase merchandise.  But it doesn’t stop there:  the same basic principle can also bring click-and-drag responsiveness to short video sequences and even user input widgets, such as the click-and-scrub input fields of numerous Adobe dialog boxes.  Keep reading »

New O’Reilly Title, Coming Soon!

Wednesday, March 12th, 2008
Flash ActionScript 2.0 General ActionScript 3.0

I just finished the last of my eleven chapters for a new O’Reilly title, ActionScript 3.0:  The Quick Answer Guide for Flash Professionals, last Wednesday.  This was shortly after lunch, 12:30 on the dot, and a neat thing happened almost as I lifted my hands from the keyboard (more on that in a sec).  The rest of the book is still being written, and it’s shaping up nicely.  I’m pretty excited about this project already!  :)   The aim of this reference is to help developers, even keyframe coders, get up to speed with AS3, so keep your eyes peeled in June!

I took a wild tumble off the grid while I was researching and writing for the past five or six weeks, so I apologize for my late replies to blog comments and email.  I’ve been catching up on my inbox since last Wednesday and plan to reply to everyone as soon as I can.  Thanks, so much, to my friends for all the encouragement!  (Go, FlashGods.org!)

I’ll be going over author reviews in the coming weeks, but the heavy lifting is behind me.  The neat thing that happened, on day I finished, is this:  I went downstairs to gaze out the window for a few moments, and right as I did, UPS brought a package to the door.  I opened the box, and inside was a huge tin of Turkish coffee (over a pound!), imported from Turkey, sent by reader Çağatay.  What a way to commemorate the milestone!  Thanks, Çağatay!  This coffee is a real treat!

How to use Font Symbols (Embedded Fonts) with ActionScript

Thursday, February 28th, 2008
ActionScript 2.0 ActionScript 3.0

You certainly don’t need ActionScript to make use of embedded fonts.  You can always just embed font outlines manually by selecting a text field, then using the Embed button in the Property inspector.  Select your range of characters, type in your text, then publish; you’re good to go (and you only need to do it with dynamic and input text fields:  static text fields embed font outlines automatically).  In fact, if your text field has an instance name — something you can also set in the Property inspector — then you can determine its text content with ActionScript and the embedded font outlines still hold.  But if you’re using ActionScript to create text fields on the fly, the mechanics are a bit different.  Let’s take a look.  Keep reading »

Progressive Enhancement with Flash

Monday, February 4th, 2008
Flash ActionScript 2.0 ActionScript 3.0

One of the main tenets of good Web design is the principle of progressive enhancement.  In general, the idea goes like this:  make sure the user can access a web site’s essential content regardless of browser.  It shouldn’t matter whether the user visits your site with Internet Explorer, Firefox, Safari, Netscape, or pick your favorite flavor.  In fact, the site’s content should be accessible even without JavaScript or peripheral plugins like Flash Player.  Once the basics are covered, use CSS to enhance the visual design.  Then, and only then, introduce the whizz-bang stuff — nifty rollovers, AJAX interactivity, Flash — and do it in a way that doesn’t penalize users who don’t have (or choose to disable) the needed machinery.

Sound pretty neat?  I’ve seen a few examples of this online and at conferences, so I delved into this topic myself to see how much fun it might be.  Turns out it can be somewhat challenging, but definitely fun to see the results.  I put together an example in order to explore the basic mechanics of this form of progressive enhancement — a slideshow SWF that takes its cue from the HTML in which it appears — and turned it into a three-part series on CommunityMX.com.  The first part is free and covers how to get the HTML from the Web page itself into the SWF.  The follow-up articles go into how to parse that HTML in AS2 and AS3.  CommunityMX offers free trial memberships, so if you aren’t interested in becoming a subscriber, you can wait until the follow-up that interests you gets posted (not sure yet when that will be), then sign up for the trial membership.  Of course, if you want to subscribe, that would be cool too!

http://www.communitymx.com/content/article.cfm?cid=02395

Moock’s Pitch for AS3 (It’s a Good One!)

Monday, January 21st, 2008
Flash ActionScript 3.0

O’Reilly and Adobe have teamed up on a new website dedicated to Rich Internet Applications (RIA).  Among the first featured articles is a comparative look at ActionScript 3.0 and its predecessors, 2.0 and 1.0, in which Colin Moock offers a number of solid insights (and encouragements) toward learning the new language.

http://www.insideria.com/2008/01/actionscript-30-is-it-hard-or.html

How to Play a Timeline Backwards (with Easing!)

Wednesday, January 2nd, 2008
ActionScript 2.0 ActionScript 3.0

Reader James Colvin wrote me in mid-December to ask if I had any thoughts on playing a timeline backwards.  As it turns out, this question comes up every now and then on the Adobe forums, where longtime regular kglad usually posts his very handy custom function in reply.  In kglad’s version, the MovieClip.nextFrame() and prevFrame() methods are used in cahoots with setInterval() to accomplish the goal.  He often assigns the function to the Object.prototype property of the MovieClip class, which makes the new functionality available to all movie clips (a pre-AS3 technique).

My initial reaction was to search the forums and send back a link, but James’ question had an interesting twist:  could this non-standard timeline movement include easing?  Wow, what a cool challenge!  So I thought about it off and on over the holidays, and a neat solution occurred to me just this morning.  Keep reading »

Flash CS3 (9.0.2) Supports New Video and Audio Codecs; FLVPlayback Works, But …

Thursday, December 13th, 2007
Flash ActionScript 3.0

If you want to be able to deliver non-FLV video in Flash (how cool is that?!), head over to the Adobe Flash Support Center and download the Adobe Flash Player Update for Flash CS3 Professional (9.0.2).  The result?  At runtime, you’ll be able to load MOV and MP4 files encoded in the H.264 hi-def codec.  This is in addition to the usual FLV, and we’re talking Flash Player 9 only (specifically, version 9.0.115.0 or higher).  You’ll also be able to load M4A audio instead of only MP3.  The upgrade to the IDE allows you to view such content as you test and debug SWFs right in the authoring environment.  I’ve already installed and tested, and the update works … but I have seen one stumbling block.  You can work around it — in fact, you can work right through it — but it isn’t especially obvious.  Keep reading »

MP3 Cue Points Article Updated on Adobe Developer Connection

Tuesday, December 4th, 2007
ActionScript 2.0 ActionScript 3.0

I wrote a cue points article last year (October, 2006) for what was then called the Adobe Dev Center.  One of the editors recently asked me to update that article for Flash CS3, which I was happy to do.  It’s now available on the Adobe Developer Connection at the following URL.

http://www.adobe.com/devnet/actionscript/articles/cue_points_audio.html

If you’re looking for a way to assign cue points to audio files (especially MP3 files loaded at runtime), I hope you find this article useful.  It steps through a custom SoundSync class in ActionScript 2.0 and 3.0.

Trust Me, AS3, It’s a MovieClip

Thursday, November 29th, 2007
Flash ActionScript 3.0

This topic came up when someone asked me how (if it was possible) to instruct one movie clip to start playing after another has stopped.  For example, the main timeline does its thing, humming along, when it suddenly comes to a keyframe that contains a nested movie clip.  A simple stop() action in that keyframe tells the main timeline to rest where it is, and the nested movie clip starts playing on its own.  When the nested clip hits the last frame of its own timeline … that’s when the main timeline needs to start moving again.  How to do that?

In my reply, I said there were a number of possible ways.  You could set up a loop, for example — MovieClip.onEnterFrame (AS2) or Event.ENTER_FRAME (AS3), maybe setInterval() (AS2) or the Timer class (AS3) — and in that loop, check the current frame of the nested movie clip against the number of its total frames.  In AS2, that would be a comparison of _currentframe to _totalframes; in AS3, currentFrame to totalFrames.  When the former equals the latter, invoke MovieClip.play() on the main timeline and quit the loop.

But much easier than that, and less processor intensive, is simply to put a keyframe script in the last frame of the nested movie clip, telling its parent (the main timeline) to play.  In AS2, that would be this._parent.play();.  In AS3, this.parent.play(); (no underscore on parent).  Ah, but there lies a problem.  The AS3 version, which is technically correct, causes a compiler warning:  1061: Call to a possibly undefined method play through a reference with static type flash.display:DisplayObjectContainer.  What on earth?  Keep reading »

How to Pause and Loop the Timeline in Flash CS3 (AS3)

Monday, November 26th, 2007
Flash ActionScript 3.0

How to pause the main timeline (or any timeline), and how to loop it, are fairly common questions on the Adobe forums — not super hot topics, but they continue to crop up every few months.  I suggested an AS2 approach to both questions in “How to Pause a Timeline (AS2)” and “How to Loop a Movie Three Times (AS2)” in 2006, but now with Flash CS3’s support for ActionScript 3.0, a couple of updates make good sense.

Check out “Using ActionScript to pause and loop the timeline in Flash,” in the Adobe Design Center, to see how things have changed.  Looping, as it turns out, can be handled in practically the same way.  The recommended approach for pausing now calls for the Timer class, which operates very differently from the setInterval() used in AS2.