2009
09.19

Recently my dad walked the “Camino de Santiago” and forwarded way points he had taken with his Garmin GPS with some notes about each point. I looked at the the Garmin output and it seemed I needed MapQuest to read them? Not too deterred and not wishing to wait for a copy of MapQuest I thought there must be a way to convert these files. A little bit of searching and I came across an amazing utility “gpsbabel”, that was able to cross covert many formats.

Once downloaded I then ran the following command:

gpsbabel -i gdb,roadbook -f sample.gdb -x nuketypes,waypoints,tracks -x transform,wpt=rte -o kml -F sample.kml

where sample.gdb is from the Garmin GPS and sample.kml is the output file.

Read More >>

Bookmark and Share
2009
06.01

augmented

Getting a little carried away, I wanted to get things moving from my previous post, so here are some augmented cubes. I’m still using the pattern described below.

draw this

Bookmark and Share
2009
05.29

Okay, just thought i would throw up a quick post on this. I challenged myself to get to grips with this relatively new technology people are trying out with flash – augmented reality! This uses a mixture of excellent as3 projects such as FLARToolkit, Papervision 3D and an excellent 3dsmax export script to xml.

Before you begin be sure to have a piece of paper, a thick black marker and a web cam!


augmented

First off, using your marker and paper, you will need to draw this shape:
draw this
make sure you keep them lines dark and thick!


Run the flash movie
and be sure to point the camera at your bit paper and you should see a plane!

Bookmark and Share
2008
12.07

Move your mouse from left to right and see the sun rise :)

Papervision Cube landscape

Bookmark and Share
2008
12.03

Experiments with Papervision 3D Great White…

F16 3D Papervision 3D

All points created by exporting from a 3d package, position objects (cubes) at these points. Using Tweener, then make ‘em move on the mouse over action. Dynamically add the text to a movieclip – add movieclip to moviematerial and apply to plane. Have the plane face the camera and stick in a couple of event listeners… et viola ;)

F16 3D Papervision 3D

Bookmark and Share
2008
10.05

Some things are better being tweened by hand, but imagine you want to run that tween and then call a function in the document class. There are several ways this can be achieved (check a movieclip’s progress on a timer / enter frame event or dispatch a custom event), but I like to keep it simple where I can, unless it is really necessary.

If we have a document class of type “TimelineClassCaller” and we have a movieclip carry out an animation and at the end we want to call a function within TimelineClassCaller, this is the type of call we would make:

TimelineClassCaller(parent).YeahMadeIt();

Where “YeahMadeIt” is the function within TimelineClassCaller. All we have done is cast the main movie before we make the call. Just make sure your pathing is correct (ie parent). As always it is easier to download an example to understand.

Bookmark and Share
2008
09.27

Presentation slides have been a feature of Flash MX 2004 and is still available in Flash 9 (but still used ActionScript 2) – so when designers see it, they think “Oh! oh! We could have Flash styled PowerPoint presentations…” and away they go. All great until they have finished hand tweening all the texts for 50 slides and then at the eleventh hour the client makes a whole load of copy changes and does not quite like the rate or tween effect on the slides.  Oh no, disaster!!!

To avoid such a senario and to keep transitions consistent, here’s a tip “extend the mx.screens.Slide” class and hold your core functionality here for things such as Text tweens and use simple calls within your slides to start your core functionality.

Okay, here we go – start of by creating a class that extends “mx.screens.Slide” :

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
import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
import flash.filters.BlurFilter;
import mx.transitions.TransitionManager;

class Presenter extends mx.screens.Slide {

static var timers:Array = new Array();
private var bf:BlurFilter;
// -- constructor
function Presenter() {
super();
bf = new BlurFilter(2,10,2);
FilterShortcuts.init();
}

function fadeBounceTexts(texts:Array):Void{
for(var n=0;n<texts.length;n++){
texts[n].tf._alpha = 0;
texts[n].t = setInterval(this,"fadeBounceText",(texts[n].d * 1000),texts[n]);
timers.push(texts[n].t);
}
}

function fadeBounceText(obj:Object):Void{
clearInterval(obj.t);
var of = obj.tf.filters;
var oY:Number = obj.tf._y;

obj.tf.filters = new Array(bf);
obj.tf._y = obj.tf._y + (obj.tf.textHeight * 0.8);
obj.tf._alpha = 0;
obj.tf._yscale = 80;

Tweener.addTween(obj.tf, {_alpha:100,_yscale:100, _filter:new BlurFilter(0,0,0), _y:oY, time:0.7, transition:"easeOutBack"});
}
}

In the code above I have used Tweener, no point in reinventing the wheel.  So when I call the function “fadeBounceTexts” from each slide, then this will start the text effects:

1
2
3
4
5
6
7
8
9
on(reveal){
_parent.fadeBounceTexts([
{tf:t1, d:1},
{tf:t2, d:1.2},
{tf:t3, d:1.4},
{tf:c1.t1, d:2.2},
{tf:c1.t2, d:2.4}
]);
}

Where “tf” is the instance name of the dynamic textfield and “d” is the delay before the Tween should start and this is all started when the slide is revealed, hence “on(reveal)”. Anyhow, enough gibber jabber, here is a rar file with it all in (and a little extra!)

download

Bookmark and Share
2008
05.26

AS3 simple custom event example

This is a consise exmple of how to create a custom event in ActionScript 3. Firstly, create a custom event that extends Event, here this is called “SimpleItemEvent”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package{
 /* really simple event examlple */
 import flash.events.Event;
 import SimpleItem;

 public class SimpleItemEvent extends Event {
    public static const COMPLETE:String = "complete";
    public static const READY:String = "ready";
    private var _si:SimpleItem;
    public function SimpleItemEvent(type:String, si:SimpleItem)  {
       super(type,true);
       _si = si;
    }
    public override function  clone():Event  {
       return new SimpleItemEvent(type,_si);
    }
    public function get simpleItem():SimpleItem  {
       return _si;
    }
 }
}

