Category: Flash

Please Log In or Register

Parsons Exploratory Navigation

Recently Parsons has launched a much needed improved site. I worked on a Flash application of the site which serves as an exploratory navigation for potential students to discover programs they may be interested in based on floating keywords. The design was done by Dexter Miranda and supervised by Isa Gouverneur, both part of the Parsons creative team. The navigation also visually makes connections between programs or schools that share keywords. This is slightly confusing to explain, so take a look at the navigation itself.

MORE INFO


BackTweets API AS3 Class

For a current project collaborator Bruce Drummond and I needed to search Twitter for urls. We attempted to parse the bit.ly truncated urls by expanding them, but that proved inefficient. Since each user truncates urls differently, we could not simply truncate the url and then search for that bit.ly. We also contacted bit.ly to determine if a list of short urls could be returned for a long url, but after a condescending response, we decided to look elsewhere.

After some searching on the web, we found BackTweets. This is an extension of BackType that stores data for various social media. BackTweets proved most effective at handling url searches. We could pass in the url that we were searching for and BackTweets would return a list of tweets. It is also possible to pass in something shorter, like nytimes.com and it will return tweets that have that inside the url. For example, http://www.nytimes.com/2009/11/13/world/asia/13eikenberry.html?_r=1&hp, could be returned when providing nytimes.com as a query term.

Earlier in this project we wrote a class in AS3 for Flash, and thought that someone may benefit from it.

Download Source
MORE INFO


New York Times Newswire API Quick Demo

For my data visualization class, we were asked to visualize the New York Times Newswire API. This is a quick demo mapping the hour of the day to the number of ny times posts for each category. You can select single categories by clicking on the buttons and you can click and drag horizontally to rotate the center graphic. One of my first attempts at using papervision and it went pretty smooth, but the coordinate system is the opposite to that of the native 3D engine in Flash, OpenFrameworks and Processing. Not that I didn’t understand it, just not used to it.

Check out the quick demo.


Animating with Vector3D Class

Move your mouse over the word to see the effect.

I have been getting back into OpenFrameworks lately and I have been using the OF vector library for all of the recent animations that I have been doing. I thought that I should give the AS3 Vector3D library a go. There are some limited, but useful functions built in. Making the move over to vector animation has made my coded animations more streamlined, if you are thinking about making the switch, consider the following code samples :


Without Vectors


var locX = 0, locY = 0;
var loc2X = 100;
var loc2Y = 50;

var dx = loc2X – locX;
var dy = loc2Y – locY;
var dist = Math.sqrt( (dx * dx) + (dy * dy) );


Utilizing Vectors


var loc:Vector3D = new Vector3D();
var loc2:Vector3D = new Vector3D(100, 50);

var dist2 = (loc2.subtract( loc )).length;

// or //
var dist3 = Vector3D.distance( loc, loc2 );

MORE INFO


Loading an XML File From Another Domain Without a Cross-Domain Policy File

I recently completed a project in which I needed to load xml files from anywhere on the web. Through some quick google searches, I found that most recommendations were for a cross-domain policy file. However, I do not have access to change these files. With the help of some php, we can grab xml from other domains. All we do is pass the php file a location of the xml that we would like to load and read it back in Flash.

Download src.
This includes a sample .fla file and the php file, with comments.

MORE INFO


Math Mapping Functions

I have not posted in a while, do to finals, vacations and excuses. But for my final I got into algorithmic animation and I used these functions a great deal to help me out. The values must be in the range to work correctly.

// returns a number between 0.0 and 1.0 //
public static function normalize(value:Number, low:Number, high:Number):Number {
   return value/(high + low);
}

// value should always be between 0.0 – 1.0. Places value into desired range of low – high //
public static function lerp(value:Number, low:Number, high:Number):Number {
   return value * (high – low) + low;
}

// convert the value parameter from range low1 to high1 to the range low2 to high2 //
public static function map(value:Number, low1, high1, low2, high2):Number {
   return normalize(value, low1, high1) * (high2 – low2) + low2;
}

// convert radians to degrees //
public static function toDegrees(radians:Number):Number {
   return radians * 180/Math.PI;
}

// convert degrees to radians //
public static function toRadians(degrees:Number):Number {
   return degrees * Math.PI / 180;
}

Download Class


AMFPHP 1.9 and Actionscript 3

I recently installed amfphp 1.9 and have gotten it to work thanks to some tutorials by Lee Brimelow on some introductions to amfphp.

Introduction to AMFPHP 1
Introduction to AMFPHP 2



He also did a blog post about some security issues regarding amfphp. These were great to get me started, but I ran into a few problems when I began to play around with it on my own.

First, I always place some returns at the top of my documents just for some space. However, this caused Flash to return a Server.badCall error, so make sure that there are no extra returns at the top of your document.

I had trouble finding the data that the responder returns by using the method that Lee described, but I found that if the amfphp function returns a single value, like “false” or “0″, then you can access it through :

function onTotal(responds:Object):void {
total = int( responds.serverInfo.initialData );
}

If you are dealing with a function that returns multiple values, such as a query to a database, I found that you can cycle through the results with this :

function onGetUserInfo(responds:Object):void {
for (var i:int = 0; i < responds.serverInfo.initialData.length; i++) {
trace(responds.serverInfo.initialData[i]);
trace(responds.serverInfo.initialData[i][0]);
}
}

Another problem that I ran into was the calls returning null values. This was due to the fact that I was directly referencing the file name.
i.e. http://www.site.com/amfphp/gateway.php. This worked when the user was at www.site.com, however, when the user accessed the swf from site.com it would return null values. I found that a quick fix was to simply reference the gateway through “/amfphp/gateway.php”.

Lee chose to display examples from php 5 and the constructor function for the class that he mentions for php 5 is
class DB {
public function __construct() {}
}
?>

If you are using php 4, the constructor function of the class is the same name as the class that contains it
class DB {
function DB() {}
}?>

I am not very good at php so I hope that this helps someone, as some of these errors were tough to spot, mainly the class constructor and the url with www or not.


AS3 Multi-Image and Swf Loader



If you want a very robust multiLoader in as3 then BulkLoader by Arthur Debert is a great solution. This as3 multi-loader manages the loading of multiple images and swfs and is a lighter class, and is based on the BulkLoader code.
Tracking of individual progress and of the group is easy. To view the loading again, just refresh the page. There is a sample .fla, with sample code for loading and tracking images, which can be downloaded here. Please let me know of any questions or suggestions.