SWFAddress, if You Aren’t Using it for All Your Flash, Start to

We’ve been using SWFAddress for a while now, and while I was cleaning old project files out of Flex I came across my first Flex Test using it. It’s simple, and in fact, SWFAddress has been improved a bunch since this test was made (mostly involving SEO, and fallback links + Google Analytics). Now we’re using it for running our entire navigation schemes for all Flash sites, mini-sites, components, and even in our pitches.

Check out my example (click anywhere to move the box, then use the back/forward buttons for undo/redo).

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package {
	import com.asual.swfaddress.SWFAddress;
	import com.asual.swfaddress.SWFAddressEvent;
 
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
 
	public class SWFAddress_test extends Sprite
	{
		private var _square:Shape;
 
		public function SWFAddress_test()
		{
			SWFAddress.addEventListener(SWFAddressEvent.INIT, init);
		}
 
		private function init(evt:SWFAddressEvent):void
		{
			SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleSWFAddressChange);
			stage.addEventListener(MouseEvent.CLICK, gotoAddress);
 
			_square = new Shape();
			_square.graphics.beginFill(0x0);
			_square.graphics.drawRect(0,0,50,50);
			this.addChild(_square);
		}
 
		private function handleSWFAddressChange(evt:SWFAddressEvent):void
		{
			trace(evt.path);
			var address:Array = evt.path.split("/", 3);
			var xLoc:Number = Number(address[1]);
			if(!isNaN(xLoc)) moveSquare(xLoc);
 
		}
 
		private function gotoAddress(evt:MouseEvent):void
		{
			SWFAddress.setValue(this.mouseX.toString());
		}
 
		private function moveSquare(loc:Number):void
		{
			_square.x = loc;
		}
	}
}

Why we use the MIT license for all our work.

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Plenty that’s been heard and said before, but with some good jokes, and relevant to the fans / obedient followers of Shepard Fairey and his arrest in Boston. (Glad I live in Somerville).

I still think his arrest has to do with the upcoming mayoral race.

Flex Custom Validator Email Confirmation

Pretty simple stuff. This was driving me a bit crazy at the beginning of the day so I decided to just cut and paste my source code hoping this will help someone else out. Basically I just want to create a custom validator that makes sure one field is equal to another in flex. Pretty simple but if you are a noob you will find this task a bit sucky…. Her is the code

Actionscript Custom Validator.

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.flextradeshow.classes
{
	import flash.text.TextField;
 
	import mx.controls.TextInput;
	import mx.validators.ValidationResult;
	import mx.validators.Validator;
 
	public class EqualValidator extends Validator
	{
		private var results:Array;
 
		[Bindable]
		public var textbox:TextInput = new TextInput();
 
		public function EqualValidator()
		{
			super();
 
		}
		override protected function doValidation(value:Object):Array
		{
			results = [];
			results = super.doValidation(value);
			if(results.length > 0)
			{
				return results;
			}
			if(value!=textbox.text || !value)
			{
				results.push(new ValidationResult(true,null,"NaN","Not a matching value sorry"));
				return results;
			}
			return results;
		}
	}
}

This is the code you need in your view to use the validator.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0" encoding="utf-8">
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:tsclasses="com.flextradeshow.classes.*" >
	<mx:StringValidator
		id="nameValidator"
		source="{_iname}"
		property="text"
		minLength="4"
	/>
	<mx:EmailValidator
		id="emailValidator"
		source="{_iemail}"
		property="text"
	/>
	<mx:EmailValidator
		id="emailConfirmationValidator"
		source="{_iconfirmemail}"
		property="text"
	/>
	<tsclasses:EqualValidator id="sameEmailValidator" source="{_iconfirmemail}" textbox="{_iemail}" property="text" />
 
	<mx:Form labelWidth="100" width="302" height="100%" horizontalScrollPolicy="off">
		<mx:FormItem label="Full Name" required="true">
			<mx:TextInput  id="_iname"/>
		</mx:FormItem>
		<mx:FormItem label="Email" required="true">
			<mx:TextInput id="_iemail"/>
		</mx:FormItem>
			<mx:FormItem label="Confirm Email" required="true">
			<mx:TextInput id="_iconfirmemail" />
		</mx:FormItem>
		<mx:FormItem label="Birthday">
			<mx:DateField  id="_ibirthday" />
		</mx:FormItem>
		<mx:Spacer height="15"/>
		<mx:Label text="Free mimoDesk Sample (Choose One)"></mx:Label>
		<mx:Box paddingLeft="110">
			<mx:RadioButtonGroup id="freemimodesk"/>
			<mx:RadioButton label="Star Wars" groupName="freemimodesk" selected="true"/>
			<mx:RadioButton label="Tokidoki" groupName="freemimodesk"/>
			<mx:RadioButton label="Original Core Series" groupName="freemimodesk"/>
			<mx:RadioButton label="Not Interested" groupName="freemimodesk"/>
		</mx:Box>
		<mx:Spacer height="15"/>
		<mx:Label text="Subscribe to any of the following Newsletters"></mx:Label>
		<mx:Box paddingLeft="110">
			<mx:CheckBox label="Consumer" selected="true"/>
			<mx:CheckBox label="Press"/>
			<mx:CheckBox label="Wholesale"/>
		</mx:Box>
		<mx:Box horizontalAlign="right" width="100%">
			<mx:Button label="Subscribe"/>
		</mx:Box>
	</mx:Form>
</mx:Panel>

Facebook Post Image Test

Gilles Villeneuve(CDN) Ferrari 312T4 Graham Hill(GBR) Lotus 33

Yeah old F1 Pics.

Some explanation: We’re working on a RSS feed that can be read by Facebook so it can add images to the newsfeed post automagically. Then we want to see if when we change it in the RSS feed, it updates on FB or not. Fingers Crossed.

Update: This worked out fine, but once the image is posted you’d have to replace the image on your webserver, with one of the same name, to change the one on FB (Since they externally load it each time).

Quick Look for Actionscript (and most other c-like source-code)

Stumbled across this Quick Look plugin the other day while learning Objective-C, and while it previewed and code colored my .h and .m files, it was a bit disappointing that it didn’t work on .as files.

So not quite as simple as adding .as to the info.plist—what I’ve done is add public.archive.applesingle to the list of UTI types. This is a bit of a hack, because Adobe doesn’t export a profile UTI with .as files. So if they do start doing that someday, this may cause problems, but in the meantime, it’s the simplest way to get quicklook working for .as files.

Download Quick Look with ActionScript Plugin