Not just Actionscript noodlings

07 May

Hi



from multitouch-barcelona.com


No Response Filed under: video
07 May

Funkineven – She’s Acid / Must Move (Eglo)



Read full review of She’s Acid / Must Move – FUNKINEVEN on Boomkat.com ©

This is sounding great, shame I’m off to Oz in a month and taking vinyl is gonna be a problem. Hoping it’ll be out on a CD sometime soon.

p.s. loving the idea of the new boomkat embed feature, but surprised and disappointed that it doesn’t play anything directly, it opens up a new window. Come on boomkat, juno have had one for ages now.


No Response Filed under: music
07 May

OK OK time for a change…


OK so I set this blog up initially just to share some Flash and Actionscript related knowledge. So that has happened, not as much as I’d hoped, but I’ve been busy (working at KentLyons). But I realised recently that I’m blogging elsewherefacebooking, tweeting, dropping and tumbling alot of stuff that I like around the internets and my blog is being left alone, but it should be through my blog that I’m sharing these things (and it’s also a bit boring talking about just geeky shit) . So here starts a new chapter in my blog’s life….


No Response Filed under: talk
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);

06 Aug

drawRect() co-ordinates problem


You’ll often want to draw a rectangle using the graphics.drawRect() method, like:

var box:Sprite = new Sprite();
box.graphics.beginFill(0x7170b6, 0.85);
//drawRect(x, y, width,height)
box.graphics.drawRect(100,50,300, 200);
box.graphics.endFill();
addChild(box);

where the x and y values are 100 & 50. I have found that using the x and y values inside the drawRect method to not function as I wish.
It is simply solved by setting the values outside of the method, like:

var box:Sprite = new Sprite();
box.graphics.beginFill(0x7170b6, 0.85);
box.graphics.drawRect(0,0,300, 200);
box.graphics.endFill();
box.x = 100;
box.y = 50;
addChild(box);

Page 4 of 512345