July 10, 2006

Essential ActionScript 2.0 Book

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 10:37 am

I have started having a read through the book Essentail ActionScript 2.0 by Colin Moock (O’Rielly ISBN: 0-596-00652-7). To further my knowledge in ActionScript 2.0 for this latest project. Although I will not be contributing to the coding of the frontend development directly, it betters my understanding of how to prepare content to drive the frontend website. It also allows me to provide another programmers input to the development design.

In Essential ActionScript 2.0, bestselling author Colin Moock covers everything you’ll need to know about the new ActionScript language and its methodologies. Experienced Flash developers and programmers coming from other languages will enjoy the sheer depth of Moocks’s coverage. Novice programmers will appreciate the frequent, low-jargon explanations that are often glossed over by advanced programming books. Essential ActionScript 2.0 is the one book every ActionScript coder must own.

The book is an easy read and you quickly can get hold of ActionScript 2.0 syntax and programming style straight away. This is a great book for programmers wanting to crash course into ActionScript and apply their already developed theory.

Check out the book on the O’Reilly Network Safari Bookshelf

July 6, 2006

Loading external data from Flash

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 12:34 pm

As you may all know already, you will need to ensure that you have a crossdomain policy available on your domain to ensure that XML/external data can be read and loaded into your clients flash player.

Flash Player Security will not allow content to be read in from a different domain to where the current file is sitting on - and as you will most likely be aware, www.domain.com and domain.com are different, and not everyone uses the www. prefix.

If your flash application uses an absolute URL to load the content, say from reading an XML document or communicating with a data provider architecture (Flash Remoting, Web Services and the like) you will need to create a basic cross-domain.xml policy file that sits at the root of your domain (eg, www.domain.com/crossdomain.xml).

This is termed sandboxing and can be read on the Macromedia Developer Center: Security Changes in Macromedia Flash 7.

An example of a crossdomain.xml policy file from flash remoting random thoughts is as follows:

<br />
< ?xml version="1.0"?><br />
< !DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"><br />
<cross -domain-policy><br />
<allow -access-from domain="www.flash-remoting.com" /><br />
<allow -access-from domain="flash-remoting.com" /><br />
<allow -access-from domain="*.flash-remoting.com" /><br />
<allow -access-from domain="www.communitymx.com" /><br />
<allow -access-from domain="communitymx.com" /><br />
</cross><br />

Diagnosing if this is the issue

If you are trying to make a request (aka. such as reading in XML or communicating via Flash Remoting) to a remote domain (aka. lets say you are staging it on a test server connecting to a live server, like www.myserver.com looks at www.myclientshosting.com) the request will not leave flash and won’t receive a response from the target server. Most of the time a flash developer will see this as a continous load sequence that hangs during loading of the XML or Remoting request.

EU Passport with Britain Citizenship

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 10:55 am

I received my United Kingdom of Great Britain and Northern Ireland Passport with my Britain Citizenship today, allowing me to work under The Free Movement Of Workers agreement.  I can virtually work anywhere in Europe now. Very excited about today.

A list of counties I can now work at in Europe can be read at http://www.anyworkanywhere.com/EECmembers.html

July 5, 2006

ActionScript compiling to SWF using ANT and as2ant

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 11:36 pm

I have been starting work on a project involving compiling multiple ActionScript classes. To help in the development process and shorten the time that the Flash Developers take to compile multiple classes into a single SWF movie I have researched into using ANT to compile the ActionScript classes. Using an Open Source Flash compiler (MTASC) and a As2ant (allowing us to create MTASC ant tasks) I have produced the following build.xml.

The build.xml expects that the project is setup with the folder:

  • build.xml
  • lib/as2ant.jar - required by ANT, available in the as2ant download package
  • src/**/*.as - All your class/classes (including subdirectories)

and creates the output to

  • build/*.swf

Have a look at the build.xml here.

You need to simply change you project name (for the output SWF) and the output settings, such as background colour, width/height params, main class and the like.
For any changes please email them to cameronmanderson@gmail.com.

Under the pump

You will find other articles relevant to this document in these sections:
Richard Lee @ 12:56 pm

Hi guys, sorry I haven’t been able to post as frequently as I had hoped over the last couple of days. In the past week the workload has been a bit crazy and I’m just about to head off to launch. So anyway, keep an eye out for some juicy post’s from Cam ;) i’ll be back into it soon!

July 4, 2006

Flash ActionScript strip slashes using Regular Expressions

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 2:23 pm

I am just having a bit of a play with some ActionScript 2 for an upcoming project. I have came across the necessity to strip slashes of a string that has been directly parsed from PHP. As it is a object containing many properties it may seem unfeasible to try and strip slashes for every property of the whole object. Instead I will look in flash on how to allow the Flash Developer to strip slashes when they wish to use the object property.

To do so we will want to have a look at Regular Expressions in Flash. Flash did not come packaged with any Regular Expression classes by default, so we will have a look at a using a popular package “RegExp.as” provided by Joey Lott at this URL: http://www.jurjans.lv/flash/RegExp.html. Once we have downloaded the package from their website, you can set it up in your flash file using a simple import.

Reading over the documentation to the behaviour of “addslashes” on PHP.net:

Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote (), double quote (), backslash (\) and NUL (the NULL byte).

So our strip slashes will atleast need to ensure that the escaped characters do not contain escaping ‘\’ characters.

One basic way of doing this would be to create a Regular Expression that would match against those characters.

Regular Expression to match occurance of addslashes escaping

(\\([”‘\\])) - Starts with a slash followed by any of the escaped characters (NOTE: this contains single quote and double quote characters which need to be escaped)

The escaped value to use in our Flash Regular expression is “(\\\\([\”\’\\\\]))” (a mouth full of escaping due to the fact that we are matching escaped characters).

// FLASH ActionScript Strip Slashes Example
// Import our RegExp class
import RegExp;
 
// Some escaped text that has arived from PHP or a database
body = "\"foobar.html\" and then \\ \' this and that etc";
trace(stripslashes(body));
 
/**
* Strips slashes of a String
* @param str String Escaped String to strip slashes
* @return String with slashes removed
*/
function stripslashes(str:String):String {
    var stripSlashesRegExp = new RegExp("(\\\\([\"\'\\\\]))","gim");
    return str.replace(stripSlashesRegExp, "$2");
}

This will be much more powerful than a split(’\\’).join() style as that method will strip all backslashes in your document. You may want to consider using a wrapper class and create a Singleton design pattern to stop compiling the regular expression every time it is called. Maybe you could consider adding it as a prototype for the String Class also.

July 3, 2006

Quote of the day

You will find other articles relevant to this document in these sections:
Richard Lee @ 4:39 pm

Writing CSS is very much like having sex. Not everyone does it the same way and there is no particular “right” way to do it - Jonathan Branbrook

« Previous Page