About Me

My photo
Derek lives in Wall Street, Lee-Over-Sands, St Osyth. A mobile and event software/product designer by trade - and is keen to improve things for all the local residents - and has lived in this idyllic location since 2009.

Friday, 20 August 2010

Flash Lite remote loaded .swf interactivity

Not sure if anyone has ever noticed this, but strange things happen with Flash Lite 2.1 when you try remotely loading a .swf with dynamic variable text fields.

If you export the seperate .swf as Flash Lite 2.1 - any parameters and variables calling values on the root of the main movie just don't work - also buttons don't operate in the seperate movie etc.

Exporting as Flash 5 results in a similar problem.

If you export at Flash 6 it does seem to function, well some parts do - buttons etc fine, but some parameters just don't change for some reason when that file is loaded in dynamically into the Flash Lite 2.1 environment - all variables and params that are referenced show "null", even though they might be targetted to:

_root.counter

Why would you need to do this I hear you ask... well I was trying to load seperately a readout debug style display, to save memory in my main application. Had to give up in the end because, although it saved a little memory, it made the tool uttely useless for diagnosing issues with the app and server!

Quite suprising this. I'll be glad to see the day when I no longer need to use Flash Lite, and we can export to full Flash 10.1 - although I still haven't read anything yet about how the new player handles mobile specific FSCommands, e.g. checking network status, triggering vibrate on the phone, etc.

Tuesday, 10 August 2010

Flash Text Field autoSize="center"

Had the usual problems with autoSize on fonts today in Flash Pro 8 and Actionscript 2.0. After making a text box react to content length and reposition itself vertically (I wish Flash could do that like DTP software does) using code, I found some text was always cut off at the end of the paragraph.

After some experimentation, I found the following solution: Applying a leading command in code sorts it out, width and wordwrap values obviously contribute. Hopefully the code below will help anyone else that has the same problem. The border command is useful to show whats going on with the size of the text box.


var my_fmt:TextFormat = new TextFormat();
my_fmt.leading = 0;
description1.setTextFormat(my_fmt);
description1.wordWrap=true;
description1._width=453.2;
description1._height=300;
description1.border=true;
description1.autoSize="center";

Thursday, 3 June 2010

FSCommands.. and Flash/Flash Lite export

Here's a weird thing I found today - if you have a Flash application, say originally built for Flash Lite 2.1 and you're suddenly asked to make it work on the desktop... The obvious thing to do is go to the export settings, change it to Flash Player 8 or whatever then publish.

What I found today is that ANY code on a given frame that has FSCommands on it halts code execution. So if for example you do the conventional thing and put all your Actionscript code on frame 1 - if there are FSCommand2s there - the whole thing just fails when compiled.

I tested this by putting a trace command in after the FSCommand after noticing the app just wasn't starting when exported to Flash Player 8 rather than Flash Player 2.1, which worked fine - a very odd thing indeed - and of course these weird findings are the main reason why I started this Flash Developer blog!

Friday, 14 May 2010

NaN errors

So much for modern "strict data typing" programming theory. I waste so much time debugging problems with scripts that are usually related to extracting data from XML, which is a string, then trying to turn it into a number using a pre-typed variable - only to find I end up with NaN.

Rubbish. Older programming languages, such as Atari Basic in my childhood had no such issues - they would throw an occasional "type mismatch" error if it went wrong or the data was unexpectedly a string instead of a numeric value. Of course that used to be fixed by using int(variable).

This modern approach fools the app and compiler into thinking everything is fine, but simply refuses to convert the variable properly, and populates it with the useless NaN value, which of course you can't do anything with!

This means a lot of value tracing in functions needs to be done to diagnose these problems  - then finally you can spot ity, and attempt various ways of converting the original values again until you get something sensible out of Actionscript.

Screw ECMA script conventions - more trouble than its worth.

Tuesday, 4 May 2010

dot and bracket scope notation

Every time I try and follow programming "best practice", which of course states that you shouldn't use the old fashioned eval statement (which supposedly is inefficient), I end up looking dumbfounded by someone's decision of how they implement syntax and code... specifically Flash Actionscript 2.0 bracket notation - which for a beginner or a seasoned experienced programmer trying it out for the first time, just doesn't make a lot of sense.

Ok lets say you have 10 identical items, placed on the stage using the Flash IDE and values in each "pre-populated" and you want to do something to all instances - say read off the values - obviously you use a loop and do this - so this is supposedly bad (eval) method....

