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

Moved to England

After 30 odd hours of flying, transit lounges and endless spinach pasta stodge, I’m in London.

Now to find a job, if anyone knows of any Flash work going over here, drop me a line.

I have a job, house, etc thanks to all the people who posted links. Now I just need the weather to warm up.

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.

AS3 Drag Sort Grid Experiment

This is really just an experiment that I have ended up not using at all.

I had a project where I had to come up with some interface for changing the order of items (gallery items in a CMS) so I thought I could simply layout a grid representation of the gallery items and let the user drag them around to re arrange them.

The result is below;

The Flash plugin is required to view this object.

It’s not perfect by any means, but might be of use for someone. In the end I added drag and drop functionality to the NpScrollingPanel class as a means to re order content.

Source Files
Here is the relevant source file; Drag Sort Grid (1035) - 42.29 KB

The orginal file came from the excellent soulwire (JUSTIN WINDLE) at this url; http://blog.soulwire.co.uk/art/dynamic-stacking/

Getting Ripped off on Flash Template Sites

I recently discovered a user at http://flashden.net was using one of my files as a paid template, an older version of my FullBrowser Content file.

While I give most of my files away, I do stipulate that they are not used as the base for making money off of, by turning them into templates etc that are on sold multiple times. Generally this is a good faith agreement, between myself and whoever uses my files. I have received alot of help from various blogs and forums with learning ActionScript, and this blog is a means to return some of that help.

What was and is most frustrating about this experience, has been my dealings with Flash Den, and the user who ‘borrowed’ my file. It was pretty clear cut to me, that this user had stolen my source. I mean, I decompiled his preview and had a look at it to see.

Seems that FlashDen were just taking their time, and have since removed this offenders and another’s from the site. So, well done to them.

Check out this for similarities:

His file contains these constants;

public static const BG_LOADING:String = "newslideloading";
public static const UNLOAD_BG:String = "unloadbg";
public static const BG_LOADED:String = "newslideloaded";

My file contains these constants:

public static  const BG_LOADED:String  = "newslideloaded";
public static  const BG_LOADING:String  = "newslideloading";
public static  const UNLOAD_BG:String  = "unloadbg";

His has these vars (just some of them)

private var YminStageSize:int;
private var useMinStageSize:Boolean;
private var XminStageSize:int;
private var imageScaleProp:Number;

Mine has these vars (again, just some of them)

private var useMinStageSize:Boolean;//use a minimum stage size?
private var XminStageSize:int;
private var YminStageSize:int;
private var imageScaleProp:Number;

You get the idea. Not only were the constants, vars the same, but the method names were the same, along with the functionality of each method.?Ǭ†The only change was the shift from tweenLite to tweener for some animation, and the removal of all the garbage collection methods and event handling. The guy was so crap, that he left the constants in there, not understanding that they were for custom event dispatches, but deleted the custom event handling. The user was adamant that he didn’t use my file, when clearly he had. After a few emails, he decided to delete ‘my’ file once he realised he had been caught out.

I decided to report him to FlashDen, and provided the FlashDen staff with my source files, and a link to his. Their response was that no copyright infringement occurred, and that the user probably just deleted his file to “make some modifications”. I couldn’t believe it, I mean, clearly his file is totally based off of mine. This user is still happily uploading new files.

So, in the end, its worked out OK. FlashDen took their time, which I guess is OK. As they investigate any issues, rather than issuing instant take down notices if someone thinks something is copyright.

On another forum, some other user posted class files from the Martha Mclean website I wrote, trying to get help with the mess the decompiler made of it all. I recognised the code instantly and questioned where it came from. What an idiot. If the dude actually just tried to learn how to do it, then he would be set, its not even that hard..

ActionScript 3 Scrolling Text Class

The NpTextScroller Class is a ActionScript 3 Implementation of scrolling text. Similar to the NpScrollingPanel Class.

