Archive for the 'Actionscript' Category

Introduction to Manual Compiling with Flex SDK

February 15th, 2010 | Category: Actionscript, Programming

So, many of you have sent me emails or asked me in person about how, exactly, to get started playing with the Flex SDK without having to pour any money into unnecessary resources or IDEs. First, let me say that purchasing and using Flex Builder will be one of the best investments you can make in your Flex development learning, but yes, you can indeed download the SDK free of charge and manually compile AS3 and AIR applications. This will be a very simple post dealing with just how this can be done. While there are many, many, many details we could approach, I want to tackle this issue in its simplest form and hopefully get people on the ground running within minutes of reading this post. Please note that this will be written for Windows users, though I highly recommend people set up a Linux environment and play with the command line tools there as well, if possible.
Read more

No comments

Dynamic XML Slideshow in AS3

January 21st, 2010 | Category: Actionscript, Web Development

Over the past year or so, I have been responsible for developing and maintaining a JavaScript Slideshow component for our internal CMS. With the similarities between JavaScript and Actionscript, I have wanted to implement this slideshow in a manner consistent with the flexibility and usage of the JavaScript version. The biggest difference is that the JS one is focused on content, and the AS3 version will be focused on pictures – since AS3 does not fully support markup and CSS yet. This being said, I have had opportunity to attack my project and have the first phase completed. As with so many of my other personal projects, I’m tackling it in phases rather than having a defined spec list ready to go. In this case, I have the slideshow reading an image list from an XML document, loading the individual pictures and setting them on a timed rotation.
Read more

2 comments

Simple Actionscript Shooter Phase 1 (AS3)

May 08th, 2009 | Category: Actionscript, Game Development, Web Development

Well, OK, it’s not much of a Phase 1 – more like Phases 1, 2 and 3 all rolled into one simple demo, but for my purposes, the name will suffice. Many different ideas and techniques have been rolling around in my head for months, and I finally decided to try and find a simple way to implement some of those ideas into a working model; and what better way to do so than a classic shooter?

With flash gaming sites like Kongregate and ArmorGames offering incentives – and even revenue – to developers, I thought it about time to start put something together and just see what comes of it. Obviously, I have a long way to go, but here is a preview of a little application on which I am currently working.
Read more

1 comment

Embedding Fonts into Actionscript Only Project (AS3)

May 07th, 2009 | Category: Actionscript, Web Development

Embedding fonts has been a bane to me for some time, and I finally spent the time to find both the easiest and most comprehensive way to embed needed fonts into a SWF using AS3 only. As always, I try to keep the demos here as lightweight as possible, and I have tried to keep any code snippets I give free from external resources. In this case, there is a small exception, but it is only the exception of using one of the fonts installed on your own computer.

Basically, we need to understand a couple things about the nature of the embedded font in Actionscript. First, it must be assigned to a String in order to store all the character references. Next, you will quickly find that creating and implementing a TextFormat object to attach the font and styles to the different places in which it will be used is ideal. Finally, keep in mind that attaching several fonts to a single application can significantly increase the file size, so try to consolidate and style for variety as much as possible instead of selecting a boat load of different font faces.
Read more

1 comment

Map Handling Take 3 – Hover Over Borders (AS3)

May 06th, 2009 | Category: Actionscript, Web Development

Well, at the risk of sensory overload today – it’s my blog after all – I decided to post one more version of my map handler. This one adds in the classic mouse hover scroll effect at the edges of the map. I did try to make it a bit more usable, though, by calculating the distance from the edge of the map and accelerating the movement appropriately. So, the closer to the edge you are, the faster the map scrolls. So, to recap, you can use the following methods to move:
Read more

2 comments

Drag Viewport for Map Preview in AS3

May 06th, 2009 | Category: Actionscript, Web Development

So, a really quick update post here. Upon publishing my previous post, I received some great feedback from gamer friends who thought a good way to improve the interaction would be to allow for dragging the preview marker around to update the viewport in addition to simply clicking. After giving this some thought and suppressing some immediate concerns about the overhead calculations this might take, I have implemented this change and am interested in getting some feedback. Of course, all the other features (like clicking the preview and navigating the map using the A, S, D and W keys). Feedback welcome as always…
Read more

