06
Jun

SWFAddress and a tip

Working on a revamp of a website, I decided to try out SWFAddress to make the back button work instead of a hand-rolled solution…

I managed to get this up and running really quickly, which was nice, but then I spent 2 hours working out why it no longer worked when I integrated the SWFAddress into the site…

The Flash bit worked okay - change something and the address bar got updated, but the back button never worked - or did not send any events back to Flash.

2 Hours later, after stripping my code back, I found the problem:

If you are using SWFObject, the javascript for this needs to be included before the SWFAddress javascript. Doh!

Apart from that small hiccup, it’s nice and fairly simple to use…

30
May

I won something!

I received a cool poster through the post today, courtesy of Ethan Eismann, who works for Adobe.

http://hello.eboy.com/eboy/2008/02/25/poster-for-adobe-air-launch/

Ethan ran a mini-competition on his blog asking for the best comments on “optimisation” and I got an email a few days later saying mine was the best out of 4.  I had not realised it was a competition I was just having a slightly sarcastic rant on a pet subject of mine :)

Anyway, it made my day and I have a limited piece of artwork by Eboy now too!

28
May

regular expressions…

Tip of the day for Dreamweaver users.

If you are doing a search and replace for ellipses with the corresponding HTML entity - … - remember to turn off the “Regular Expressions” check box, especially if you have selected “Entire Current Local Site.

Search & Replace

Otherwise your computer sits there and starts making pretty patterns and if you go and make a cup of tea, it might make it through your entire site.

Search & Replace 2

16
May

SAS SOS

Surfers Against Sewage - Save Our SeasI finished a big project last week for Surfers Against Sewage called Save Our Seas.

This is another free educational resource like Operation Beach Clean which I had done previously.

Anyway, this time I did some animation myself and also re-used part of the intro from OBC, adding some extra audio and lip-sync’ing to this.

The Flash is a bit more modular this time, so we can easily create new content and add it to the XML sitemap to be loaded in. It still runs in AS2 as it borrows some code from the OBC project.

Some cool stuff which helped a lot: the XPath implementation from XFactorStudio, Jobe Makar’s Wordsearch game from Flash MX Game Programming Demystified was ported to AS2 and I used the Tween Lite package for the first time when the ripple transitions started slowing everything down - nice and simple. I also had some great help from the FlashCoders mailing list with some tricky problems, cheers guys.

Anyway, check out the finished project and if you know any teachers who might like it, let them know too.

http://www.sas.org.uk/education/sos/

Tip - don’t launch PDF documents as a URL in Firefox, Acrobat Reader keeps hanging the browser for some reason…

Here is some code to help:
Quick Code


private function _showPDF(_pdfURL:String):Void {
//use JS to pass in the browser variable to Flash: - http://www.quirksmode.org/js/detect.html
 
var browser:String = String(_root.browser).toLowerCase();
 
if ("firefox" == browser) {
_useDownload = true;
}
if (true == _useDownload) {
var fileRef:FileReference = new FileReference();
if(!fileRef.download(_pdfURL)) {
trace("Failed to download.");
}
} else {
getURL(_pdfURLl, "_blank");
}
}
18
Mar

Adobe - Make Some Noise

Adobe, MAKE SOME NOISE

Just read a post by Andre Michelle a guy who has done some amazing stuff with sound in Flash. Anyway, he is asking for Adobe to address a serious issue that is threatening to break a lot of sites that people have done trying to work around Adobe’s crappy implementation of the sound API in the Flash Player, so I am putting up his widget in support and adding my £0.02’s worth.

For a long time I have wondered why Adobe have not paid the same attention to the sound side of Flash than they do with the visual side - in Flash 8 they gave us Bitmaps and Filters to mess with these, but no access to the sound API beyond panning and volume. With ActionScript 3 came a leap in the speed acheivable for applications, but no major improvements in the sound API beyond compute spectrum - which everyone can now use to make visualisations of soun, great, but I want to play with the sound please…
Fortunately Andre & some other people found workarounds to create sound on the fly in the Flash Player. It takes some interesting ActionScript hacks to do this, but they made some really good real-time music stuff with it. http://code.google.com/p/popforge/

