Flash Builder 4 beta is here!
Adobe released Flash Builder (formerly Flex Builder) 4 beta today. You can check it out here. Also, be sure to check out what’s new in FB4 here.
AS2 to AS3 Buttons
In ActionScript 3, Adobe got rid of attatching code directly to the MovieClip or Button you were working with on the the timeline.
So no more of this:
1 2 3 4 | on(press) { //do something } |
For code on the timeline that affects a button (whose instance name we’ll call “button”), we used to do this in AS2:
1 2 3 4 | button.onPress = function() { //do someting; } |
Now in AS3, we have something a little more “wordy”:
1 2 3 4 5 | button.addEventListener(MouseEvent.MOUSE_DOWN,handleClick); function handleClick(e:MouseEvent):void { //do someting; } |
One thing to understand about ActionScript 3 is that it is an event driven language. You listen for events, events get dispatched, and you handle them appropripately. I’ll break down the code for you.
1 |
What we’re saying on line 1 is here, we have a button that will listen for MouseEvent.MOUSE_DOWN events, and if that happens run the handleClick function.
2 |
Here, we’re just defining the function “handleClick.” It accepts an argument of type MouseEvent and :void means it doesn’t return anything.
As you can see, AS3 for buttons isn’t too difficult, just a little wordier. Below, I’ve listed the old way of handling buttons with their new event listeners. Just swap out the MouseEvents for what you need when you add the event listener.
| AS2 | AS3 |
| button.onPress | MouseEvent.MOUSE_DOWN |
| button.onRelease | MouseEvent.MOUSE_UP |
| button.onRollOver | MouseEvent.MOUSE_OVER |
| button.onRollOut | MouseEvent.MOUSE_OUT |
ActionScript 2 to ActionScript 3 Migration Cookbook
I’m starting a new series of mini how-to’s to ease ActionScript 2 migration to ActionScript 3. AS3, as we like to call it, is a much cleaner and more standardized language; not to mention a whole lot faster. Adobe has really been urging everyone who works with Flash to switch to AS3.
So if you’ve been putting migration off, now is the time to learn. These recipe style how-tos will be targeted to mostly Flash Designers and novice to intermediate developers who haven’t made the switch quite yet.
I’m at FlexCampOC!
I’m here at FlexCampOC at the Boeing Conference Center in Huntington Beach. The schedule sounds like a great line up of speakers.
If you’re here, come say hello! I’m in the 3rd row, 1st on the left facing the stage. I’m the Asian in the white blazer and brown shirt.
Flex Camp OC
What do you get when you combine 150 Flex and ActionScript wizkids at Boeing? Flex Camp OC, that’s what. There’ll be plenty of cool talks, food, prizes, and a party later on in Surf City. Register and introduce yourself. I’ll see you guys on January 31st.
Google’s Vision of Flash Content Gets a Little Clearer
FlashSpeaksActionscript just posted Jim Corbett’s presentation on SWF searchability. This is great for flash developers and designers who worry about SEO.
Check out the presentation here. [via FlashSpeaksActionScript]
Adobe Releases Air 1.5 for Linux
Adobe has released AIR 1.5 for Linux! I’m not a desktop Linux user myself (I only use it for my web server) but I do approve of reaching a bigger audience. What’s great about AIR is that it allows web/AJAX/Flash developers to build desktop applications without the use of the “classical” programming languages such as C/C++.
Adobe announces Stratus
With the release of Flash Player 10, Adobe has allowed for peer to peer connections. But to get the clients to be aware of each other, you needed a middleman to handshake the peers such as an updated version of the Flash Media Server. Now Adobe Stratus is a new beta service that will act as the middleman and connect the peers. Once the connection has been established, it’s all peer to peer traffic.
Imagine peer to peer games, video chat without a intermediate server, etc. I hope to get a demo app out once I learn a little bit about it more.
CASA Lib updated to AS3
If you guys code as much as I do, I’m sure you’ve found yourself using code over again and again. CASA Lib is a set of classes and utilities to get you coding faster. Need to find and average value in an array? No problem. Need to remove all event listeners and do other cleanup when you remove a sprite from the stage? That’s there too. Check it out here or download here.
