July 2003 Archives

Interesting - new player auto-updater

| 1 Comment

I found this while digging into this new beta player a little further...

"C:\WINDOWS\system32\Macromed\Flash\GetFlash.exe" - yours might be in a different location. If you click settings then, it takes you here: http://www.macromedia.com/support/flashplayer/help/settings/global_notify.html

Rock! I heard this was a new feature, but it was cool to see it in action. I think it's a tad buggy though... It told me there was a new player available when I already installed the beta a few hours ago...

Some stuff I found as well (that I haven't seen posted anywhere yet)

onMouseWheel
shutdownURL
onConstruct
// has the petition been heard??? It looks like it
onLoadStart
onLoadComplete
onLoadProgress
onLoadError
LoadNeverCompleted
URLNotFound
onScroller
onUnload
onInitialize
HttpAddRequestHeaders
HttpSendRequest
HttpOpenRequest
InternetErrorDlg
InternetCloseHandle
InternetReadFile
InternetQueryDataAvailable

There's also still references to "Tin Can" which was the beta test code name for FlashComm..

Alright, that's enough for one evening...

Flash Player 7 Beta

| 1 Comment

By now you all should have heard about the Flash Player 7 beta. If not, check out FullAsAGoog, or the MXNA for a blog list of flashers who have posted about it.

And hey, since I'm on that list, I might as well post about it too, right?

I'm not going to mention features or anything like that. you can find that on everyone's weblog. The only thing I want to say about this beta is that I'm very pleased with Macromedia in the way they're handling it.

By fully testing out the player in the developer community they can get accurate feedback and address the issues that arise BEFORE releasing it to the public. I'm honestly hoping that Flash Player 7 doesn't turn into what 6 did with always having to worry about what minor version the viewer had. There were so many different minor versions that developing became a major headache, and eventually I just decided to force everyone to use 6,0,79,0 becuase it just got to be too much with keeping track of what I could and couldn't do with the "older" Flash 6 players.

So... let's hear it for Macromedia, they're headed in the right direction. I was beginning to think no one even beta-tested anymore (internet development is so fast paced that the trend seems to be little or no beta testing before public releases). You can be sure that I'll do my fair share of bug testing, and reporting any issues that may arise. One thing I definitly want to test is Flash Remoting over SSL in a load balanced environment. We've had many many problems with this, but only on all Active-X versions of Flash Player 6... *fingers crossed* Let's hope the security sandbox code is a little better and consistent between all of the players (Mozilla, IE, Mac, Linux).

Woohoo! I can't wait for the new IDE either. :-)

Oh, and let's hear it for me not proofreading before I save my entires and having them sent to the news aggregators with typos in the header, then fixing the spelling error and having my entry listed twice in a row. I rock!!! (lesson learned)

FlashStickies 0.0.1

| 1 Comment

Download FlashStickies 0.0.1

Please see the license and readme files inside the zip file. This is still alpha software, and there are bound to be bugs. There's a list of known issues in the readme file.

I'll continue to develop this as I get the time, but I felt I was at a point where at least the program is useable, and the more people that use it the better the bug reports will be.. which eventually leads to a better product. Bear in mind I wrote this in my free time, so don't expect any support or anything like that.. but I'll try to implement bug fixes as they arise.

Extract all of the files into a directory... Wherever you launch FlashStickies.exe from, that is where all of the note information is saved. When you exit the program, it creates a "FlashStickies.obj" file containing the saved note data. Again, see the readme file for known issues.

I look forward to everyone's comments. Please bear in mind this IS still alpha, so if you try to break it you might be able to. I hope that won't deter you from using the program in the future once additional versions are released.

traceObject

| 1 Comment

Ever get tired of debugging with the trace command and seeing [object Object] in the output window? Right in line with recursion discussion in my previous entry, I created a handy little function that will trace the entire contents of an object.

I'm sure someone else has done something like this before, perhaps even better than my approach. If so, post up a comment. Suggestions for improvement are also welcome.

Hopefully MTCodeBeautifier works this time.. I've seen inconsistent results when trying to post code. The code is in the extended entry (read more), and I apologize if the code is unreadable on the site here -- I'll provide a download link to an ActionScript file tonight sometime. If you have trouble reading it, view the source of the page and copy/paste into Flash.

UPDATE: Download the code here - traceObject.as - or use the download link on the front page of my weblog.

Towers of Hanoi

| 1 Comment

This one was dug up from my archives....

How to Solve the Towers of Hanoi with Flash MX

The main thing to get from this example is how simple the algorithm is, and to show how powerful recursion can be. For those not familiar with recursion - recursion is the process of a function calling itself.

There are always 2 "cases" in a recursive function - the "base case" that signals the end of the recursion, and the "recursive case." Recursion is a way of problem simplification. If you don't know how to solve a problem, a common approach is to break the problem down into smaller pieces, and this is exactly what recursion does. The "recursive case" reduces the problem into a more solveable problem, until eventually the "base case" is found, which we can easily solve. Then, the result "bubbles up" to the top level for the complete answer.

Life in the Way

| No Comments

I set a goal of getting the file access working within FlashStickies by the end of this evening. As usual, I had high hopes, but a certain series of events changed the way my time was consumed.

I spent the remainder of Wednesday night, after making the FlashStickies announcement, reading more of A Prayer for Owen Meany, by John Irving. My day Thursday was filled with work and socializing (gasp!).

Friday, today, I came home from work with the second worst headache I've had in the last few months. I wouldn't label it as a migraine, but I don't get headaches often. Thus, being that I've had two headaches in the last few months, and being that one WAS migraine... the one I had this evening defaults to "second-worst," making it sound entirely worse than it actually was.

Anyway, it put me in no mood for programming. In fact... I came home, slept for 3 hours, ate dinner, and finished the aforementioned book. Therefore no where in the past few days was there any time for extracurricular Flash development.

This weekend looks out of the question as well. My girlfriend and I live ~100 miles apart, and we only get together on weekends. Needless to say, I won't be doing any programming.

Sunday afternoon, a friend of mine is taking me biking somewhere in Jim Thorpe. Jim Thorpe is a coal miner's town in North Eastern Pennsylvania named after the Olympic Gold Medalist. It's a very amazing scenic town, with interesting sights.. oh, alright, enough linking.

I'll be taking my digital camera along, and maybe.. just maybe.. I'll put up a little photo gallery when I get back.

So, basically, you can probably expect FlashStickies to have a 1.0 release sometime next week. I feel that I've let everyone down by announcing a download link tonight, and that will motivate me to get it done sooner.... but as the title states, sometimes life gets in the way of programming....

... and that's not always a bad thing.

Announcing FlashStickies

| No Comments

Last night I practically finished my little Flash desktop app that I've been working on. I call it "FlashStickies."

Basically, it's a simple clone of the popular "Stickies" application written for Macs. It's a combination of Flash MX and ScreenWeaver. In the future, once I work on SharpFlash a little more, I hope to be able to create the program with SharpFlash instead of ScreenWeaver... but that will be much later in the future - I still have a lot of work to do on SharpFlash before its even near ScreenWeaver quality.

I'll be officially releasing the 1.0 version on Friday. The only thing that the application doesn't do is save your sticky notes. It's useable as it is now, but saving is an important feature and I don't want to launch without it. With a little luck, I'll be able to have the kind folks behind ScreenWeaver link to the application from their examples page. Their example page only has 4 examples, and I think FlashStickies is a good example of how powerful Flash can be outside of a web environment.

I'll need to make a project page for it as well on this site somewhere, since I'll be continually supporting it and fixing bugs as they come in. In the meantime, here is a screenshot. Come back Friday night (Eastern Time - sometime after 6pm) - there will be a download link.

FlashStickies_thumb.jpg

I need to clean up the source a little bit too. I plan on releasing that too, but maybe not right away. I'll wait to fix a few bugs first and give myself enough time to comment it fairly well before showing it to everyone. It will be coming though...

New Starter

| No Comments

Well, it didn't take long at all - I found a used starter and installed it no problem. Actually, since I was at work, it was my dad who found me the starter. I'm assuming it was used, but it was just in a box on the floor, so it may have been new instead.... Either way, there were minor problems - like the bolts were shot and it kept jamming so I had to shim it, but aside from that, I got my daily driver back on the road in no time at all.

Tonight I'll be working on that flash desktop app I keep talking about. There's a fairly good chance that I'll finish it tonight depending on how many hiccups I come across. I'm excited to get this one done and share it with everybody, it's a handy little program.

On my drive home from work today I kept thinking of project ideas that I want to work on. I thought of 3 more things that I'd like to accomplish, one of which is finally developing a component set to offer to the community. I think I have an original idea that would have many practical applications...

The list grows longer, the days are getting shorter, and I'm getting older (and other short little phrases ending in "er" would fit here too). Stay tuned, by the end of the week my little desktop app should be posted.

Stranded

| No Comments

I exited work today and climbed into my 1991 Isuzu Trooper. It's tan, a 5spd., with 163,000 miles on it. All in all, it runs pretty good. I received it 2 years ago with a blown engine, and $300 later had a new engine in it and had it on the road again.

So I put the key in, turn the ignition, and nothing happens. Crap.

I called up my dad, and luckily he was in the area. He came to me in the parking lot outside of the office building, and confirmed my thoughts - "bad starter."

So... because the truck has a manual transmission, it was possible to start it by getting it moving and then popping the clutch. This is exactly what we did. I put it in 2nd gear, pushed the clutch in, and my dad pulled behind me in his pickup truck. He pushed me around the parking lot until I picked up enough speed.. then I popped the clutch.

The clutch chirped pretty good (reverse torque, clutches aren't made to go that way), but the engine came to life. I drove the truck home to my garage, pulled it in, and immeditaely got it up on the lift. The lift was leftover from a local garage who got a new one installed. I picked it up for only $1200... not a bad deal at all.

The plan for tonight: Eat leftover spaghetti, rip the starter out, then try to find a working used starter in a local junkyard. If I can find one, I'll even put it in tonight.. but I think I'm going to have to send it out to get rebuilt tomorrow.

Luckily, I have another vehicle. It's my Race/Show car (2002 Pontiac FireHawk #133), but it never sees the rain.. and they want rain all week. I'm not anal about driving my Trans Am in the rain, but it doesn't have good street tires on it. I go to the drag strip alot, and run around on Nitto Drag Radials (a decent compromise between solid traction at the track and being street legal), which have VERY bad wet traction. The car has traction control, but 550 horsepower and traction control are virtually oxymorons.

Hopefully I can fix the "super trooper" tonight and keep my baby under her cover in the garage, away from the bad weather coming this way...

Woohoo! Another night without programming. I think I'm on a roll!

Time Management

| 1 Comment

I spent this weekend away from computers and away from programming. My girlfriend and I visited a zoo, went to a drive in, went to dinner, and all in all had a great weekend together. When we weren't spending time together, I was busy reading A Prayer for Owen Meany. It's one of those "classic" books that they try to make you read in school, but for some reason it slipped through the cracks in my educational process.

I try to read a few pages every night before falling asleep, and I've slowly been making my way through the pages. I'm horrible at time management skills. There are always a million things that I want to do, but never enough time to complete them all. Some days I'll sit and read 300 pages in an afternoon. Other times I'll program for 10 hours straight working on whatever it is I've convinced myself needs the most attention.

Flash Frame Loop Speed Tests

| 1 Comment

I'm sure someone else has done this already, but I just wanted to demonstrate something that many Flash programers might not know about.

When developing games, performance is usually one of the most important elements. This is especially true in action games, as user interaction needs to have almost a "real time" feel. In action games, there is typically a frame loop somewhere that does the processing. This handles things like getting user input, updating the users position, moving enemies, scrolling the background, etc. You want these frame loops to execute as fast as possible, for obvious reasons.

There are 4 basic ways that I know of to create a frame loop. There may be more, but they are probably more complex and slower than what I'm going to show you...

MTCodeBeautifier

| No Comments

Anyone have any idea why MTCodeBeautifier only works for me some of the time?

It worked in my post about Tiled backgrounds, but didn't work in my previous post. *shrug*

Also, it bugs me that the font size is smaller. Actually, it bugs me that I'm still using a MoveableType default template. One day I'll get around to changing it, it's on my "to do" list.

Busy busy busy

| No Comments

I apologize for the lack of updates lately.. life has been keeping me pretty busy and I've barely had time to breathe.

I plan on releasing SharpFlash to the community sometime in the next two weeks. I'm starting to get a little disenchanted with it (read: other projects are taking higher priority) and it's too cool of a project to just let die. I hope that once I release it some people will pick up on the development and continue on with what I've started...

I have a new project that I'm working on as well.. more details on that soon, it's almost in a stable state already. Almost...

So much to do.. so little time..

Tiled backgrounds

| 5 Comments

Someone on a Flash mailing list asked how to create an html-like tiled background out of a .gif. Here's a very quick little tutorial on how to do that.

  • Import the .gif file (File -> Import)
  • Click on the image, and press F8 (same as Insert -> Convert to Symbol)
  • Name the symbol "tile" (the symbol name is actually irrelevant, name it what you like), click the "MovieClip" radio button, and click the top left square next to "Registration." This places the origin in the top left corner. Click OK.
  • Select the tile Movie Clip on the stage and give it an instance name of "tile0_0_mc" (unlike the symbol name which you could make up yourself, make sure you use this as the instance name)
  • Set the coordinates of the movie clip to be at 0,0 (ctrl+alt+1, ctrl+alt+4 are the shortcut keys for this, or use the properties panel to enter 0 as the x and y coordinates)
  • Copy and paste this script on the timeline:
    for (var x = 0; x < Stage.width; x += tile0_0_mc._width) {
    	for (var y = 0; y < Stage.height; y += tile0_0_mc._height) {
    		targ = "tile" + (x/tile0_0_mc._width) + "_" + (y/tile0_0_mc._height) + "_mc";
    		// the if statement prevents us from having two tile0_0_mc's on the stage
    		if (x != 0 || y != 0) {
    			duplicateMovieClip(_root.tile0_0_mc, targ, ++_global.depth);
    			_root[targ]._x = x;
    			_root[targ]._y = y;
    		}
    	}
    }
    
  • Export the movie, and see your .gif become a tiled background!

Managing Flash Application States

| 1 Comment

If you're anything like me, you use the Flash timeline to control your application states. This is a fairly common approach, but what if you want to strictly control the states and their interaction with each other? When viwing a swf file, you can right click and select "Play." This advances the playhead, and it plays until it encounters a stop() actionscript command. The "Play" action will cause the movie to advance to a new application state, which in most cases is an undesired user action.

A quick way to prevent this from interfering with the way your application works is to structure your timeline something like this: application_states_thumb.jpg

To download the .fla file for this example, click here.

As you can see, I simply added a new "error" application state, and added another keyframe to each application state. On the keyframe, there is one line of actionscript telling the movie to stop at the error state.

This prevents a "malicious" or "just-experimenting" user from having more control over your application than you want them to by rigidly locking them into application states. It may not be the best solution around, but it's been working for me.

Ideally, you would like to force the user back to the state they just came from and prevent the "Play" action from happening at all. This can be accomplished by stopping at "_root._currentframe - 1", rather than the "error" state. The possible downside to this is code being executed again on the application state frame producing unwanted results. If you decide to use this approach instead, make sure you're careful when redirecting to the state they left so nothing gets executed "accidently."

SWFHeaderInfo 1.1

| No Comments

Thanks to a comment posted by one of my readers, I fixed a tiny (but problematic) bug in my SWFHeaderInfo class.

You can find the new file here. The link points to a zip file with the source and the library bundled together.

The error was an oversight on my part. When decompressing a swf file I neglected to close the file on the disk before returning a new MemoryStream. This prevented all access to the swf file because the file was marked as in use. The issue has been fixed, and I apologize for any inconvenience it may have caused!

ECMAScript 4 - strongly typed?

| No Comments

I just came across this link today (a week and a half late). ECMAScript 4 Netscape Proposal. One of the interesting things that jumped out at me is the typing of variables.

Flash ActionScript, an ECMA-262 language, is not typed. That is to say, declaring a variable and assinging it a new type does not yeild syntax errors, unlike some other common languages (Java, C++, etc).

var x = 1;
x = "new value";

... is perfectly legal. But, if the proposal is accepted, you would in theory be able to declare variables like this...

var x:MyType = new MyType();
x.foo();
// the above is the same as this...
var x = new MyType();
x.foo();

I say in theory, because there is no guarantee that ActionScript would be updated if a new standard was put into place. Actually, this is a big deal with ActionScript because the Flash 4 way of accessing variables is by using a colon...

_root.ball:color = red;

This is a big deal because currently the Flash player can play all previous versions of Flash content. If ActionScript becomes typed like in the new ECMAScript proposal, that would mean that Flash 4 movies would break. This would require multiple players to be installed on a computer to view all possible Flash content available. Either that, or everyone would be forced to update their old content to at least Flash 5 dot notation. There are probably some other options too, but I can't think of anything else off the top of my head.

This is a big deal again, because Flash 4 syntax is FAST. When creating games, I revert to Flash 4 style code because of great performance advantages, even though the coding style is deprecated (not to mention hard to read).

Anyway, this will be really interesting following along. Isn't it about time for Flash 7 yet anyway? I'm curious of the course Macromedia is going to take...

In the meantime, check out Peter's blog for an entry about strong-typing with Actionscript.

SharpFlash, under the hood

| No Comments

One of the ways I implemented the callbacks for SharpFlash lies in how the application was created. SharpFlash is a multi-threaded application. One thread is the Active-X control (the Flash player) and another thread is a socket server I created. Upon startup, the Flash player connects to the socket server, and when a function is done executing, the socket server sends a message to the flash client passing it the appropriate results. It's nothing overly complicated, but I thought it was a pretty clever solution. I'll post the client-side flash code for this sometime in the future. Jesse has a copy of the code, but it still hasn't quite stabalized yet, and I'm sure he's sick of me emailing him updates. ;-)

There are still some things I need to work out before releasing anything to the public. For one, because each application is it's own socket server, it runs a little slower than expected (not to mention it's all C# managed code here...). I have some optimizations in mind to improve performace, but I just haven't had the time to try implementing anything yet. Additionally, each server tries to use the same port (I just picked 5558 for kicks), only one program can run at a time. I'll need to modify the code to keep trying ports until one is found, then set a variable in the Flash movie so it knows which port to connect to. Either that, or I should try to create one instance of the server for all Applications that stays in memory until all "SharpFlash created" applications close. This is probably the best solution, but would require the most of my time to figure out.

Anyway, to tantalize some tastebuds, I decided to include a preview image of what I have working so far. I've just implemented the "title bar button" options tonight (i.e. you can now build .exe's without a close button, for instance). Check out the screenshot: SharpFlash preview - click to enlarge!

I think that's about it for tonight. Of course I have more to talk about, but I'll save that for another time as this is already getting long. I have a whole lot of things I want to do with this program, and I'm really excited about everything (gee, can't you tell?). I want to get it out the door ASAP, but I also don't want to release anything that's crap either. Either way, I WILL be releasing source with this, once it stabalizes, and I welcome the community to dive in on the development.

