Not just Actionscript noodlings


26 Oct

Molehill – new Flash 3D engine


An amazing new native 3D engine was unveiled at the Adobe Max conference. It’s a “new set of low-level, GPU-accelerated 3D APIs that will enable advanced 3D experiences across screens through the Flash® Platform (Flash, AIR and mobile).” The last full release of the Flash player (10) enabled 3D-like functionality (it was actually 2.5 D), but this is a whole new situation.

http://labs.adobe.com/technologies/flash/molehill/


02 Sep

Chop or Not


The was my last project for KentLyons -  a microsite/game for Channel 4 called Chop or Not.

With the British general elections looming and the budget being a main focus for the media and voters, Channel 4 wanted to make a semi-serious game that let you make decisions on public spending.

The main game engine was built in Flash – Actionscript 3, using AMFPHP which connects the Flash via Php to a SQL database.

The game is has been used in collaboration with Channel 4′s Dispatches programme, for a live broadcast in the run up to the budget.


27 Jul

New site update


After a break of about 3 years, I’ve given my portfolio site (14lox.com) a much needed update.

I started from scratch, with an idea that I wanted to make it with flipping panels to display information. This would give nice transitions through sections and naturally create a grid, around which I could position the content.

Before Flash Player 10 (FP10), the only way to make 3D functionality was with an open source library like Papervision; but it was overkill for this simple motion. With FP10′s great penetration (97.5% in June 2010) coupled with the 3D (well 2.5D really) functionality built into it, I decided it was the way to go.

One of the problems with FP10′s 2.5D engine is that it’s not great for double sided objects, something that was essential for my project. While researching, I stumbled across Soulwire’s great PaperSprite class, which solves this problem by allowing you to add DisplayObjects, one to the front and one on to the back. Once this was solved, it was just a matter of writing the XML file, chopping up the content into block size rectangles and creating different functions for different actions – some blocks having an image on its back, some are links and some are just coloured blocks.

Have a look for yourself, 14lox.com


09 Jul

New Freestyle Magazine site launched


My role in the Freestyle family is ‘Webmaster’ – a strange title, but basically it means I’m in charge of everything digital. I run the blog, help the team out with server issues and also to build the main site -  well today I have finally put the second version live.

Designed by Ollie and Massi (Senior Designer and Art Director, respectively) based in Milan, with direction from the team in Berlin and built by myself in London and now Sydney, you can definitely call this an international project.

It is built in Flash – Actionscript 3, using a variable of the MVC design pattern, with several different XML files allowing for dynamic updates of content. The site is built so that when a new issue is released the site can be updates just via the XML files, therefore abstracting the content from the display functionality, allowing for an AIR based CMS (coming soon) to update the content.

Take a look http://www.freestylemagazine.co.uk


22 Apr

TwitterScript proxy problem


I used TwitterScript for a project recently to display the site’s twitter posts and ran into Twitter’s cross domain policy. Basically you can’t access XML direct from Twitter.

Actionscripter talks about the problem, not specifically about TwitterScript, and gives a php solution:

The following two lines of PHP code will create your proxy service. Name this proxy.php and put it on your server:

<?php
$url = $_GET['url'];
readfile($url);
?>

Now, instead of calling

http://twitter.com/statuses/user_timeline/zenbullets.xml?count=5

We call

http://yourserver.com/proxy.php?url=http://twitter.com/statuses/
        user_timeline/zenbullets.xml?count=5

Th problem with TwitterScript is that (at the time of writing) it is released as a swc, which doesn’t allow you to edit the code. My solution was to manually download the actionscript files from http://code.google.com/p/twitterscript/source/browse/#svn/trunk/src/com/twitter/api and build my own repository, using this instead of the swc. Then inside Twitter.as replace as instructed above.


1 Response Filed under: actionscript 3
19 Mar

Bubbling event problem in Internet Explorer 6


Another Internet Explorer problem I stumbled upon, which soley occurred on IE6 on a PC.

Within Actionscript 3, the event has a flow it follows when dispatched, I’ll let livedocs explain it better than me:

When an event occurs, it moves through the three phases of the event flow: the capture phase, which flows from the top of the display list hierarchy to the node just before the target node; the target phase, which comprises the target node; and the bubbling phase, which flows from the node subsequent to the target node back up the display list hierarchy.

It seems that IE6 is too slow when using a custom event (thats what I was using) while bubbling was set to true to function as expected. So I suggest you set it to false and or find a workaround.


27 Nov

SWFMacMouseWheel IE Problem


Recently came across a problem with Internet Explorer and SWFMacMouseWheel.

the error was

Message: 'swfmacmousewheel' is null or not an object

It turns out it was a common error and has been fixed in the latest version, which is below.