Now create a somthing that uses the custom event class above, in this example the class SimpleItem uses a timer to trigger a custom event.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package
{
  import flash.display.Sprite;
  import flash.utils.Timer;
  import flash.events.Event;
  import flash.events.TimerEvent;
  import SimpleItemEvent;

  public class SimpleItem extends Sprite{
        private var timer:Timer;
        public function SimpleItem(){
        }
    public function start()  {
         timer = new Timer(4000,1);
         timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
         timer.start();
         dispatchEvent(new SimpleItemEvent(SimpleItemEvent.READY, this));
    }
    private function timerComplete(e:TimerEvent){
         dispatchEvent(new SimpleItemEvent(SimpleItemEvent.COMPLETE, this));
    }
  }
}

Finally create we use a SimpleItem in our code (this could be in our code behind of our FLA), and add listeners to it’s events.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package {
   import flash.display.Sprite;
   import SimpleItem;
   import SimpleItemEvent;

   public class Simple extends Sprite {
     public function Simple()     {
       var si = new SimpleItem();
       si.addEventListener(SimpleItemEvent.READY,traceReady);
       si.addEventListener(SimpleItemEvent.COMPLETE, traceComplete);
       si.start();
     }
     private function traceReady(e:SimpleItemEvent):void  {
       trace(e.target + "ready");
     }
     private function traceComplete(e:SimpleItemEvent):void     {
       trace("complete");
     }
  }
}

download the example.

Bookmark and Share
2008
05.17

I couldn’t find a complete tutorial online on how to do this, but only partial solutions, so here is a small easy to understand example on how to load an external SWF and use it as a library in ActionScript 3. This is really good if you are using Flex to develop your Flash project – which is a great way to develop BTW. Also, if you wanted to break down the project and have others work on the presentation items, while you get on with the code.

For the purpose of this, we will stick to using Flash  - firstly create a flash file open an Flash file (using Flash) and create a Movie Clip called “Tone” and then from your library right click on your Movie Clip and click on Linkage and check the option “export for ActionScript” the class name will be “Tone”, leave all other default settings (you should see Tone extends flash.display.MovieClip) and click  “ok” . Also, please note, you don’t have to have your Movie Clip placed on the stage. Save this file as “Assets.fla” and build to create “Assets.swf”.

Next create the “AssetsLoader.fla” and give this a base class called “AssetsLoader”. Open a new ActionScript file and call this “AssetsLoader.as” (the code behind). Here is the code – which is pretty self explanatory:

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
package{
 import flash.display.Sprite;
 import flash.display.MovieClip;
 import flash.display.Loader;
 import flash.net.URLRequest;
 import flash.events.Event;

 public class AssetsLoader extends Sprite{

  static const ASSETS_FILE = "Assets.swf";
  private var assetSwf:Object; // this is our SWF loaded into a LoaderInfo Object

  public function AssetsLoader():void{
   loadAssets();
  }

  private function loadAssets():void{
   var request:URLRequest = new URLRequest(ASSETS_FILE);
   var loader:Loader = new Loader();
   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, assetsLoaded);�
   loader.load(request);
  }

  private function assetsLoaded(e:Event):void {
   assetSwf = e.target; // assetSwf if loaded and ready
   exampleOfHowToShowAsset();
  }

  private function extractAssets(ref:String):MovieClip{
   var MovieClipItem:Class = assetSwf.applicationDomain.getDefinition(ref) as Class;
   var mc:MovieClip = new MovieClipItem() as MovieClip;
   mc.gotoAndStop(1);
   return mc
  }

  private function exampleOfHowToShowAsset():void{
   // finally we grab the MovieClip
   var mc:MovieClip = extractAssets("Tone");
   addChild(mc);
   // let's just center stage it!
   mc.x = .5 *(stage.stageWidth - mc.width);
   mc.y = .5 *(stage.stageHeight - mc.height);
  }
 }
}

And just to make sure it works here is a RAR file with it all in.

Bookmark and Share
2008
04.29

If you are thinking of remote network storage for the home, then you should definately consider a Linksys NSLU2. This device can be purchased for under £60 and simply plugs into your router, which doesn’t need to be a Linksys router – but you will need a spare RJ45 slot. The NSLU2 enables connection of 2 external USB 2.0 storage devices, so hooking this up to a 500GB freecom drive was a cheap solution for network storage.

I also had an old Dell Latitude C600 kicking about with Windows XP, but running really slowly – so I tried sticking on Xubuntu 7.10, the light version of the Ubuntu Linux operating system. Unfortunately, although it comes with Samba, it was not straight forward to connect to the shared network drive and have this as effectively a mapped drive. So I had a go with Ubunto 8.04 and bingo – dead easy, with a little networking know how.

So after managing ot connect Ubuntu and xp to my drive, the only issue was with my Vista laptop… this was not easy and took some searching. Sometimes it would connect and then disconnect – a little odd when I was using the Vista system to configure the LSNU2. Eventually I found out that Vista is more secure than previous versions of Windows and as such I had to make a change to the network security policy.

Start, Run, secpol.msc.

Under Local Policies > Security Options

Change the value of “Network Security: LAN Manager authentication level”
from “NTVLM2 responses only”
to “LM and NTLM – use NTLMv2 session security if negotiated”.

Then mapping the drive worked as expected.

Bookmark and Share