creacog

Product Owner/Manager; Digital Project Manager, ex-Developer Available for Product Owner roles
Product Owner/Manager; Digital Project Manager, ex-Developer Available for Product Owner roles

strange stage-size problem, but only in ie6

I’ve just been working on an small piece of pure ActionScript3. Essentially the migrating from the large horrible Twitter Widget that I had in the right column, to the text-only representation now overlayed on the header image above.

I use SWFObject to embed the SWF in the page. I set the dimensions of the SWF to 780×45. Within the main function of the SWF I prevent the stage from scaling and set it to align top left. I then use the stage.stageWidth and stage.stageHeight properties to draw a semitransparent background within which to position a TextField then trot-off to get the Twitter feed.

All is well on Safari and Firefox. But when I test on Internet Explorer 6, strange things happen. The first time a page loads, it displays ok. But reload the page, or navigate to another within the blog where the SWF is loaded from cache, and the layout is quite messed up. Testing showed that this is because the stage’s stageHeight and stageWidth are returning value 0 in this circumstance. Further testing shows that although the stage’s initial size is 0x0, it does get resized at some point.

The solution I’ve implemented is to listen for and handle resize events. Mildly frustrating as I didn’t plan on dealing with resize. The only reason my application is structured like this is to allow the SWF to adapt to the dimensions set via SWFObject. Not to allow the SWF fluid resizing through it’s life.

Simply moving the positioning code to the resize handler solved the ie6 problem, but for the other browsers that render at the correct size from the off, no resize event fires. So from our main function we have to put a manual call in to the resize handler (with null as the argument), and then only modify positioning if the stage dimensions are something other than 0x0.

Posted by creacog in ActionScript, CS3, 3 comments

creative-cognition builds a flash game

The makers of StarCraft need have no fear, but I finally got around to implementing my first Flash based game. A simple retro tennis style game, built as a brand building exercise and integrated by my client into a Facebook application.

CVL-Tennis thumbnail

This was a fun project to work on and programme. To initially build a pure AS3 application, and to later integrate that with Flash CS3 when the real graphics were ready.

It was also an exercise in use of MVC. Since we did not use PureMVC nor any other other framework, using this pattern loaded the initial development with some seemingly onerous complexity. However the time invested later paid off in allowing easy adaptation of that game engine to the various graphics and controllers tried through testing.

Some links:

Posted by creacog in ActionScript, Adobe, CS3, Flash Platform, Flex, Projects, Work, 0 comments

thanks to Adobe and Sean McSharry for tonight’s poker

I’d never played poker before, and thoroughly enjoyed it, while it lasted. There where 8 tables of 9 players. I was on Table 8. Eight believed to be a lucky number by the Chinese. The first 3 knocked out of the tournament were all on my table – including me! 🙁

loser tee shirt

So now the proud owner of a rare (1 of 5) “Poker Tournament I : Loser” tee shirt. But a really fun night just glad it wasn’t real money. Roll on the next one.

Posted by creacog in Adobe, 1 comment

a shout to my corporate site

creative-cognition

After a number of years of content-neglect, and problems of client confidentiality, I’ve finally got around to posting up a case-study covering some simple Flash based work samples. (Note: work samples, not code samples). Flash platform case-studies will be being posted more regularly here on in. But kicking off now with three bespoke user-interface elements : A special accordion, a minimal bouncing menu and a HTMLtext text builder.

The user-interface elements presented may not set the artistic Flash world on fire, but each represent very specific design solutions. They were also interesting and fun to programme.

Bespoke user-interface elements.

Note: creative-cognition ltd is no-longer trading

Posted by creacog in ActionScript, Flash Platform, Work, 0 comments

Flash CS3 : finding the gradient transform tool

I’ve just been driven up the wall trying to find the Gradient Transform tool. 🙁 Most of my work in the IDE is arranging libraries of assets supplied by others, for coding. So for drawing I am a newbie.

I needed to make my own block with a gradient. I knew there was a tool for modifying one once created, but I couldn’t see it in the tool panel, I couldn’t find an option for it in the Modify menu, and the Help page simply referred to it in the Tools panel.

Loation of the Gradient Tool

I eventually found it hidden behind the Free Transform tool : you have to click-hold Free Transform to reveal the Gradient Tool. I still haven’t found it in the menu hierarchy. I have posted comment to livedocs, but thought it worth posting here in the meantime.