items=10;
for (item=1;item
    theObject=eval("_root.field"+item);
    trace("item "+theObject._name+" has a value of "+theObject.text);
}

In bracket notation it would be:

items=10;
for (item=1;item
    theText=_root["field"+item].text;
    trace("item "+theObject._name+" has a value of "+theObject.text);
}

it works, but is it only me who finds the fact that there is no dot after the root command a bit odd?

common sense would make you thing it should be
theText=_root.["field"+item].text;

but no - another Actionscript oddity! I remember struggling with this years ago when I had problems using an eval statement inside a dynamic element - thankfully examples on the web rescued me at the time - so today after revisiting the technique again - I thought it was worth pointing out!

Friday, 30 April 2010

And so the Adobe Apple War drags on...

I'm going to put on my Nostradamus head and make a prediction. Apple will lose all market share and Iphone smartphone dominance by 2012, as people will migrate towards Google Android devices that support "the full web". The tech war between Apple and Adobe will be finally over.

The Ipad will fall aside in popularity like the Macbook Air as a nice bit of kit that opened up the market for better more open usable devices that fulfil real people's needs and desires for mobile computing, and not be another commercial model designed for the "proles" by Apple to line their own pockets.


Why do I think this? Well the tech journalists are usually a step behind us techies, and being an intermediary between us "Geeks" and the mass populace, they trundle in like tanks on the battlefield. I suppose in this ongoing war, us developers, early-adopters etc are the scouts, where the public are the infantry. The dozens of current articles by tech journalists about the spat between Apple and Adobe is starting to sink in with them - true there's a lot of rubbish journalism going on too, about how HMTL 5 will replace Flash (erm no, perhaps for video playback but thats it - Flash is sooo much more than just a YouTube video player!). The fact is most tech journalists being "media people" all have a Mac bias because their peers use them. The rest of us make other decisions with our hardware based on cost and performance, not style - its all about CONTENT.

However the tide of the battle is turning, as even these "Mac Fanboys" are slowly starting to see through the bullshit from Steve Jobs and his keynote speeches and see the real picture. Perhaps its their Itunes account statements as they realise how much Apple gets from them as they download the latest apps they'll never use again in a months time. Perhaps its because its the current tech media popular subject that gets people writing on an otherwise dull tech landscape.

Of course these comparisons to a war makes Jobs and the CEO of Adobe the Generals pushing the buttons and rallying the troops, but like a real war, well crafted political agendas and propaganda can fuel the cause and motivate people, but after a couple of years those troops will soon realise the cost of not seeing the bigger picture.

In this case its the amount of money they pay to Apple for content & applications, so while the "troops" and fanboys chew over the long-term reality of their sheep like movements, a lack of choice, censorship and big costs, the more enlightened of us are already three steps ahead through bitter experience or analytical projection and theories of how it will "play out" - and using other free alternatives.

On the free web.

Wednesday, 31 March 2010

Flash Help Woes

I discovered today after a bout of reinstalling everything onto my home PC that Adobe have finally switched off the "LiveDocs" on Flash Pro 8. What a disaster for anyone trying to learn coding with older editions of Flash.

Now, why on earth would you want to use such an old app I hear you ask.

Well its simple. I find Flash Pro 8 to be a nice tool. It does everything CS3 can, well apart from Actionscript 3.0 and exporting to Flash 9 obviously, but thats not the point in this case.

Many of the projects I work on don't need the latest cutting edge tech in the very latest Flash Player - and as I'm mainly an Actionscript 2 programmer who finds 3.0 as much of a handful to work with as the transition from 1.0 to 2.0 I really don't need any extras.

Over the years I've used various incarnations of the Flash IDE in my work with various companies - Flash 5 was pretty good as a tool, but I found Flash CS3 to be incredibly unstable, and CS4's lack of "in product" integrated help a real annoyance for me.

Additionally Pro 8 has a very good Flash Lite testing environment - whereas although the newer CS4 tried to do this better, I've found the security sandbox being applied in the test environment just doesn't reflect what happens on a real device, so again I now always use Pro 8 when I'm building FlashLite 2.1 content.

The real killer though is the help. If you go back and right click on an actionscript command in Pro 8 or even CS3, you get a lovely help window that just "works" and tells you what the IDE thinks it is.

CS4's environment appears not to have this tight integration, and attempts instead to load info from the web, which is a sensible idea in terms of updating entries obviously, so I understand the reasons Adobe have used, but the reality is that Adobe has never been any good at making easy to use comprehensive intelligently searchable documentation.