1 comment

Handling Larger Maps in AS3

I have been working on some ideas for a TD game that would be both entertaining and original, and I feel that – with the help of a couple friends’ input – I’m on the way to something worth developing. Since I have already put together much of the “guts” for a TD game, I am hoping that I will be able to quickly put together a prototype in my free time. Ideally, once I have a prototype together, I will be able to find a sponsor to pay for development, and I would then be able to focus some solid time on the project, but that is a bit optimistic at this point, since we are still in the baby conceptual stage.

Without giving too much away on my idea, I’m going to try to cover some concepts and specific ideas that I have had to resolve in order to visualize different portions of the interface and interactions. The first thing I realized was, to fully succeed with the idea I want to implement, I would have to be able to support fairly large maps (in some remote cases, massive may be a better term). Having been a long time RTS (Real Time Strategy) player, I decided to take some cues from them and implement a similar map-handling system. Surprisingly, once things started falling into place, it was quite easy to tweak and get working to a satisfactory level.
Read more

2 comments

Google Analytics Style Graphing with AS3

March 06th, 2009 | Category: Actionscript, Programming, Web Development

Developers who have been using Google Analytics for any time can appreciate the flexibility and power behind some of the graphing software it offers. I recently found myself wondering just how they get the incredibly usable effect they have, so I began tinkering with some Actionscript and soon found myself with a very workable base that not only could be modified and grown to match what this software offers but is also surprisingly simplistic in nature.

Basically, we simply have our main application (or graph in this case) that can take any number of argument values and calculate not only their position based on ratio but also spreads them across the graph in a readable way. So, we create a simple point object that handles the visuals – both the expanding and contracting as well as the showing and hiding of the value text – and allow our graph to do some very simple calculations to spread them out evenly.
Read more

2 comments

Harnassing the Power of Timers in AS3

February 26th, 2009 | Category: Actionscript, Programming, Web Development

Anyone who has had the experience of trying to time events for web via client side scripting before can readily appreciate the power and ease of using the robust Timer class in Actionscript 3. Similar to the idea of using JavaScript’s setTimout and/or setInterval methods, we can use this class to set a timer for a millisecond count that will simply trigger a TimerEvent when the timer has reached its end. The beauty of it, though, is that when the timer is created, we can explicitly declare how many times we want the timer to run! No more sloppy looping of intervals or timeouts: just set your timer to X number of loops and start it running.

So, obviously, if we create a timer to run once, it is the equivalent of running a setTimeout function. As with the aforementioned JavaScript functions, we set the timer with a number of milliseconds we want to wait before triggering its event. As an optional second argument, we pass in the number of cycles we wish the timer to run. Also, since the timer is an object, even if we set the timer to run only once, we can call the start method on it and manually run that single timer multiple times throughout our script. With a little creative thinking, I’m sure you can already come up with dozens of ways this could be useful.
Read more

No comments

Optimizing Code Reusability and Minimizing Your Footprint

February 24th, 2009 | Category: Actionscript, Programming, Web Development

One of the most common questions I am asked is also one of the biggest problems I see in code as I read it: lack of optimization. I often have people asking questions about how they can consolidate the generic actions they want multiple objects to have access to perform without duplicating the code. In Actionscript, just like any other coding language, the duplication of code is typically a red flag that you are doing something wrong. No, not wrong in the sense of broken, but wrong in the sense of best practice and code optimization. It is much easier to have one handler function to debug and keep up than to have that same handler individually executing in a dozen different class objects.

Quite possibly the single most useful thing I have discovered in optimizing some of the graphical effects I use over and over again is simply making use of the event object in my callback functions. When you attach an event listener to an object and the event is triggered, the event passed into the callback function has a target attribute that is a reference to the object which initially triggered the event. Accessing the object this way lets us generalize handlers (such as a fadeOut function) that will consolidate our code and give us uniformity in execution.
Read more

1 comment

Next Page »