Simple Flash to browser console logging

If you are like me, you like to be able to trace out commands etc from Flash into your browser container. I generally use FlashTracer on Firefox or a more full featured debugger.

However, sometimes I simply want to trace elements into the console of either Safari or Firefox. This is as simple as using ExternalInterface and a small javascript method that takes a single parameter and writes it to the browsers console, via console.log(). Which can then be inspected via Safari’s debug panel or within Firebug on Firefox. And yes, I realise I could use Flashbug or something similar, but to be honest, I hardly ever use Firefox, hence the desire for something that works in Safari.

Simple example file is attached.

Source files
Simple Flash logging (98)

FlashPress 0.6 Released

OK, I finally had some time to tidy this up a little.

So, here it is, FlashPress 0.6.

Supports both ZendAMF and AMFPHP. Supports Wordpress 3.0.

This version of FlashPress uses the Wordpress API rather than directly working on the wordpress database. It also includes write support for some methods. This is experimental and you should test this fully before deploying it. There is also an experimental search method, that will probably change internally as I get my head around the SQL required.

This is a beta, so let me know how you get on with it, and post any bugs etc so I can look into them.

The example file is minimal, with just a listing of the various method calls and their parameters. As I get time (unlikely) I’ll add to the examples. I’ll add the method lists to this post as I get some more time.

Note: I’ve tested this release against Wordpress 3.0, and it seems to be working fine. Let me know if you enounter any issues.

Source Files
Flash Press 0.6 (173)

Actionscript 3 watermark image class

A recent project needed a watermark added to any images that could be downloaded off the site. Originally we used a PHP solution, which worked fine. But I wanted to do it inside of Flash and use the save methods in FP10.

So, I wrote this simple little class to adding a water mark to a display object, and the returning that display object as bitmapdata for say, passing to Adobe’s jpg encoder.

Maybe someone will have some use for it?

Source Files
Here is the relevant source file; Watermark class (331)

By downloading, you agree to the terms of use, outlined here: http://www.blog.noponies.com/terms-and-conditions

Dependencies
Zero

Actionscript 3 RSS Reader Demo

I made this as a simple test for RSS parsing for a job a little while back, and it never was used for anything, so I’ll post it here as it may be of use to someone.

Its a simple RSS parser that uses the RSS and Atom libraries http://code.google.com/p/as3syndicationlib/ to handle parsing its RSS feeds. Although parsing RSS is trivial, I wanted to use a provided Adobe library for the hell of it.

The file is not overly documented and uses my scrolling panel and scrollbar classes to handle scrolling the RSS items.

An example is below.

The Flash plugin is required to view this object.

Source Files
Here is the relevant source file; Rss Reader Demo (357)

By downloading, you agree to the terms of use, outlined here: http://www.blog.noponies.com/terms-and-conditions

Dependencies
Zero

Using Asdoc under OSX

At work I’m without my install of Flex, and its various niceities like ant builds for creating ASDoc documentation for my various classes and work projects.

In the past I’ve messed around with the commandline controls for creating ASDoc documentation, but without a great deal of success.

However, at work today, I decided to get it working and create some documentation. There are a range of options for creating asdoc documents on the mac, I’ll list them below.

1 / Command line. Downloading the Flex SDK and kicking it command line style.

2 / Getting a copy of Flex, and using Ant to build your docs.

3 / Using either the SDK, or Flex but a front end tool like Dita to generate the shell scripts for you, that you then run in terminal to create your docs.

I’ve used Dita and Flex with an Ant build on my home mac. At work, I use the command line approach.

Heres how I got it to work, using the new Flex 4 SDK beta and the OSX terminal.

a / Make sure you have downloaded the latest Flex SDK. Unzip it and place it somewhere on your hard drive. Mine lives in the “Developer” folder of my OSX boot disk.
b / Open up a text editor. I always find it easier to work out my terminal commands in a text editor, and simply paste in what I want into termainl when I’m ready.
c / Find the path to your bin folder within your Flex SDK folder. The simplest way, is to simply drag n drop the bin folder into an empty terminal window, which will then give you the path to the folder. Or simply, type it out manually. You now need to tell terminal to work from this ‘bin’ directory, via the ‘cd’ command. The syntax for that is below;