And until Flash Lite finally dies off (which remember 2.1 is the equivalent of the Flash 6 Player) Pro 8 is still a valid tool.

Groan :(

Thursday, 25 February 2010

A recent project of mine for Williams F1 has appeared on Twitpic/Twitter

Fab new business 2 business tool - our guests log in & can fi... on Twitpic

My company Red Digital built this for the Williams F1 team to use out in Barcelona at their final car tests before the racing season begins - essentially a RFID card based event registration and search tool to find info about attendees/delegates during events. It even has a nice photo-booth type picture feature so users can update the contact photo on each profile. This system was originally designed and built for the Barclays ATP Tennis tournament at the end of 2009. The frontend system is all built with my Flash coding of course, and the backend system created and designed by my colleague Swarvek Swiac.

This latest incarnation of the Delegate touchscreen kiosk features a multi-language feature for translating all the buttons / content into any number of pre-configured languages.

Saturday, 20 February 2010

Flash Case Command

Found something odd today, if you use the "case" command in Flash, you must ALWAYS put "break;" on the last line, otherwise, strangely the other cases defined below it actually get executed - which isn't the sort of logical effect you'd effect!

Thursday, 18 February 2010

Timeline frame movement oddities

If anyone has ever wanted a Flash movie to replay the code on the current frame in a timeline, basically its impossible, without mucking about with workarounds. This makes it worth mentioning in my Blog just in case someone is having trouble with this.

I've revisited this again for the first time in a year - although timelines are of course a throwback to Actionscript 1.0 techniques, its still the most efficient way of building items on a page, using timeline navigation methods to jump to a certain frame based on a button action, and of course that frame has pasted onto it all the items you want to appear, or not.

As well as the physical items on the stage, there is of course the actionscript code itself on the frame. Despite most current thinking which discourage usage of timeline based code, its still a very logical place to put it - as most applications are proceedural in nature - so its often still the most efficient way of making sure code matches visual objects at a certain part of your Flash program.

Where this falls down however, is where you want a frame to "re-execute" its code on that given frame. Why would you want to do this? Well the project I'm working on is a modification to an older app I built a couple of months ago, which is built with the method above. Now I want to force a language change using some Flag items - this means quite simply that the app needs to repopulate the page content when this happens. Of course there is also the background loading of XML files to achive this, but for the moment lets focus on the actual repopulation of your text fields, button titles etc on the current frame.

In this situation, the most obvious solution is to have the populate feature on the same frame to be activated based on the language change. Of course - this means that you may have built the whole page population methods on the timeline code.

This is where the old methods are problematic, as a command like this:
_root.gotoAndStop(this._currentframe)
won't work, you'd think it would, but no. A trace command will confirm that nothing happens. So the old workaround would be to add a blank dummy frame before each main frame in your Flash movie, then use:
_root.gotoAndStop(this._currentframe-1);
The playhead then definately moves, and the frame's actual code gets re-executed, in turn repopulating your objects on the stage.

Another approach is to put all your populate features in frame 1 into a function, then the Flag button press can call the function, irrespective of the above timeline execution issues. Of course your actionscript frame then also calls the same function as the timeline moves.

The downside of course with this is that it makes your code very hard to go through, because all the population routines are then seperated visually and structurally from where they are used, making updates harder, as you have to flick from timeline frame to frame 1's function definitions.

This is one of those odd situations where I thought it was worth pointing this out, because few Flash tutorials ever go into the actual architecture of building a Flash Application.

Friday, 29 January 2010

The Apple Ipad - what a suprise - no Flash support again!

I wrote this response on a blog page today and thought I'd publish it here on my blog.... Basically people were "slating" ;) Flash as a technology, and saying why do I care if its supported in my Ipad browser...

I replied....

Dont blame the toolbox, blame the craftsmen. You're comparing a web-browser with a programming toolkit - they aren't the same. A browser is designed to show a multitude of content types - thats it. If one manufacturer decides to restrict this, then you have to consider the commercial reasons why. The reality of all this is a hidden agenda. Its down to money and app sales. Apple get a hell of a lot of money in aftersales from its devices via the appstore. Why would anyone buy an app if they can go on a web-page and use a free Flash based one. Thats what all this Flash issue is actually about.

Being a Flash developer I have a broader experience of using Flash commercially - so I'm uniquely positioned to comment. You should have your opinion, but I think you need to consider the bigger picture - hopefully after reading this, you and others might see it a little differently.

People forget that Flash is a broad programming platform - not just something that you create banner ads with, and such implementations for advertising and rubbish music intro pages are only a small part of its overall capabilities and a very poor way of using the technology.

Its a software tool like any other - It can be used fullscreen as an app, or for small components on a normal web-page. Its main strength is its amazing array of rich media support. If you want to build a lush usable interface brimming with streaming HD video, animation, artwork, mp3 playback - nothing beats it for ease of development - thats why its so popular.

Try making a browser based game or rich content application with all that using PHP and HTML 5 utilising webcam functionality, HD video, animations and the sort of high quality typographical design that you'd see in a conventional magazine - very hard with other programming toolkits, but all possible with Flash to do yourself.

If you use anything else you'll be rebuilding the wheel all the time and need a massive team of people. Similarly you could also try Java, .Net or Silverlight and after you've built your web multimedia super app - but it would look like a web app like all the others with no professional design finess.

Then try the same thing in Flash - you'll soon see why its a world beater - you'll build it in a fraction of the time -And you have pixel perfect (and even fraction of a pixel accuracy on your creation) thats why its used by so many people.

I've never had Flash apps crash on me - I've been building them commercially for 10 years now - such things are always down to bad programming - or unstable hardware in a machine - or too many badly designed (written) Flash applications running on the same web page on a machine without much Ram.

So if you want to make your perfect home automation Ipad app yourself - good luck using Apple's programming kit - I know I'd rather build it in Flash in a fraction of the time and then wait for a decent tablet with full PC functionality and a proper browser that shows ALL web content Flash or otherwise. Which lets face it will happen over the next 6 months in the same way the Iphone reinvigorated the touchscreen phone market.

So putting a ban on Flash content is like saying "we won't allow you to watch .wmv videos." "divx" or worse "jpegs are not allowed".

Technology is about opening boundaries for displaying content to everyone, which is what a real fully featured web browser should do. It shouldn't matter whatever tools they wish to use to create their content.

Its like digital "free speech", why shouldn't you be able to see ALL web content - Java, Silverlight, Flash, Video, Pictures everything. I don't want companies forcing me to see and buy their stuff only.

This unfortunately is something Apple won't ever allow to happen, which in the long run is why they'll fail, because after the masses buy it, they'll get fed up with seeing "plugin not available" on their favourite websites and start liking the whole form factor of a tablet, and decide to go buy a more open PC or Mac based tablet instead in a couple of years.

Monday, 4 January 2010

FreeSpin3D for Flash CS3 & CS4

During a R&D session today I've been looking into something I discovered over the christmas 2009 break while being forced to watch parental TV choices - Having used computers and video games since the age of 12 I find passive TV as entertainment rots my brain after a while. Thank god for laptops and an empty mind numbed by TV, which started over the xmas break to make work seem appealing in terms of stimulation.

Once of the more interesting things I researched was a nice 3d plugin for Flash, which promises no more number crunching with tough 3d tools like Papervision, and having to produce raw objects with code... which to the layman is basically like pulling teeth to make a basic wheel, or making a human being after first having to mess about designing all the DNA first, rather than just animating a clay figure.

FreeSpin3d is a cool plugin to extend Flash with real 3d game object capabilities that even enables import of standard 3DStudio .3ds files (with a 4000 polygon limit of course). So the theory is that you can build your models, then import them for use, it can even do tweens on the timeline for more simple animations, or of course the more attractive feature I'd be using - proper Actionscript scripted control for game & interface UI interactivity... which in my industry is exactly what I've been after - having been stuck with previous plugins like Flashloaded's 3DEnvironment, which wasn't real 3d, just a collection of flat flash movieclips rotating in a psuedo3d environment (like Doom almost). You can see an example of my experiments with this here on my website http://www.derekfoley.com

At the moment I'm just reading about FreeSpin3D. Seems promising so far, but like FlashLoaded's documentation the lack of Actionscript examples for the features they provide in the simplistic component parameters as usual like 3dEnvironment really lets it down - meaning it potentially could be a tough learning curve - and a risk for me to get our company Red Digital to invest in as a tool to use.

But what other alternatives are around? Papervision3D, whilst being very good requires a computer science and mathematics degree to operate past the most basic examples, so this could be good for us. Like most plugins, its going to be hard to make it work with client requests e.g. "can you make it do this".

The only other alternative is to build my own raw 3d code with pure maths... so this is definately attractive as its a big time saver and could lead us to provide some nice interactive menus and interfaces in a real 3d interface for a change rather than how I've done it before for our "Du" and "Nakheel" Holopro interfaces.