http://www.flashbrighton.org/wordpress/?p=9

Now I think Adobe understand that music is an important part of the “experience”, so why they don’t make it easier for people to play, when they have done lots of the hard work with bitmaps, is beyond me. They really should be taking the stuff that people like Andre have done on board and realise that giving us tools to play with sound is something that would open up huge avenues for creativity in Flash…

Manipulating bitmaps is done in 2 dimensions as opposed to working with sound, which only requires one dimension, so the processing requirement for sound is usually less - depending on the complexity of calculations for effects. This should be a no brainer Adobe - are you tied down by some dubious industry patent bollox or is there something else you are not telling us? Maybe they are all tone-deaf with extremely acute visual acuity to compensate, because that’s the impression I get from the apparent bias towards visuals.

So what do I want in the Flash player:

The ability to apply filters to a sound channel ~ adding filters to a movieclip.

The ability to grab the sound data and do wtf I want with it ~ grabbing bitmap data.

Midi control built into the Flash player please.

Maybe a MOD player - that would make games a bit more retro sounding :)

I have asked them for this, if you want it, fill in the wish list…

http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform


15
Mar

Flex font embedding preloader gotcha

I just ran into a frustrating problem with Flex using embedded fonts and a custom preloader…

I have been working on a small app, was ready to upload it all the other night then tested it again and noticed my fonts were not working properly - they had previously been fine.

It was really wierd, the bold version of my font was fine, but where I was using the normal weight typeface, my character set was limited to a few characters:

“adgino0123456789L.”

I tried changing the font I was using and embedded a different font and everything was okay - wtf?

I spent about 2 hours fiddling round without any luck and was about to change the font I was using permenantly because it seemed that Flex was having problems transcoding all the glyphs I wanted to use in my project - time for a break.

Sitting down and feeling refreshed, I noticed a strange thing about my characters - look again and see if you can work it out:

“adgino0123456789L.”

Still no wiser (it’s an anagram)…

Oh b****r, it says “Loading.”

Guess what, the last thing I had done before uploading was tweak my custom preloader for the project to display the % loaded.  There are a few useful tutorials about doing a custom preloader for Flex:

http://www.onflex.org/ted/2006/07/flex-2-custom-preloaders.php 

http://www.bit-101.com/blog/?p=946

http://jessewarden.com/2007/07/making-a-cooler-preloader-in-flex-part-1-of-3.html 

Unfortunately by making my preloader use dynamic text, I had also embedded the font in the SWF file.  This overrides Flex’s embedding of the font - not sure why, I guess the font in the preloader is “loaded” before the main application fonts, so Flash Player thinks it is already there - what a nightmare.

So, beware if implementing a custom preloader - don’t use the same fonts as you use in your app, or embed all the characters you are going to use, which defeats the object of having a preloader if you ask me…

Nasty, on further reading, it seemed that Jesse Warden has also run into the same problem…

 http://jessewarden.com/2006/12/integrating-a-flash-interface-into-flex-2.html

15
Mar

Creative Britain…

I have just been reading the Guardian’s article about the government via Ethan Eismann’s blog and here is my impression…

Funding for creative enterprises is pretty good for some areas in the UK. Across the rest of the UK, the “arts” receives lottery money and other funding, but probably not as much as some of the people would hope for - is it ever enough?

The area I live in received large amounts of money for lots of projects, not just creative  ones, under the EU’s Objective One funding.  This is changing in 2008, but more money will be coming in http://www.objectiveone.com/index.htm

With Objective One a lot of money has been funneled into generating new industry streams and the creative industry has been a major recipient with numerous organisations offering grants & funding for the creative industries - for example, some “funding funnels”:

