Loop through XML elements using PHP

If you don’t know the absolute path of an element in your xml file the using xpath and ‘//’ acts as a wildcard (similar to ‘..’ in as3 i guess) you can run a loop and return all values for those elements.

Handy for this likes RSS feeds or KML files ect.

<?php

$xml = simplexml_load_file('my.xml');

	foreach ($xml->xpath('//xmlnode')  as $node) {
    	echo "\t node: $node <br />\n";

	}
?>

SQL Update with join.

UPDATE a INNER JOIN b ON a.id = b.id  SET a.column = b.column

Javascript onclick=”return validateForm()”;

This is the basics for an checking if a Terms and Conditions checkbox has been checked, using javascript.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script>
function validateForm()
    {

 		if(!document.getElementById("tandc").checked){
			document.getElementById("tandc").focus();
			alert("You must agree to the terms and conditions");
			return false;
		}

		return true;
	}
-->
</script>
</head>
<body>
<input id="tandc" name="terms" type="checkbox" value="" />
 <a href="process.php" onclick="return validateForm();"><input type="button" name="Submit" value="Submit" /></a>
</body>
</html>

Orbiting around a target 3D object – Away 3D

This is a AS3 script using Away 3D that orbits some 3d objects around a target object, if an alternate target object is selected, all orbiting objects and camera target Tween to their new coordinates.

View Demo

Source

