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();
		}
	}
}

Away 3D setup hints

I’ve recently been working on a project using the Away 3D engine and thought I’de write this post to highlight a basics that I found werent really highlighted but relatively important. Its predominatly going to be used by me for reference, and I’ll keep adding to it

//Changing an Object3D's alpha value.
object3D.alpha = .5;
object3D.ownCanvas = true;

//Changing a MovieClipSprite alpha value
msc.movieclip.alpha = .5;

Materials

//Simple wireframe material
var material:WireframeMaterial = new WireframeMaterial( 0xff0000,{thickness:1});

//Simple colour material
var colorMaterial:ColorMaterial = new ColorMaterial( 0xffffff,{alpha:.5});

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.

Anniversary Invites

I recently created some invitations for my Aunty and Uncles’ 50th Wedding Anniversay. ‘The Golden Anniversary’ as it is named required some ‘gold’ in the design, so I decided it was a perfect job for the old Gocco. Before I told my Aunty I would be able to print in gold, I had to check I could still get the ‘Art Gocco’ supplies as I remebered they were going out opf production… My print supplier had bought a lot of back stock so they still has bulbs and screens, and were running out of inks. I was a little suprised to see the actual cost of screens had gone up from $15 for 5 to over $45 for 5, a nice %300 price rise. I ended up spending over $75 just on art gocco supplies.

The design involved printing the photographic elements on a bubblejet and the printing borders and titles in the gold. It is fun and satisfying when you get into the printing with the gocco, and once set up it is relatively quick. I personally love that the print isn’t perfect and you can see spots where the ink can be thin at times, or a little rough from the exposure.

The biggest time element was actually printing over 300 pages on the bubblejet, it took around 12 hours, and at one point when I went out to get some milk the paper jammed… TYPICAL. Anyway my Aunty was over the moon with them, and has told me that everyone adored them, so job well done.

Home Office

New home office setup already messy…. what can you do…. start working!!

Home Office Space

Corrupt, signal! Promotes purple times

About 2 weeks ago my 2007 MacBook Pro froze on me with a corrupted screen. It was obvious that it wasn’t your normal software freeze, it looked like how a brain aneurysm might feel like. The only choice was to cut all power and reboot. This kept happening over the following week, becoming more frequent, until the day where it had just had enough of the resusitation and just refused to boot.

Assuming it was a motherboard/graphics issue I needed to get something done rather quick as I was at the tail end of a big job and needed to finish what I was doing. I wasn’t panicing to much, and decided to take my hardrvie out and put it in my girlfriends macbook pro (I thought this would get me out of jail). I then added a new blank hardrive to my effected laptop and took it up to the local MacCentric shop to get a quote on a fix.

Inititally I thought I would just go in there and speak to a technicial who would say within 3 seconds of showing him
“Yeah mate its your core board, that’ll cost roughly $500 to fix”

But to my annoyance I was greeted by an ill informed secratary who made me fill out forms rather than ask a technican 2 meters away behind closed doors, if he could have a look at it. Late the next day I recieved a voice mail with half the news I’de expect.
“Your motherboard/graphics card are stuffed!” (yep I wish you told me that on the spot).

The other half of the news was, due to the fact the client has opened the computer, they have caused the hardware failure and instead of a wopping $1000 fee to fix it would be doubled to $2000!!!! What the F$%K! Is this some Apple policy? It was out of warrenty, I’m happy to pay for it to be fixed, but trying to blame me for breaking it when I opened it and doubling the charge… No way man!

Peeved off I went online (using my girlfriends laptop) and had a look at ebay for a similar replacement. Low and behold the same spec machine was selling for around $1200. Cheaper to buy a second hand one hey! However whislt looking I found a little chinese guy offering services to fix MacBook Pro motherboards for $250… BONUS, that’s what I wanted to see. I’m in the process of shipping it off stayed tuned!

Meanwhile back at the homestead, my girlfriends 13″ MacBook had to be hooked up to my BenQ 241W, I have had troubles with this monitor, shortly after I bought it in 2006. Initiall problems were the DVI connection spact out and it wouldn’t ‘detect’ any signal. This initially started from my MacBook Pro, but also was happening on my PC, so it wasn’t related to computer or cable. After spending a lot of time in forums ect, I came to the conclusion that the ‘firmware’ for that monitor needed to by updated, DOH.. What a hassle. I forgot about that and used the DSUB/VGA connection which continued to work. All up until now!

I plugged the 13″ MacBook Pro in, and for some reason I am now getting the same “issue” as the DSUB … “no signal detected”… urghhh! I wrote an email to BenQ, and 2 weeks later I am still to get a repsonse! In the meantime I went to the local Office Works and picked up a HP 23″LED for $226, BARGIN MAN!

I bought it home, unpacked it, realising the price reflected the build, eg no USB or HDMI connection and a crappy static plastic stand, but hey it’s so thin and light who cares!

So I was set up again able to work, with a borrowed laptop and a cheap LCD monitor which rocked! Little after half an hour of getting back into getting some real work done… PURPLE SCREEN OF DEATH, both screens went purple and nothing happend. Time to cut all power again and reboot! This time I kind of pretended nothing happened, and the problem seemed to stop, until my girlfriend came home from work and was doing some web browsing when the same thing happened. I immediately got blamed for stuffing up her perfectly working laptop, and it was now all my fault.

First things first I just went and did a system software update, and low and behold one of the fixes was for a purple screen of death on 13″ MacBook Pros hooked upto external displays. Cool, it seemed like I was clearing up all issues. I installed the updates and restarted. I just wanted to say that these upadates seemed to have done nothing except alternate between a purple and black screen! LUSH, maybe I need to buy a new MacBook Pro and Cinema Display, is that what they are trying to say?

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.

Grid Art for Typoart

I’ve just been developing some ideas for prints using FPDF to dynamically create the PDF’s. They consist of a grid of objects in these cases, letters and shapes, where each element can have alternate properties applied to them. The text based is great and things like poems would easily be incorporated, and give it meaning. All prints ratio/sizes can also be altered simply, so any size can be output.

TYPOART_LETTERS_1648_20101128202818

Above: A string or sentence with a message displayed in the middle, in this case fruits.

TYPOART_LETTERS_1648_20101128162613_fruits

The same example with different colours and grid size.

TYPOART_SQUARES_1648_20101128170352

TYPOART_SQUARES_1648_20101127011102

TYPOART_SQUARES_1648_20101127012526

TYPOART_SQUARES_1648_20101128190352_650

Examples of the dots in different combination