http://www.flickernow.org

http://www.creativeskills.org.uk

One issue I have with the Objective One approach is that it is very much “gravy train” for a large amount of middle-class people and I feel that a lot of money does not trickle down to those who need the most help, instead they are patronised by various projects that often only skim the surface.  However, creativity is only recently becoming a recognised way of making money rather than something to take up your spare time -whether this is bad or good is a topic for another time.

It is nice to see that the government has recognised that creativity is such an important part of education, if for the wrong reasons.  Their pledge should hopefully help to counter a worrying trend in education that has seen timetables drop many creative subjects and reduce the time devoted to others in favour of science, maths, business and things seen as useful for making money.  Having worked in creative projects with schools I found it very frustrating that the only time some kids got to do creative stuff was outside school time, so if the government is not spinning us a big line, we will hopefully get some cool stuff happening again. This should also please the teachers who are fed up with the governments “measure everything” approach to education which has made lessons driven towards passing the measurement criteria applied to schools rather than making sure kids get an interesting and well rounded education.  Finally teachers may be able to get a bit more creative with their lessons - which will be a welcome break from the “Teaching for SATS” culture that seems rife in schools at the moment.

So, we will probably be seeing more projects for the likes of Creative Partnerships, Youth Music & other organisations who try to promote creativity for young people. This in turn is good for me, because I like doing projects with young people that gets them being creative… http://glenpike.co.uk/portfolio/automaton.htm

06
Mar

Quick and dirty Flex buttons with separators

I have been trying to get Flex separators between my buttons in a Repeater tag as I did not want to use the LinkBar. I was having trouble trying to replace the Flex separator one with my image and it was getting stretched by the link bar and looked rubbish, so I looked around for a hack to mess with the repeaters and found Peter Elst’s post about working with the Repeater.

Here is a quick and dirty way to put a separator image between your buttons and hoik (remove) the last one out…

MXML for a simple repeater below:
Quick Code


  <mx:Repeater id="navButtons"
    dataProvider="{navData}">  
    <mx:Button id="btn" styleName="navButton"
      click="navClick(event)" label="{navButtons.currentItem.label}"/>
    <mx:Image id="separator" source="embedded_assets/menu_separator.png"/>
  </mx:Repeater>

Now you need to add in a function to remove the last separator image - you only want them between the buttons right?

First add a function that will handle this - easy, you access the thing you want to mess with as an element in an array - the array name is the id of the element you created in the Repeater:

Quick Code


private function removeLastImage():void {
navBar.removeChild(separator[navData.length - 1]);
}

You also need to put in a call to the removeLastImage function somewhere in your component. Mine was called from the creationComplete handler - here is the whole component.

Quick Code


<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
  xmlns:skins="skins.*" creationComplete="removeLastImage()">
 
  <mx:Script>
    <![CDATA[
      import mx.collections.ArrayCollection;
      
      [Bindable]
      public var navData:ArrayCollection;
      
 
      private function navClick(event:Event):void {
        trace("navClick " + event.toString());
      }
      
      private function removeLastImage():void {
        navBar.removeChild(separator[navData.length - 1]);
      }
    ]]>
  </mx:Script>
  <mx:Repeater id="navButtons"
    dataProvider="{navData}">  
    <mx:Button id="btn" styleName="navButton"
      click="navClick(event)" label="{navButtons.currentItem.label}"/>
    <mx:Image id="separator" source="embedded_assets/menu_separator.png"/>
  </mx:Repeater>
  
</mx:Canvas>
03
Mar

PhotoShop Strikes Back

I wrote last week about problems with Adobe’s CS3 trial messing with my file associations.

Well guess, what this has caused bigger problems this week, time=money-wasting problems…