package
{
		import away3d.cameras.Camera3D;
		import away3d.containers.ObjectContainer3D;
		import away3d.containers.Scene3D;
		import away3d.containers.View3D;
		import away3d.core.base.Face;
		import away3d.core.base.Mesh;
		import away3d.core.base.Object3D;
		import away3d.core.base.Vertex;
		import away3d.core.clip.RectangleClipping;
		import away3d.core.utils.Cast;
		import away3d.events.MouseEvent3D;
		import away3d.lights.DirectionalLight3D;
		import away3d.lights.PointLight3D;
		import away3d.loaders.Loader3D;
		import away3d.loaders.Swf;
		import away3d.materials.BitmapMaterial;
		import away3d.materials.ColorMaterial;
		import away3d.materials.ShadingColorMaterial;
		import away3d.materials.WireColorMaterial;
		import away3d.materials.WireframeMaterial;
		import away3d.primitives.Cone;
		import away3d.primitives.Cube;
		import away3d.primitives.LineSegment;
		import away3d.primitives.Plane;
		import away3d.primitives.Sphere;
		import away3d.primitives.TextField3D;
		import away3d.primitives.Trident;
		import away3d.sprites.MovieClipSprite;
		import away3d.sprites.Sprite3D;

		import com.greensock.TweenLite;

		import flash.display.Sprite;
		import flash.display.StageAlign;
		import flash.display.StageScaleMode;
		import flash.events.Event;
		import flash.geom.Vector3D;

		import wumedia.vector.VectorText;

	[SWF(backgroundColor='#333333', frameRate='60')]
	public class PositionOnSphere extends Sprite
	{
		private var _scene:Scene3D;
		private var _camera:Camera3D;
		private var _view:View3D;

		public var  _lookX:int = 300;
		public var _lookY:int = 200;
		public var _lookZ:int = 700;
		private var sphere:Sphere;
		private var sphereOrbit1:Sphere;
		private var sphereOrbit1Phi:Number;
		private var sphereOrbit1Theta:Number;

		private var sphereOrbit2:Sphere;
		private var sphereOrbit2Phi:Number;
		private var sphereOrbit2Theta:Number;

		private var sphereOrbit3:Sphere;
		private var sphereOrbit3Phi:Number;
		private var sphereOrbit3Theta:Number;
		private var target01:Cube;
		private var target02:Cube;

		public function PositionOnSphere()
		{
			super();
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;

			initScene();
			initObjects();

			this.addEventListener(Event.ENTER_FRAME, render);
		}

		private function initScene():void
		{
			_scene = new Scene3D();
			_camera = new Camera3D({z:-1000});
			_view = new View3D({scene:_scene, camera:_camera});
			_view.x = stage.stageWidth/2;
			_view.y = stage.stageHeight/2;
			_view.clipping = new RectangleClipping({minX:-stage.stageWidth/2, minY:-stage.stageHeight/2, maxX:stage.stageWidth/2, maxY:stage.stageHeight/2});
			addChild(_view);

			// Add trident for reference
			var tri:Trident = new Trident( (1000/2+100),true);
			_scene.addChild(tri);

		}
		private function initObjects():void
		{
			var plane:Plane = new Plane();
			plane.width = plane.height = 50000;
			plane.y = -1000;
			plane.segmentsW = plane.segmentsH = 12;
			plane.material = new WireframeMaterial(0x222222);
			_scene.addChild(plane);

			sphere = new Sphere({material:"white#black",radius:200});
			sphere.ownCanvas = true;
			sphere.alpha = .7;
			sphere.bothsides = true;
			sphere.x = _lookX;
			sphere.y = _lookY;
			sphere.z = _lookZ;
			_scene.addChild(sphere);

			//setup target objects
			target01 = new Cube({material:"black#white", depth:50, width:50, height:50});
			_scene.addChild(target01);

			target02 = new Cube({material:"black#white", depth:50, width:50, height:50});
			_scene.addChild(target02);
			target02.x = _lookX;
			target02.y = _lookY;
			target02.z = _lookZ;

			target01.addEventListener(MouseEvent3D.MOUSE_DOWN,objectHandler);
			target02.addEventListener(MouseEvent3D.MOUSE_DOWN,objectHandler);
			//set up orbiting spheres

			sphereOrbit1 = new Sphere({material:"yellow#black",radius:20});
			sphereOrbit1Phi = radians(0);
			sphereOrbit1Theta = radians(90);

			_scene.addChild(sphereOrbit1);

			sphereOrbit2 = new Sphere({material:"red#black",radius:20});
			sphereOrbit2Phi = radians(90);
			sphereOrbit2Theta = 0;

			_scene.addChild(sphereOrbit2);

			sphereOrbit3 = new Sphere({material:"blue#black",radius:20});
			sphereOrbit3Phi = 0
			sphereOrbit3Theta = radians(90);

			_scene.addChild(sphereOrbit3);
		}

		private function objectHandler(e:MouseEvent3D):void
		{
			var obj:Object3D = e.target as Object3D;
			tweenCameraTarget(obj.x,obj.y,obj.z)

		}
		private function setCoords(_targetObject:Object3D,_radius:Number = 300,_phi:Number = 0,_theta:Number = 0):void{

			var xp:int = _lookX - (_radius) * Math.sin(_phi) * Math.cos(_theta);
			var zp:int = _lookZ - (_radius) * Math.sin(_phi) * Math.sin(_theta);
			var yp:int = _lookY - (_radius) * Math.cos(_phi);

			_targetObject.x = xp;
			_targetObject.y = yp;
			_targetObject.z = zp;
		}
		private function hoverCamera():void
		{
			var mX:Number = this.mouseX > 0 ? this.mouseX : 0;
			var mY:Number = this.mouseY > 0 ? this.mouseY : 0;

			//you need to init tarX and tarY with the _lookX and _lookY
			var tarX:Number = _lookX +  5*(mX  - (stage.stageWidth*.5 ));
			var tarY:Number = _lookY + -5*(mY - (stage.stageHeight*.5));

			var dX:Number = _camera.x - tarX;
			var dY:Number = _camera.y - tarY;
			var dZ:Number = _lookZ - 1000 ;

			_camera.x -= dX*0.25;
			_camera.y -= dY*0.25;
			//always keep Z 1000 away from target
			_camera.z = _lookZ - 1000;
			_camera.lookAt(new Vector3D(_lookX, _lookY, _lookZ));

		}
		private function tweenCameraTarget(_x:int,_y:int,_z:int):void{

			//this tweens the look at variables
			TweenLite.to(this, 1, {_lookX:_x,_lookY:_y,_lookZ:_z});
			TweenLite.to(sphere,1,{x:_x, y:_y, z:_z});

		}
		private function radians(_degrees:Number):Number{
			//convert degrees to radians
			return _degrees*(Math.PI/180);
		}
		private function degrees(_radians:Number):Number{
			//convert radians to degrees
			return _radians*(180/Math.PI);
		}
		private function render(evt:Event):void
		{
			hoverCamera();

			setCoords(sphereOrbit1,300,sphereOrbit1Phi+=radians(1),sphereOrbit1Theta+=radians(3));

			setCoords(sphereOrbit2,330,sphereOrbit2Phi,sphereOrbit2Theta += radians(2) );

			setCoords(sphereOrbit3,270,sphereOrbit3Phi +=radians(4),sphereOrbit3Theta);

			_view.render();
		}
	}
}