I envision this as being a great learning tool and application overall for the Flash community. I hope that people will be able to use this on an enterprise level in the future, once the feature buildout nears completion.

So much to do... so little time...

So much for programming...

| No Comments

I wanted to do some more programming tonight (of course, I'm a nerd, right?), but a coworker of mine needed help moving a "free" piano. We rented a U-Haul truck (one of those $19.95 ones) and I got behind the wheel. Needless to say, I was stylin' with my pimped out ride, and we had to beat the hunnies off of us with a stick. Oh, and I put free in quotes because when all was said and done (renting the U-Haul, paying for the miles, putting gas in it, eating, etc) it turned out to be a $50 piano. Hey, almost free is good enough too.

So that took up 3 hours of my time after work, and its getting late and I don't feel like thinking anymore tonight. I'm gonna hit the wieghts and just relax for the rest of the evening.

Oh, and I almost cried tonight... we went to this little Pizza shop at the 25th st. shopping center in Easton, Pa called "Antonio's." I ordered 2 slices (plain, of course) and at the end of the second slice my eyes started to get all watery. It might've been the red peppers, but I'd like to think that the pizza was just that good that it made me sad to think that there was no more left on my plate.

Goodnight all, I'll post up more tomorrow.

More Progress...

| No Comments
I was able to work on SharpFlash some more this weekend. It's slowly coming around, and I'm finally happy with the interface. Right now it supports the following methods:
sfWindow.getWindowTitle(callback, scope);
sfApplication.exit();
sfSystem.Dialogs.BrowseForFile_Open(fileName, typeFilter, intialPath, windowTitle, callback, scope);
sfWindow.hide();
sfWindow.moveTo(x, y);
sfWindow.setWindowTitle(windowTitle);
sfWindow.show();
sfWindow.toggleVisibility();

.. and I'm continually adding more.

Off the top of my head, there are a few features of Screenweaver that I don't know how to mimic. In no particular order, they are: multiple windows (I haven't tried to tackle this yet, it may be easier than I think), right-click menus, returning values from API functions (I can't get "var title = sfWindow.getWindowTitle()" to work - more on that later), transparent windows, and running more than one program at a time (this will be explained a little later too). However, everything else seems pretty straight forward and I'm happy with progress so far.

I hope I'm not violating any copyright laws here... I read that if you re-create something with your own code than you're not in violation. Being that I'm coding this from scratch, I think I'm alright... Does anyone know if this is the case? If not, then I'll have to re-work the API a little so it doesn't resemble Screenweaver's so much. I don't want to step on any toes, I just want to provide the Flash community with a killer app.

SWFHeaderInfo

| 2 Comments

As I was working on SharpFlash some more this weekend I came across the need to be able to read the width and height of a .swf file from the file itself. After some digging, I found a great reference for the file format (http://www.half-serious.com/swf/format/) and also noticed that the Macromedia documentation is wrong. The first 3 bytes of a compressed swf are "CWS" not "FWC".

Anyhow, I created a C# class for parsing the swf header, and exposing the attributes as C# properties. You can download it here. It works for compressed .swf files as well.

Example usage is in the main method. It looks like this...

SharpFlash, a first look

| No Comments

As I mentioned in my previous post, one of the projects that I'm working on in my free time has a working title of "SharpFlash". It gets its name because it integrates C# and Flash to form a single application. I'm so original it's not even funny.

It's still very much in the early phases, but I've made a lot of progress with it so far. The idea behind SharpFlash is that it exposes a rich API in Flash to allow .swf movies to interact with Windows when making standalone .exe's.

First Post

| No Comments

The first post of any weblog is almost the most crucial. It sets the tone for all of the posts to follow, and is supposed to generate interest to keep everyone coming back. In the spirit of that, let me not bore anyone by details about who I am or what I do. I want you to come back, so the less you know about me the better.

And on that note, why should you come back if you don't know anything about me? Well.. I guess "because I said so" isn't a good enough answer. I don't really have a good answer for that. I'm a computer programmer, doing a lot of work with a lot of different programming languages. Somehow I managed to become the "Senior Flash Developer" at Binney & Smith, Inc., but that isn't all that I do.

I also develop in ColdFusion, SQL, Java, and dabble in C# mostly for personal experience. In college (I just graduated with high honors from Lehigh University May 19th, 2003) they taught me a lot about Software Engineering and C++. I have a B.S. in Computer Science. Yipee. Bored yet?

Anyway, I think that's enough for now. I have a lot of cool projects I'm working on, and in the future I'll be releasing source code for my little project called "SharpFlash." SharpFlash is a Flash Wrapper written in C# (.Net) that enables the creation of Flash applications on "steriods" (much like Screenweaver). More about that later...

Thanks for stopping by, drop in again in a few weeks to see what I've been up to.

Flex.org - The Directory for Flex

Archives