The class supports scrolling via the provided scrollBar, keyboard (UP and DOWN arrows) or via the mouse wheel. I’ve also included and added in support for the mouse wheel on Macs. That support is courtesy of the great class provided by pixelbreaker. The class is scrollRect based. I chose a scrollRect for a performance gain it offers when scrolling text. The downside in this implementation is that when you are blur scrolling the text, the top and bottom of the rect tends to look blurred as well.

The Class uses an enterframe for it’s scrolling, rather than a tween engine. The enterframe events are always removed when scrolling etc stops.

I have not tested this on a PC, so let me know if it has issues. I think Safari might have an issue with it, judging by some of the comments from pixel breakers blog posts.

Class Features

  • Scroll Y
  • Either CSS or TextFormat Styles for text
  • Supports HTML text
  • Scroll via MouseWheel, Keyboard, Slider Bar
  • Selectively choose what listeners to add, or remove
  • Slider Bar is fully configurable
  • Slider Bar auto hides if there is not enough text to scroll
  • Use custom asset for Slider Bar Drag Handle
  • Append text
  • Replace text at runtime
  • Scroll programatically to particular points
  • Control blurring amounts
  • Control scroll speed and easing

View Example
Here is an example. It’s using external text, with the left hand text block controlled via a TextFormat Object and an embedded font. The right is controlled via an external CSS StyleSheet, using Arial. Clicking the “load new text” button swaps the right hand block of text to a TextFormat Object.; http://www.noponies.com/dev/as3_textscroller/

Source Files
Donator only file!

Dependencies
The .fla’s use the Memory and Framerate monitoring component from Grant Skinner, which you can get here: http://www.gskinner.com/blog/archives/2008/04/simple_componen.html, But, simply delete this out, for a production use.
Mac MouseWheel Scrolling pixelbreaker

ActionScript 3 Content Scroller Class

The NpScrollingPanel is a ActionScript 3 Implementation of a scrolling panel. Pretty common place stuff. This is a reworking of an older version of the same file I posted a little while ago. Since then I’ve removed the scrollRect version, but may re do it at some stage, if time permits. Internally the class now uses the Adobe Tween engine to scroll all content.

The NpScrollingPanel Class is designed to create a scrolling pane of content. The Class itself does not handle any loading in of content. You must provide the class with DisplayObjects for it to scroll. I wanted it to be completely content independent.

Let me know if there are bugs etc..

Class Features

  • Scroll x and y
  • Fixed or stage width / height scrolling area
  • Create columns / rows of scrolling content
  • Scroll via mouse movement, panel edges, or via external sources
  • Control colour and alpha of scroller background
  • Toggle button mode for content
  • Scrolls any DisplayObject
  • Adjust content item padding on the fly
  • Remove content items on the fly
  • Use lots of cpu with a blur scroll mode :)
  • Simple internal easing engine
  • Control scroll speed and easing
  • Enable / Disable scrolling
  • Target individual content items
  • Enable Reflections on content
  • Drag N Drop content items, to change their order in the panel
  • Flexible event system to track clicks etc on content

View Example
Here is an example. It’s using external XML content and the vertical scroller is pulling in two bitmaps from the library; http://www.noponies.com/dev/as3_scrollingpanel/. Performance of the blurred and reflected content is pretty bad :) . I’ve been playing around with this class for a job, where I’ve built a basic CMS, that needed the ability to reorder the content. So, I’ve added in the ability to drag n drop the content items, changing their order, plus a whole lot of other bug fixes. The new version is not online yet, but will be by the end of the week. The online demo allows for dragging and dropping, its pretty beta!

Updates
Jan 03 2009: Small fix for a bug pointed out by Matt.

Source Files
Here is the relevant source file; Scrolling Panel Source Files (1942) - 352.72 KB
Here are the beta files, that allow for dragging content items. Be aware, that quite abit of the api has changed.
Scrolling Panel Source Files (Beta) (538) - 351.77 KB
Let me know how these new files work out.
By downloading, you agree to the terms of use, outlined here: http://www.blog.noponies.com/terms-and-conditions

Dependencies
The class uses the http://www.adobe.com/devnet/flash/articles/reflect_class_as3.html class to enable reflections on content.

« Previous PageNext Page »