Author Archive for Rich

26
Apr

AS3 Teachers Wanted


If you are a teacher or trainer currently using Learning ActionScript 3.0 in a class, please get in touch. We are developing additional teaching resources and are anxious to know what you think would help you most. What are the strengths and weaknesses of the book? What tools will help you in your teaching? Any opinions will be appreciated!

If you’re a student using Learning ActionScript 3.0 in a class, please let us know what kinds of class resources you think would be useful, and tell your instructor we’re looking for input!

23
Apr

Looking Forward to Flashbelt


We’re very happy to announce that I’ll be conducting a workshop on ActionScript 3.0 at this year’s Flashbelt conference in Minneapolis. It’s a full-day workshop based on the book, teaching the fundamentals of AS3 with lots of examples and, of course, free source code.

This will be my first time at Flashbelt, and I’m really looking forward to it. I’ve heard very high praise about the show—praise that grows year over year—and I dig Flashbelt’s El Hefe, Dave Schroeder. In addition to putting together Flashbelt, Dave is also the brains and talent behind Pilotvibe, a groovy place to get you some Flash sound.

From everything I’ve heard, Flashbelt is a happenin’ gig, that has an intimate feel and a stellar group of presenters. This year is no exception. Presenters include Mark Anders, Julian Dolce, JR Fabito, Richard Galvan, Moses Gunesch, Joshua Hirsch, Robert Hodgin, Mario Klingemann, Tali Krakowsky, Dan Lacivita, Lisa Larson-Kelley, Seb Lee-Delisle, Andre Michelle, Stacey Mulcahy, Erik Natzke, Paul Ortchanian, Danny Patterson, Todd Perkins, Robert Reinhardt, Rich Shupe, Geoff Stearns, Mate Steinforth, Zach Stepek, Craig Swann, Jared Tarbell, Dustin Tauer, Jeremy Thorp, and Philip Van Allen.

This year, the event is June 8-11, and I hope to see you there.

26
Mar

AS3 Components and TxEff


Recently I’ve been trying to put together a collection of AS3 components for some writing and training I’m doing about… er… AS3 components. I want to write a series of posts here, but I also have another column, book, and video training in the works, in which they may appear. With a fair amount of focus on this effort, I wanted to look around for some great examples, ranging from open source to commercial, simple to advanced.

In the process, I happened upon TxEff from Jumpeye Components. TxEff is a spectacular text-effects component with a really great configuration utility that allows you to easily modify all the effects without writing any code. You can also configure the effects without the utility using XML. Written in AS3, it performs really well and Jumpeye did a great job, soup to nuts. You can even add on to the component with additional effects.

I haven’t been able to try any of the additional effect libraries, but I decided to try a simple test that fits in well with the first post in this series. I wanted to see how easy it would be to create a simple effect using the online utility. I wanted to create something that anyone could do, right out o the box. I was pretty impressed with how easy it was to adjust the many parameters and found myself with the problem of too much goodness to choose from. Then I decided to test the defaults of one of the new effects, 3DCamFocus. Here it is:

Continue reading ‘AS3 Components and TxEff’

12
Jan

Chapter 3 Document Classes


Thanks to Nick, we discovered an error in the document classes that accompany the source code for Chapter 3. The error has been corrected, and the archive has been replaced. This has nothing to do with the book, so this only applies to those early coders who downloaded the Chapter 3 source archive prior to January 12, 2008.

We introduce syntax and concepts early on in a way that allows us to focus closely on the topics themselves, without having to dive immediately into classes. We then use classes more and more as we progress through the chapters.

However, if you already have some experience with classes (or want to start pushing yourself to this ideal early on), we also provide a second copy of all the timeline examples, using document classes instead. This way you can experiment with both approaches and pick the style that suites you best at the outset of the book.

So, none of the timeline examples were affected and, if you only need to think about this if you downloaded the Chapter 3 archive before January 12th.

Thanks Nick!

12
Jan

Site Testers


We would like to start a small list of folks who would be willing to put this site through its paces. If anyone is interested/willing to test the site over time- (no commitment required, just test as you go) please send us a note through the Contact form. Thanks.

14
Dec

Sending Data from AVM2 to AVM1


In Chapter 13, we showed how to use a LocalConnection to communicate between an AS3-based movie in Flash Player’s AVM2, and an AS2-based movie in Flash Player’s AVM1. The example was basic, using functions to stop and start an animated movie clip. In this first of future additional examples, we’ll pass data into a function in the AVM! movie.

Continue reading ‘Sending Data from AVM2 to AVM1′

21
Nov

Mandatory Argument Types


Loosely related to the Dispatching Custom Events post, here's a quick example of how to deal with the data type checking of mandatory arguments, such as those used with event listeners.

Below is all the source code required for this example, including the errant segments. Lines 1 through 7 setup a simple timer that calls a function every 3 seconds, until the timer is triggered three times. If you test just that portion of the code, you'll see an initial delay of three seconds, followed by three traces to the Output panel.

Suppose, however, that you also want to trigger the same event once, immediately. If you just call the function, as seen in line 10, you will get an error. This is because you can't call a listener with required arguments, without sending the required values. That is, the listener function requires an event object for the evt parameter, and an error will be thrown if it is not supplied.

ActionScript 3.0:
  1. var timr:Timer = new Timer(3000, 3);
  2. timr.addEventListener(TimerEvent.TIMER, onTimer, false, 0, true);
  3. timr.start();
  4.  
  5. function onTimer(evt:TimerEvent):void {
  6.     trace("timer function triggered");
  7. }
  8.  
  9. //scenario 1
  10. //onTimer();
  11. //error: 1136: Incorrect number of arguments.  Expected 1.
  12. onTimer(null);
  13.  
  14. //scenario 2
  15. onTimer(new TimerEvent(TimerEvent.TIMER));
  16.  
  17. //scenario 3
  18. //stage.addEventListener(MouseEvent.CLICK, onTimer, false, 0, true);
  19. //TypeError: Error #1034: Type Coercion failed: 
  20. //   cannot convert flash.events.MouseEvent to flash.events.TimerEvent.
  21. stage.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
  22.  
  23. function onClick(evt:MouseEvent):void {
  24.     onTimer(new TimerEvent(TimerEvent.TIMER));
  25. }

One easy way to accomplish this goal, is to send null with the function call, as seen in line 12. This will prevent an error from being thrown. If the event itself can be of use to you, you can create a new Timer event and send that to the listener argument. This can be seen in line 15, and is also covered in the previous post. All you have to do is follow the new keyword, with the desired event class, and the specific event you want to be created.

The third scenario is an example of wanting to augment the timer with mouse clicks. If you simply add a mouse listener to the stage, as seen in line 21, you will also get an error. The onTimer function will be called, but the event passed to the function will be a mouse event, rather than the required timer event. One way to get around this is to create an interim function, that correctly receives the mouse event and sends the desired timer event to the ultimate function, as seen in lines 23 through 25.