Posted by creacog in CS3, Flash Platform, 14 comments

sensible(ish) code print from flex builder (on MacOS X)

Continuing the theme of occasional Flex Builder hints and tips…

Occasionally I need to see code printed on paper. Unfortunately the printing capabilities of Flex Builder, or more specifically in this case, Eclipse, are a bit messy…

  • the font is huge, and only 49 lines fit on an A4 page
  • if you have a background colour set to your code window, it gets printed – decimating your ink-tanks
  • printing is a two dialogue process – you have to go through Page Setup each and every time.

Of course in the actual Print dialogue, you have the standard Mac ability to change the page layout, paper handling etc, and save that detail in a pre-set. However…

The key things I want to achieve is to print 2up full duplex black and white, which gives me four pages of code per sheet of A4, and with a slightly smaller font size I get a more respectable 68 lines of code per ‘page’.

However I’ve found the following approach, once set-up, a little more convenient, and becomes a one-click print…

The Mac has a GNU enscript installed which converts text files to PostScript to send directly to CUPS. In my case I had to update the old Gimp-Print drivers to the current Guten-Print drivers in order to achieve duplex printing.

More information on Guten-Print and access to the drivers on SourceForge. The DMG contains good documentation and a simple package installer.

Once the new drivers are installed, and I’d recommend a new, additional, print queue be set up with appropriate defaults for your code printing, you need to set Eclipse to run an external script to print the currently active code window. From the menu: Run > External Tools > External Tools…

  • Name: enscript
  • Location: /usr/bin/enscript
  • Arguments: -2rT4v -DDuplex:true -diP5000 ${container_loc}/${resource_name}

Obviously you’ll need to tweak the arguments according to your personal print configuration.

External Tools Dialogue

Posted by creacog in Adobe, Eclipse, Flex, Flex 2, Flex 3, Mac OS, 0 comments

option up and down

Kicking myself for not finding these sooner so, posting in line with the current trend of highlighting little Flex time-savers. Two ActionScript editor short-cuts (and probably apply to any Eclipse code editor?)…

1. Select some code in the ActionScript editor and press Option-Up or Option-Down, and the selected block of code gets moved accordingly. Or just place the cursor on a line if you only wish to move a single line. Saves a load of messing with Cut-Paste.

2. Need to duplicate a line? Place the cursor at the start of the line and press either CMD-Option-Up or CMD-Option-Down, and the current line (or selection if you have one) gets duped above or below the cursor respectively.

With either of the above, if you make a selection, you don’t need to be character accurate. The movement is applied either to the line touched by the cursor, or the lines touched by the selection. i.e. If you select part of a line, the whole of that line is included in the selection to be moved.

Posted by creacog in ActionScript, Eclipse, Flex, Flex 2, Flex 3, 1 comment

flex, mac, external browser

Ted Patrick has been quite prolific of late at publishing little productivity hints and tips. I think this one from a couple of weeks ago is worth echoing and noting the workaround for the problem it raises on a Mac.

We are setting up Builder to launch the help pages into an external browser. The key advantage of which being that the code samples can then be copy/pasted. On a Mac there is a recognised bug in eclipse that if you choose Firefox as the external browser, and it is NOT your normal system default browser. Basically Eclipse attempts to launch a second instance of Firefox which will generate the “Only one copy of Firefox can be open at a time” dialogue…

Firefox close dialogue

So to get around this, you have two options.

Option 1, if you have Firefox as your default browser for the entire system, simply choose “Default system Web browser” in the Eclipse preferences panel.

Option 2, if you want to keep something else set as your system default browser e.g. Safari, but would use Firefox for displaying Flex Builder help, you need to either edit or create a new external browser entry using a command structure as per comment 5 on the eclipse bug sheet. Essentially the following settings work…

  • Location: /usr/bin/open
  • Parameters: -a firefox %URL%

Flex Builder > General > Web Browser >Edit external browser

Posted by creacog in Bug, Eclipse, Flex, Flex 2, Flex 3, Mac OS, 1 comment

flash, flex and vice versa

I have a small AS3 project where I need to keep the SWF quite small. I really want to use the Flex Builder environment to do the coding, and ultimately produce a target or targets suitable for inclusion both in Flash and/or Flex projects.

Two very helpful posts of the last couple of days with respect to setting up a suitable environment:

Posted by creacog in Adobe, CS3, Flash Platform, Flex 2, Flex 3, 1 comment