Apparently editing files in PhotoShop CS3 and using the backwards compatibility option when you save, does not guarantee you will be able to open them in an old version of  PhotoShop.  I learned this painfully, when I edited a couple of PSD’s in CS3 (after double clicking to open them, grrrr) and then saved them without worrying about the consequences because the little box tells me I should be able to open the files in older version.  Only this is not true.  When I try to use PS 6 to open my files again, I get the ominous and much discussed “not enough memory (RAM)” error message when I try to open them in PhotoShop.

This means I have lost several hours of work, because Adobe saw fit to dick with my registry.  Backups you say - well I have been backing up, but as this was the start of a project, files did not get put into version control until the end of the day.

I reckon this is some sneaky bastard trick to make me upgrade.  If it’s not, it still makes me angry.

Thanks Adobe, you have cost me at least the price of PhotoShop in lost work.  Guess where I won’t be spending that money.

F***ers.

28
Feb

Grrr buses

Having lived in the city and experienced decent transport, one of the things that really bugs me about living in Cornwall is the bus service. I try to use public transport to get around, but about 30% of my journeys are not smooth and the inconvenience + cost of going anywhere on the bus vs the time taken does not make it worth me trying, let alone justify families using public transport rather than cars.

Until recently there were 2 major bus companies down here, Truronian and First Bus. The former has just been bought by the latter, which means that First Bus pretty much have the monopoly down here - that’s bad as their service is pretty poor most of the time.

Where I live now, we get buses going East about 2 times per hour, up until about 6pm, in the evenings, it gets a bit silly - there is a 31/2 hour wait to get home if you go to St Ives on the 7:30 bus.

To travel into Truro, like I did this morning, takes 1 hour 20 minutes by bus - 20 miles by road, 30 minutes by car, 20 minutes by train. 2 buses an hour is okay, if they turn up, but like I said about 30% of my journeys do not go so well: 20% of the time, the buses don’t arrive, 10% of the time they are very late. The route here to Truro is one of the main routes in the county, but the time between buses gets even longer if you go off the beaten track. If your bus does not turn up in Mullion, you can have a wait of up to 2 hours ’til the next one - WTF!. In the city, it did not matter if a bus did not turn up - another would in about 10 minutes, but it’s impossible to get to work on time with things like this happening, a lot.

What comeback do we get? None, which is why having competing bus companies gave you a bit of a chance, (although, only some routes where covered by both), so you could take your pick. This will now change and the bus company don’t seem to have to answer to anyone, which is bad. I don’t believe having a monopoly on the buses in an area is bad - it used to work fine in Edinburgh with Lothian Buses, but where the service is pretty spartan already, it sucks big time, particularly when you consider that it costs £5.60 return to Truro as opposed to using about £5 in petrol for the trip. So even with one person travelling, it’s almost cheaper by car if you factor in other running costs (similar for trains too) and that should not be right in this day and age.

So what do we do? Well, it would be nice to see a lot more local people sharing lifts & using public transport down here, which would ease the burden on the roads in the summer, but that’s not going to happen without a big shift in ideologies, so until then we just have to keep trying to catch the bus, put up with the crap service and rubbish customer relations. For me, I may have to pass on the cost to clients in order to cover the lost time, because unless they choose to meet virtually, then travelling to see them takes too much time.  Taking 3-4 hours out for a 1 hour meeting costs a bit more than £5.60 at my rate.  Even though these may lead to more work, it eats too much out of my day for it to be cost-effective.

Grrr





About

I am a web-monkey / computer junky living in Cornwall and occasionally I tear myself away from my computer to go bodyboarding and playing in some of the beautiful places near my home. I love doing Flash and ActionScript stuff and feel that there needs to be more of this going on around here, so someday, if I have time, I may get my goddamn user group started. I may occasionally make controversial comments here about work, life and such, but this is essentially a diary and we still have the laws for a free press. Feel free to go somewhere else if you don't like it, or maybe comment if I dare turn them on. If you are: * my Gran, then sorry for swearing * my Mum, stop reading my diary dammit * everyone else, then get out more
Adobe, MAKE SOME NOISE