cd path-to-you-flex-sdk-bin-folder

d / Now you can simply run the various asDoc commands to generate your documentation. The various commands I’ve used to create the documentation for my NpFSObjectresize class are listed below. Make sure the asdoc commands are all on one long line. For some reason, I had to have the footer and window title before the -doc-sources parameter.

cd /Developer/SDKs/flex_sdk_4.0.0.7219/bin/
./asdoc -main-title="NpFSOBjectResize Class" -window-title="Noponies NpFSOBjectResize Class" -footer="Copyright <a href='http://www.blog.noponies.com' title='Visit Class Author'>Noponies</a> 2009" -doc-sources=/Users/dsattler/Desktop/sample/noponies -output=/Users/dsattler/Desktop/sample/docs

As you can see from the example above, I have a folder called ’sample’ on my desktop with my actionscript residing in a folder called ‘noponies’. I’m simply outputting my docs to a folder called ‘docs’ which resides within that ’sample’ folder.

When you are ready, simply paste in your ASDoc commands into terminal, and you should see the asdoc tool run through its various steps. One thing I’ve noticed is that the Flex 4 ASDoc tool is much more strict about correctly closing html tags etc within your documentation. A missing closing /p caught me out.

ActionScript 3 LoadMovie Snippet

Over on kirupa, one of the users was complaining about the lack of LoadMovie in AS3.

While not being something that has ever concerned me in the slightest, I thought I’d whip up a quick AS3 version of the same general idea.

Its pretty simple. A singleton class, with a simple “loadMovie” method that accepts the string URL of the asset to load, the container to load it into, and an optional Boolean flag for deciding if the containers existing children (if it has any) are removed with each new load.

I doubt this will have much use, but who knows.

Source Files
Here is the relevant source file; LoadMovie (716)

By downloading, you agree to the terms of use, outlined here: http://www.blog.noponies.com/terms-and-conditions

Dependencies
Zero

AMFPHP | Zend AMF service for connecting to Wordpress

For a project I have in development I needed to once again create or connect to a CMS.

I’ve previously rolled my own CMS using AMFPHP, which works fine. However, I thought I’d give using Wordpress a go as a CMS system for Flash sites, with an AMFPHP connection between Flash and the wordpress database.

I stumbled on Amfphp WordPress Integration (AWI) which seemed to offer what I was after. However, it has not been updated for a long time, and supports wordpress 2.3 or so and below. The project I have on needs to take advantage of wordpress’s tagging and categorising of content, which was the main element missing from the awi project. So, I re wrote it, and added in many more methods and dropped many of the existing ones.

You can view an example of it at work here: http://www.noponies.com/dev/cloud/ Which is using a hacked version of the WP-Cumulus Wordpress plugin, from here: http://www.roytanck.com/tag-cloud/. Instead of using a PHP method to create XML, I’m just using AMFPHP to call a getTagCloud method, and using the data in a similar fashion to how the WP-Cumulus Flash file works. Clicking on either a category (white text) or a tag (grey text) calls another method that pulls the various posts that are filed under that particular category or tag. Pretty simple stuff.

Ironically after embarking on this little project, I found a few other similar ones, this one (Flexpress) here by Jonnie Spratley which can be found here http://jonniespratley.com/blueprints/ and this swc library FlexDb from here: http://ghalex.com/blog/?p=53. Always annoying to re invent the wheel.

I’ve called my project, FlashPress, which is who I intended it to target (Flash devs) or people like me.

As of version 0.2 this also works fine with Zend AMF, and I’ll update the source file with some demos of connecting using Zend AMF.

Anyway, enough rambling, you can download the latest version (0.6) here;

Source Files Version 0.6
Flash Press 0.6 (173)

Let me know if there are bugs etc. I’m not really a PHP guy, nor a MYSQL guy, so I’m definitely interested in hearing about ways to improve things.

Next Page »