Freelance @ White Agency

Just finished a 4 day stint at The White Agency, working on another AS3 dev job for CBA.
A nice sraight forward job, although client changed there minds as always on a couple of key issues, it was a straight forward good job. It was realistically my first job using Flash Builder, as I migrated from FDT. Really Coooool.

Freelance @ White Agency – CBA, Credit Card Selector Tool

I recently completed a short stint at ‘The White Agency‘ in a flash dev role, building a ‘Credit Card Selector Tool’ for Commbank . I actually came in to replace another freelancer who built the intro carousel, apart from that I built the rest. The actual build time was around 10 days. It was released in two stages, the second stage included the video guide as well.

cc_selector_01

cc_selector_02

Taking over from another developer always results in a few extra days in development, often and in this case it was quicker for me to start from the beginning rather than try to use existing code.

You can view the project here, as long as it is online.

Typoart website launch

Recently I have just launched typoart.com.au a HTML/CSS/jQuery based website. Focusing on customised typographical based art, this relatively small e-commerce based website is something I haven’t done for a long time which is a complete website with no flash. One of the main reasons behind this is small budget, quick turnaround and low and behold it work on iOS!!!! So I’ve had a dabble now in jQuery which I find rather cool. However don’t get me wrong flash is not dead…. but it has it’s place and for somthing like this website, there is no need. My CSS is also improving, and I think one of the most important featrue in CSS is display:

typoart_homepage

Instead of handling the transaction internally, again I have opted for Paypal. I find it extremely annoying developing for paypal using there sandbox, it so non user friendly… well the whole paypal website is good example of frustration! Next e-commerce solution I would like to try something like eWAY.

I also designed the logotype and am about to start designing all the stationary ect….

typoart__

Love projects are called love projects for one reason, they send you broke!’
Leon Wilson

SQL Snippet: Update table field using a join using SQL

This is a handy little snippet if you need to update one field (source) in one table (table 1) from the results of a field in a related table (table 2)


UPDATE table1 JOIN table1 ON table1.id = table2.id SET table2.source = table1.source

Lighting Hospital UK – Landing Page

I recently did a holding page for the Lighting Hospital UK, it was a basic page prior to a full website being built. Unfortunatly I didn’t have the time to built the full site due to AIAM100 commitments, however the landing page which I built in a day was the direction I would have wanted to go in.

This nature of this site lends itself for some nice flash experimental pieces, so it would have been nice to dabble.

Anyway this was just built using CSS and incorporates the recent CSS3 border-radius property… love it!

lh_landingpage

AIAM100 Launch Party

After a year and a half of telling people I’ve been building this site, we finally had the AIAM100.com website and exhibtion launch party on Friday night at Cooee Art Gallery in Lamrock Ave. Bondi.

Australian Indienous Art Market top 100 (AIAM100) is a website show casing the top Australian indigenous artists based on their market performance in the secondary art market. Over 130 profiles compiled by Adrian Newstead give the user a detailed view of each artist. Market Performance results are supplied by Australian Art Sales Digest (AASD), these results allow the AIAM100 to calculate the AIAM100 index and rank each artist accordingly. It also provides the overall health of the industry, for example the peak in 2007.

Adrian Newstead at the opening of the AIAM100 website and exhibiton

Adrian Newstead at the opening of the AIAM100 website and exhibiton

Ruth Hessey & Adrian Newstead

Ruth Hessey & Adrian Newstead

Being completely built in Flash I see this website as being a RIA rather than just a website. I know I know, it’s not the normal site to be completely built in Flash, and it raised numerous challenges along the way, especially regarding text layout, formatting and resizing (which are basic things we take for granted in developing an html based site). 50% of the site is it’s cutom built php based CMS, along with an extensive database, allowing AIAM administrators to easily publish new artists profiles.

Although i’ll still be working on adding a few more features it’s a great feeling to get AIAM100.com site live into the public.