Category Archives: ActionScript

C/C++ running in Flash Player

Probably one of the biggest things to happen to Flash….maybe ever. Last year at MAX Adobe gave us a sneak peak at a research project that took C++ code and compiled it into ActionScript. The demo they showed at the sneak peak at MAX 2007 of Quake running inside Flash Player. This got a lot of buzz. Well now they have released the toolkit (Alchemy) to the community. So you can go and start converting your favorite C/C++ libraries to ActionScript.

I’d personally like to see some XSLT and XML Schema libraries ported. And I’m sure there will be a lot of ports of physics and 3D libraries too.

Peer-to-peer Communication With Flash Player 10

You probably didn’t notice that Flash Player 10 (and AIR 1.5) shipped with a new protocol for p2p (peer-to-peer) communication. The RTMFP (Real-Time Media Flow Protocol) is a new protocol that supports direct connections between two endpoints.

What is the benefit of p2p communication? This will lower the barrier to entry for people to create real-time applications in Flash Player and AIR. No more bandwidth and server management expenses. The RTMFP protocol will also be a higher quality connection since it is over UDP and not TCP like the RTMP (Real-Time Messaging Protocol) used by Flash Media Server. RTMFP will re-establish a connection if there is a brief outage and maintain a session even if the client’s IP address changes.

This new protocol could be used for a number of applications like: text chat, VoIP conversations, video chat or multi-player games/applications.

Adobe announced Stratus the week. The is a hosted rendezvous service that allows two endpoints to establish a p2p connection. Once the connection is established the service is no longer used to send the data between endpoints. Stratus is currently in beta, but is not yet available for developers to start playing with it.

You can see a few of the RTFMP details in the ActionScript 3 Language Reference (see NetConnection).

Object Relational Mapping in AIR and SQLite

When I first started looking at AIR and SQLite I thought to myself, “someone should write an object relational mapping framework to map objects to and from SQLite.” Well someone did. FlexORM handles mapping of relational objects to and from SQLite and eliminates all the messy code for doing this manually. I can’t wait to use this on my next AIR project. Thanks to Nate Chrysler for pointing this out to me.

What is the future of ActionScript?

Ecma just recently announced that the long standing EcmaScript 4 proposal is dead in favor of focusing on the EcmaScript 3.1 proposal. According to the announcment, they will eventually work on EcmaScript 4 again, but under a revised plan. ES4 as we know it in ActionScript 3 appears to be dead. Specifically concepts like namespaces and packages will be dropped entirely.

So what does this mean for ActionScript 4? Will Adobe actually remove features to keep it compliant with Ecma?

Ecma has been split for a long time on the direction of EcmaScript. there are two camps, Microsoft has been pushing the EcmaScript 3.1 arguing that EcmaScript 4 is too much for the web (whatever that means). The other camp is lead by Mozilla and Adobe pushing for the evolution of EcmaScript with the ES4 proposal. I agree with the idea of EcmaScript Harmony. Ecma should be unified. But its unfortunate that the “standard” is now behind the ActionScript implementation.

AIR Distribution Kit

Tomorrow at FlashBelt I’ll be giving a presentation on Installation and Distribution Strategies in AIR. Since AIR applications are built using web technologies like JavaScript and ActionScript, many of the AIR users aren’t used to thinking about the installation and distribution strategies that desktop applications require. My presentation will cover a couple of these issues and show some sample solutions to these problems.

I’ll also be announcing the AIR Distribution Kit open-source project. This is a ActionScript 3 library for creating update functionality within AIR applications and for creating custom browser-based install applications (otherwise known as install badges). You can see more information about this project on my labs page. I just started this project, so there might be some bugs. Check it out and let me know what you think. Please let me know if you see anything you wish working differently or what features you’d like to see added in the future. If you’re interested in assisting with the development, please contact me.

Speaking at FlashBelt again this year

FlashBeltI’ll be speaking at FlashBelt again for the fourth straight year in June. I’ve spoken at this conference every year since I moved to Minneapolis in 2005. It’s a great conference that brings in both local and national attendees. My session is titled Distribution and Installation Strategies for AIR and will cover the following:

Flash and Flex developers have been spoiled by the fact that most of our applications are distributed over the internet through the browser and Flash Player. We didn’t have to worry about installation or updates within an application. This session will walk you through the process of building a custom badge using Flex that handles the installation, update and launch of your AIR application from within a browser. We’ll also look at how to implement an update feature within your Flex AIR application so your users can always have the most recent version of your application.

Firebug Target for Flex Logging Framework

We were talking about debugging Flash/Flex applications inside the browser the other day at MN.swf Camp and I mentioned that someone had created something called FlashBug that interfaced with Firebug. I’d never really looked into it much, but I knew it existed at one point. Well, it turns out the link to that is broken. So I did a little digging and found that the interaction with Firebug is super simple. So I decided to create a custom Target that works with the Logging framework in Flex. The following is an example of how to use this target:

1
2
3
4
5
6
7
8
9
10
11
import com.dannypatterson.logging.FirebugTarget;
import mx.logging.ILogger;
import mx.logging.Log;
 
var logger:ILogger = Log.getLogger("myLogger");
var logTarget:FirebugTarget = new FirebugTarget();
logTarget.addLogger(logger);
logger.info("info from flex");
logger.error("error from flex");
logger.warn("warn from flex");
logger.debug("debug from flex");

Download the FirebugTarget class here.

Compiling XML Data into your SWF

Have you ever wanted to actually compile XML data into your SWF before? I wanted to do this to embed the build version into my Flex appliction. The version was stored in an XML file and updated during the build process. But I wanted the version to actually exist inside the SWF in order to decouple the depandancy on the external XML file at runtime. This way I don’t need to worry about the XML file not loading or getting seperated from the SWF. The version will always be there. Here is a simple example doing this in Flex.

Continue reading

MN.swf Camp Sold Out

MN.swf Camp sold out in less than three days. We had to limit the attendees to 100 because of space limitations, however, we are currently exploring other venue options. If we can secure a larger venue then we will reopen registration. I suggest you sign up for the mailing list on the conference home page so you can be alerted if registration opens again.

MN.swf Camp is a one day conference in Minneapolis focusing on the Flash Platform for programmers. Its being organized by the MN.swf User Group and FlashBelt.

XOR Cipher Encryption in ActionScript 3

I typically use an external XML file in all my applications to store configuration variables outside my compiled SWF file. This allows me to make changes to those variables without needing to recompile the SWF application. This is really helpful if you’re deploying an application to multiple environments (development, staging, production). You can deploy the same application and just have a different XML file in each environment with different values.

The values in the XML file are easily read by anyone using a proxy like Charles or Service Capture. Therefore, I decided to put a simple encryption on the values I didn’t want people to be able to easily read. XOR Cipher encryption is a simple form of two-way encryption using a known key. This key would be compiled into your SWF application. So the only way someone could decrypt your variables would be if they decompiled your SWF or guessed the key. Obviously this solution is not hack proof, but it provides a road block for anyone trying to get at these values.

The following is an ActionScript 3 class that performs this XOR encryption. This encodes/decodes the XOR encrypted value using the Base64Encoder in Flex, so if you want to use this without Flex you’ll need to remove that dependancy. The xor() method performs the XOR encryption against the key. If you run a string through this method it with return and encrypted string, and if you run that encrypted string through this method it will return your original string.

Continue reading