/**
 * SWFMacMouseWheel v2.0: Mac Mouse Wheel functionality in flash - http://blog.pixelbreaker.com/
 *
 * SWFMacMouseWheel is (c) 2007 Gabriel Bucknall and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Modded by Robert M. Hall - rhall@impossibilities.com 
 * Adjusted following functionality:
 * 1. Watch for events related only to flash content and not the container page
 * 2. Fixed to dispatch mousewheel events only to specific intance ID's that were registered, this
 *    allows multiple SWFobject embeds on a page to use swfmacmousewheel and they will only respond
 *    to their specific target ID's when the event.target.is passed. This way only the currently active item will receive a dispatch event.
 * 3. Works with SWFObject 2.1
 * 4. No longer throws an error on IE/PC platforms because of a null object
 * 5. Works on Safari for PC
 *
 * Dependencies: 
 * SWFObject v2.1 <http://code.google.com/p/swfobject/>
 * Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
 * This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
 *
 * Requires a few lines of changes to the AS2 and AS3 code to support the PC version of Safari
 * as well as an additional Flashvar paramater, set flashvars.browser = Browser.name;
 * These changes are only required for Safari on PC - all other modifications noted above are contained solely in this JavaScript
 * Safari PC support based on code/suggestions from Richard "RaillKill" Rodney of Hypermedia - http://railkill.free.fr/
 *
 * Browser detect part from http://www.quirksmode.org/js/detect.html
 *
 */
 
var Browser = { init:function() {
this.name = this.searchString(this.dataBrowser) || "unknown" },
	searchString:function(data){
	for(var A=0;A<data.length;A++){ 
	var B=data[A].string;
	var C=data[A].prop;
	this.versionSearchString=data[A].versionSearch || data[A].identity;
	if(B){
		if(B.indexOf(data[A].subString)!=-1){ 
			return data[A].identity
			}
		} else if (C) {
				return data[A].identity 
					}
			}
		},
		dataBrowser:[
			{
				string:navigator.vendor,
				subString:"Apple",
				identity:"Safari"
			}]};
 
Browser.init();
 
var swfmacmousewheel = function(){
			if(!swfobject)return null;
 
			var u=navigator.userAgent.toLowerCase();
			var p=navigator.platform.toLowerCase();
 
			var d=p?/mac/.test(p):/mac/.test(u);
			// alert(Browser.name);
			if( Browser.name != "Safari" && !d) return { registerObject:function() {} };
 
		var k = [];
 
		var r = function(event){
			var o=0;
			if(event.wheelDelta){
			o=event.wheelDelta/120;
			if(window.opera)o= -o;
			if(Browser.name=="Safari")o=o*3;}
				else if(event.detail) { o= -event.detail;
			}
				if(event.preventDefault) { 
				event.preventDefault(); }
			return o;
		};
 
		var __wheel = function(event){
 
			if(event.target.id == "" || event.target.id == undefined) {
				return; 
			} else {
				var o = r(event);
				var c;
				var tmpI = null;
				for(var i=0;i<k.length;i++){
				c = swfobject.getObjectById(k[i]);
					if(typeof(c.externalMouseEvent) == 'function' && event.target.id == k[i]) {
						tmpI=i;
					}
				}
				if(tmpI !=null) {
				c = swfobject.getObjectById(k[tmpI]);
				c.externalMouseEvent(o);	
				} else {
				window.scrollBy(0,-o);
				}
 
 
			}
		};
 
		return{ 
			registerObject:function(m)
			{
				k.push(m);
				if(window.addEventListener)window.addEventListener('DOMMouseScroll',__wheel,false);
				window.onmousewheel = document.onmousewheel = __wheel;
			}
		};
}();

25 Nov

Simple Actionscript Class setup


The simplest start to an Actionscript class

package
{
	import flash.display.Sprite;
 
	public class ClassName extends Sprite
	{
		public function ClassName ()
		{
			init();
		}
 
		private function init():void
		{
			trace("init");
		}
	}
}

19 Oct

Making sure something is on the stage


Sometimes you will need a class to be on the stage before you can use it. For example, when using the stage properties like stage.stageWidth and stage.stageHeight.

I have found the following to work the best:

package
{
	public class DisplayItem extends Sprite
	{
		public function SomeClass ()
		{
			addEventListener(Event.ADDED_TO_STAGE, init);		
		}
 
		private function init(event:Event):void
		{
			//It's always best to remove any event listeners once you dont need them any more.
			event.target.removeEventListener(Event.ADDED_TO_STAGE, init);
 
			trace("stage height = "+stage.stageHeight);
			trace("stage width = "+stage.stageWidth);
		}
	}
}

19 Oct

Centering anything


This is the simplest way to center anything.

anyThing = new AnyThing();
anyThing.x = (stage.stageWidth * 0.5) - (anyThing.width * 0.5);
anyThing.y = (stage.stageHeight * 0.5) - (anyThing.height * 0.5);
addChild(anyThing);

Page 1 of 212