Friday, February 20, 2009

Adobe AIR application - File System



So I had a little down time today, so I started writing an AIR application. The idea was to allow our admin folk to go paperless with their work order information. Essentially the programs is simply a data entry solution. It saves out an xml file based on the fields entered. It can also open the files with the the same format. So you can create, open, and modify an existing work order. The cool thing about it, is that it creates a file directory based on the File# entered. It also exports a jpeg of the form, for easy printing, since we still like our paper copies. Granted, it's sort of a glorified excel spreadsheet, and it's not finished yet. But it was a good exercise in working with the Filesystem class for Adobe Air, as well as the com.adobe.images package.

Thursday, February 19, 2009

Flex Builder - exploring the IDE


Recently I've started doing a little more work in Adobe Flex. I managed to get the free academic license from Adobe. At $250 and with a free academic version and SDK, Adobe is clearly trying to increase the reach of Actionscript development. Flex obviously isn't new, in fact the latest version v4 (currently Gumbo) is due out later this year. When I initially heard of Flex Builder I was expecting Flash without the time line, but after downloading the trial version (60 day trial, btw) I realized it's indeed a far more complex IDE than I had thought. Built on the open source Eclipse IDE, Flex Builder functions very intuitively.



At first, I was a little lost in the whole mxml and AS3 cross-code stuff. But eventually I realized the benefit of this logi
c. Flex makes so many of the monotonous interface development tasks really enjoyable. I would strongly suggest downloading the trial version and giving it a look. If you're a Flash Developer it can only help to understand a little bit about Flex. I'm working on developing a couple of desktop AIR applications built in Flex Builder.

Wednesday, February 18, 2009

Follow up on 360 Rotation Project


About 5.5 hours later the revised 360 Flash module is finally near completion. Thanks to the integration CS3 offers creating the .fla was pretty straightforward. In fact, it involved simply importing the .psd straight into Flash, making a few changes, and that was it. The file size is still a little large, but that has a lot to do with the 360 render. I ended up cutting the number of frames in half to cut down on size.



I’m using the AS3 preloader technique Lee Brimelow shows on www.gotoandlearn.com. Loading an external .swf into the loader.swf. Worked well, except that I noticed my reference to “stage” in the document class returned one of those obscure “null object reference” errors. Took me a while to debug it. Somehow the reference to the “stage” wasn’t registering as instantiated in the loader.swf.

(If anyone knows why, let me know)

Ultimately it was a smooth project start to finished.

http://www.mastertrackproductions.com/Licor/7700_loader.html

Monday, February 16, 2009

simulated 3D - 360 Rotation




The integration of 3D Graphics and Flash has come a long way over the past few months. With the advent of Papervision3D among other 3D engines, creating real-time 3D graphics in Flash is now a very tangible prospect. I intend to post more about Papervision3D and Collada file integration in the future.


However, the use of "simulated-3D" (for lack of a better term) is still very much in demand by clients. The process involves rendering an animated sequence (usually a 360 rotation of some sort) and then importing dozens (if not hundreds) of individual frames into a MovieClip in Flash.

Needless to say, it's not the most elegant means, but done sparingly and with efficiency in mind, it can produce stunning results.

I recently created a prototype for Licor Biosciences. I used a function that generated an integer based on the width of the stage - that integer was then used as the frame number of the corresponding MovieClip.

Here's the function I wrote

function giveDis(event:Event):void
{

var bX:Number = dragger.x
var bY:Number = dragger.y
var cX:Number = center.x
var cY:Number = center.y

distance = Math.round(Math.sqrt((bX) * (bX) + (cX) * (cX))/13.4);
trace(distance);
photon.gotoAndStop(distance);

}

In this case, the function is triggered by an ENTER_FRAME event. So it perpetually tracks the integer that the 'distance' variable produces.


[NOTE: 'dragger' here refers to the MovieClip used as the dragging mechanism
(i.e dragger.startDrag();) and 'center' is a second clip used at the edge of the stage.]


The distance formula shown is the Pythagorean Theorem rounded to the nearest integer and then devided by 13.4, which was a number I found by trial and error. It gave me a integer between 0 and 200 which was equal to the number of frames in my MovieClip.

(I'm sure a math genius out there could tell me why 13.4 it makes sense here.)

I'll be re-writing the code for this program shortly, and it'll be structured in the proper 'package' format.

The benefit of the code above is that it can be used for virtually any number of frames, on any stage, for any animation.

See the example here:http://www.mastertrackproductions.com/Licor/view360/Licor360.html



-Alchemist

Tuesday, February 10, 2009

e.target and MovieClip values

While working on a web project this week for IDSODISC I discovered an interesting way of handling events for movieclips in Actionscript. I set a value for each movieclip(as a button) I then used that value to store an additional movieclip, subsequently creating a single function which can be applied to what ever movieclip you click on. I've included a rough example below.

//code begins here----------------

img1.visible = false;
b1.value = img1
b1.addEventListener(MouseEvent.MOUSE_DOWN, callFunction);
function callFunction(e:MouseEvent):void
{

e.target.value.visible = true;

}

//------END-----

So essentially what this does is it makes the "value" of b1 visible. In this case, that would be img1. I'm not sure how this fits in with standard programming best practices. But the benefit here is, as long as a movieclip has a value - it can call that function.


to view the site visit:
http://www.mastertrackproductions.com/ISODISC/ISODISC_loader.html

First Blog - Up and running.

Welcome to the Actionscriptology blog. This Blog is dedicated to pretty much anything RIA, Flex, Flash, Actionscript related. I hope to update this blog frequently with new discoveries, projects, tutorials and whatever else strikes me as relevant to the RIA movement. And I encourage anyone to submit ideas/corrections to anything I post. I myself am a novice to web programming, and my hope is that others will learn as I excavate Actionscriptology.