AS3 console.log();

AS3 console.log();

tracing to the browser console via as3 just got a whole lot easier ?View Code ACTIONSCRIPTimport net.peteshand.asWindow.utils.console; console.log("trace to browser console"); Download via...
AS3 Window

AS3 Window

Ok, so one thing that has always bugged me about as3′s navigateToURL is its lack of control over the window that is opened, mainly that you can’t control the width and height. There are of course ways around this with javascript, but wouldn’t it be nice if you could do this from within as3, with no external dependencies! Well turns out you can do just that with this nifty little library. Introducing AS3 Window. You can download it via github. In it’s simplest form, the following will open a new popup window with a width and height of 640×460 and will be placed 100 pixels from the left of the screen and 50 pixels from the top of the screen. ?View Code ACTIONSCRIPTvar window:Window = new Window(); window.width = 640; window.height = 460; window.x = 100; window.y = 50; window.open('popup.html'); You can close the window by calling the close() function. ?View Code ACTIONSCRIPTwindow.close(); The library has numerous features, but I’ll leave that for another...
Away3D Liquid Ball

Away3D Liquid Ball

As part of one of my last projects I needed to create this interactive oil blob (as seen here, 58 seconds in). Thought I’d do a quick post showing it off and sharing the source for anyone who is interested. The environment map is of Manly Beach (Sydney) and was photographed by myself, so feel free to use without restriction. source can be downloaded from...

Flash/AS3 Web Notifications

Quick tutorial on opening Web Notifications in compatible browsers (Webkit) via as3. First download the WebNotifications.swc and include it in your project. ?View Code ACTIONSCRIPT1 import net.peteshand.utils.WebNotifications; If you want to test if the users browser is compatible simply call: ?View Code ACTIONSCRIPT1 2 3 if (WebNotifications.available){ // do something } Once you’ve checked if WebNotifications is available you can open a basic notification with the following code: ?View Code ACTIONSCRIPT1 2 3 if (WebNotifications.available){ WebNotifications.Open(title, body, iconURL, timeout); } You can also open an html page within a notification with the following code: ?View Code ACTIONSCRIPT1 2 3 if (WebNotifications.htmlAvailable){ WebNotifications.OpenHTML(url, timeout); } You can close open notifications with the following code: ?View Code ACTIONSCRIPT1 2 3 if (WebNotifications.htmlAvailable){ WebNotifications.Close(id); } Where id is either the title or the url depending on the type of notification. You can also close all open notifications with the following code: ?View Code ACTIONSCRIPT1 2 3 if (WebNotifications.htmlAvailable){ WebNotifications.CloseAll(); } An example can be viewed below: WebNotifications Get Adobe Flash player download example source Known Limitations: * Custom icons are not supported in OSX * HTML Notifications are not supported in OSX * CloseAll() and Close(id) are not supported in OSX * Timeout is not supported in OSX (default timeout time set by OS to 5 seconds) * For the eventlisteners to work correctly, the ‘name’ parameter must be set in attributes object to the same as the swfobject replaceElemIdStr or equivalent if something other than swfobject is being used to embed the flash. Eg: “altContent” ?View Code JAVASCRIPT1 2 3 4 var flashvars = {}; var params = { menu: "false",...

Flash 11 Platform Game Prototype

you can view an early prototype for a platform game I’m building with flash 11, away3d and box2d below. You can view the game in action here (Warming: there is no pre-loader). I’ve been surprised at the speed in which I’ve been able to put this together and because everything is xml driven once the initial level, characters and game objects have been implemented content generation is going to be a breeze. You can view the xml here. As stated above this is an early prototype, so there are plenty of things missing, for example the hero will probably stop walking when he isn’t moving 😉 and I’m sure most of what you see will change anyway, but just thought I’d share my...

integrate browser scrollbar with flash – part 2

After my last post on integrating the browser scrollbar with flash a friend of mine (Tim Keir) instantly pointed out that there is a small library called swffit which he said achieves a similar result. Don’t you just hate it when that happens! However while swffit is a great library (and I encourage you to check it out), it achieves a somewhat different result than what I was trying to demonstrate. swffit basically sets the height of the swf to 100% as long as the browser height is greater than x, if the browser height is reduced below x then the flash movie’s height is set to x and a browser scrollbar appears. This is great for full-page flash movies when viewed on a small screen because the user will always be able to scroll down if there screen isn’t big enough. So obviously my explanation and example require a little reworking to clarify why you might want to implement something like this. So that’s what I’ve done. This time round I’ve abandoned the idea of creating an experience similar to an html page and focused on more of a ‘flashy’ example. Its still very basic, but it should give you a better impression of the possibilities. The second example can be viewed here. This time there is also a scrollbar along the bottom of the window, as well as a 3d cube which replaces the checker panel. The side scrollbar controls the cube’s rotation around its x axis and the bottom scrollbar moves around the cube on its y axis. also in addition to this clicking and dragging anywhere on the flash content (or...