One idea that I had when creating the MotionSketch extension was that it could be used to do write-on effects. I was going to write an Actionscript class to demo this effect prior to releasing MotionSketch but ran out of time. So I tweaked a version of vCam to quickly demo the effect for the MotionSketch video tutorial. Thanks to a reader’s email, I was reminded that I still had yet to write this class. It’s now written and free to download. I’m calling it MotionBrush to keep it in the family with MotionSketch and MotionBlur. It’s super simple to use. Check out the video tutorial:
Oftentimes, I like to trace pieces of data as I’m programming just to make sure everything is on track. When you’re trying to trace data using E4X (XML in Actionscript 3), don’t forget the toXMLString() function. In many cases, you won’t see anything if you forget to call this function. Your code will see the data just fine, but you might not think it’s working and spend time trying to diagnose a non-existent problem.
trace(xml.children()[0])//empty tracetrace(xml.children()[0].toXMLString())//now we see it!
Thanks to a generous donation, I’ve picked up a much nicer video capture application. This video tutorial shows how to translate Photoshop graphics into Actionscript using the AS3 drawing API. The resulting SWF file size is minuscule: from a 100kb Photoshop-to-Flash import to a 5kb file with some coding. I start with the most basic aspects and work up to the more complex: from a basic rectangle, to patterns from Photoshop, to complex gradients.
I’m pretty happy with this new software, so I’ll try to post more videos. Still working on getting better resolution out of the video host though…
Careful with this one. It’s easy to miss if you’re accustomed to Actionscript 1 or 2.
stage.width will return the width of the content on the stage and ignore any empty pixels around the edges. So if you only have a 100 px wide rectangle on stage, your stage.width will be 100.
stage.stageWidth will give you the size of the stage, more like Stage.width in Actionscript 2. Use stage.stageWidth if you’re trying to position elements relative to the stage.
When working with other designers in Flash, I generally serve as the last line of defense for unsolved functionality mysteries. I often find that there’s a mishap that has resulted from changed or lost instance names, effectively decapitating pieces of code. So how do you control things with Actionscript?
The short answer: Instance Names.
For the detailed answer check out this video tutorial using Actionscript 3.
The Actionscript has to know “who” you’re wanting to talk to. Just as we know human beings by name, and talk about them and to them by name, Actionscript references objects by name. A teacher might tell “Timmy” to sit down. Accordingly, your script might tell “circle” to move 10 pixels to the left. If no symbol with the name, “circle” exists, nothing happens; just as no one sits down if there’s no “Timmy” in the classroom.
Referencing nested MovieClips works the same way, just add a dot inbetween: var clipReference = grandparentClip.parentClip.childClip;
Remember that a symbol name is different than an instance name. You can have multiple instances of a symbol on stage, but each instance name has to be unique. Instance names are set in the Property Inspector, symbol names are set in the Library.
Keep this idea in mind when working with Actionscript and it will make your life a whole lot easier.
The vCam was a camera tool for Flash created by Sham Bhangal, primarily for the work of Adam Phillips. It’s intuitive and easy to use, and creates some excellent effects. It appears as though it’s now being maintained by Bryan Heisey. Bryan’s got an AS2 version, an AS3 version for better performance, and an interactive AS3 version.
Over the past several months I’ve put together some rather extensive AS2 class libraries for some ongoing Flash projects. I had noticed that many of the open source libraries available on the interwebs had snazzy html documentation. Putting together this kind of documentation is not only helpful for other people using the libraries (so that they don’t have to go digging through the code), but it comes in handy when the author (me, in this case) hasn’t touched the code for a while.
I’m a big believer in the open-source movement and many times I’ve been able to find an open source solution that does the trick as well or better than a packaged piece of software can. So I started searching under the assumption that I would eventually settle on an open-source solution. In the case of Actionscript documentation, I found my ideal solution in VisDoc. It was one of the few solutions that had a Graphical User Interface rather than using a command line. It produces a beautiful set of documentation files. It works for both AS2 and AS3 (and Java). The one downside is that it’s Mac only. It’s not open-source, but with a sticker price of $40, it’s well worth the time saved. If you’re still looking for open-source or you need an app for your Windows machine, OSFlash has a comprehensive list of open-source documentations tools for Actionscript.