Archive for the 'ActionScript' category

Flash and Me

Apr 23 2014 Published by under ActionScript, Flash

Today I tweeted a link to another stupid linkbait article proclaiming that Flash is dead. Of course, this set off a huge flurry of tweets about whether or not Flash is still breathing. And it made me realize that I haven’t made my current position on Flash very clear.

The fact is that I have no longer have any interest in Flash or ActionScript as a platform or language. While I did do some work with ActionScript and mobile AIR development while I was at Disney, I don’t think I’ve done any personal Flash development in two or three years. I don’t have Flash Authoring or Flash Builder or any other Flash development tools on any of the computers that I currently use.

But I’m not a Flash hater. I know a lot of people who jump started their development careers with Flash and have moved on and now rant and rave about how horrible it is and always was and how much they hate it now. I’m not in that camp. I have lots of great memories about Flash – both the technology and the community that it created.

So why did I jump ship? Short answer, I don’t see it as a viable, evolving technology for the future. That’s not the same as it being dead though. I look at it more that Flash has gone into retirement. Now, people who go into retirement are not dead. Many continue to have long, healthy, happy lives for decades to come. Some continue to do many productive things, have great experiences and learn new skills. But generally speaking, they’re not graduating college and looking for a new job to start their career. They’re winding down.

That’s where I see Flash. It had its Golden Age, and it was awesome. I’m super happy that I was a part of that. But that’s over. That doesn’t mean that it’s dead. In fact, Flash still does all the stuff that made it awesome, and does it as well as it ever did. It even continues to get some new features. And you can still use it for all that stuff. And many people still do, and they make a living at it, and likely will continue to be able to make a living at it for some time.

But, as I said, it’s not a viable, evolving technology. Looking at my years as a Flash developer, I started out with Flash 4. Flash 5 had groundbreaking changes and improvements. Eighteen months later, Flash MX blew everyone away with new features again. Flash MX 2004 gave us ActionScript 2.0. The next bunch of improvements get a bit hazy due to the player versions getting out of sync with the authoring versions, but we got BitmapData and crazy audio and video improvements, ActionScript 3.0, Flex, Flex/Flash Builder, Flash Catalyst, basic 3D and then Stage3D, and on and on.

But in the last few years, there has been nothing like that. Yes, Stage3D continues to get improvements, and AIR continues to get updates. And there are things here and there, but as an overall ecosystem, I feel like it’s largely in maintenance mode. I know people will deny this and start posting long lists of recent updates and improvements. But you can’t tell me that Adobe is anywhere near as committed to the future of Flash than it was 10 or even 5 years ago.

Where is Flex? Where is Flash Mobile? Where is Flash Catalyst? Where is any sign of Flash on Linux? (hint: gone, gone, gone and gone.) What is in store for the next version of ActionScript? (hint: there is no next version of ActionScript planned.) What improvements are upcoming for Flash Builder? (hint: none.) How many people were on the Flash team a few years ago and how many are on it now? (hint: fractional.) How is the Flash Platform monetized? (no hint. no clue.) How many people do you know who were full time Flash developers 5-6 years ago who don’t Flash at all now? (hint: a LOT.) How many of the numerous Flash conferences from 5-10 years ago are still held, and have not changed their name to exclude the concept of Flash? (hint: zero.)

I know I’m now sounding like a Flash hater, but I’m really not. These are all just facts. Adobe is committing a small fraction of the resources it used to to the Flash Platform. It has cancelled most of the projects and products related to the platform. Almost every person I know who worked on the Flash team back in the day has either left, been laid off, or has moved onto other projects. Most of the Flash developers I know personally from years ago are now doing iOS, HTML/JavaScript or other development – exclusively in most cases.

Now, I know people are going to come on here and tell me how great Flash still is. Yep, I already said that. They’ll say that it is still innovating with new features. I covered that. They’ll talk about how great it is for games. No argument. Then they’ll go onto say how much HTML and JavaScript sucks. They’ll say how you can’t make apps with it and you can’t make games with it and you can’t really do anything with it because it isn’t strictly typed and doesn’t have private vars audio support sucks and blah blah blah. I’m not going to respond to those people. Only going to roll my eyes and feel a bit sad for them.

Long, long before I was into development, long, long before most of you were into programming either, I knew a guy who was a programmer. An MIT graduate. He was really proficient in some particular language being run on some particular system. I can’t tell you what language or system because at the time, I couldn’t tell you the difference between C and BASIC. But he was one of the best at this system. He had this great, really well-paying job doing it. He worked there for years. Had it made. Then the company upgraded to a new system with a new language that he knew nothing about. So he was out of a job. And he went to look for a new job. And he realized that absolutely nobody used that old system or language anymore. He was so confident and complacent at his old job that he never bothered to learn any new language or system. Now, all his skills were completely obsolete and he could not get a new job. I think he wound up doing data entry somewhere. This is not a made up fable. This was a real guy that I knew well. I don’t want to be that guy, so every once in a while I put aside my likes and biases and take an honest look at the landscape around me and decide where technology is going so that I don’t paint myself into a corner. And that’s why I stopped doing Flash.

90 responses so far

Syntax

Apr 14 2011 Published by under ActionScript, Components, Flash, iPhone

Doing some Android dev these days. Needed to check if a editable text field was empty or not. I had to dig around to find out how to do this. It turns out that an EditText’s getText() method returns an instance of Editable. You need to convert this to a string and then call equals(“”) on it. So you get this:

if(myText.getText().toString().equals("")) {...}

The similar thing in Objective-C would be:

if([[myText text] isEqualToString:@""]) {...}

And in ActionScript:

if(myText.text == "") {...}

I’m going to hold my tongue here, and let you make your own judgments. But as a person who created MinimalComponents, I bet you can guess where my preference lies. 😉

37 responses so far

Ubuntu and Me, Happy Together.

Feb 02 2011 Published by under ActionScript, Flash, General, Technology

I tweeted today about this being my second full day on Ubuntu and it a bunch of responses from people wanting to know how I did this or that, what my experience was, etc. So here’s the story.

For a while, I’ve been wanting to set up a home server. For backups, file storage, and to learn a bit more about server administration and server side programming. It’s a big gap in my knowledge base. I also wanted to get back into Linux. I’d fist messed around with Linux back in the mid 90’s, downloading RedHat onto something like 18 floppy disks via a 14.4 modem in order to install it. Back in the good old days when you had to install your own window manager and configure it by editing config files. I know you can still do that, but back then it was the only way to do it. Finally, I wanted to get back into hardware. From my very first PC (after graduating from a Commodore 128 and Amiga 500) up until my first laptop, I had built all my own PCs from scratch. I’d start with some cheap or free used PC and upgrade it bit by bit until it was a nice machine. It would often wind up with some friend or family member and I’d start over.

The Linux portion of this whole thing got rekindled recently, in my switch over from MediaTemple to Dreamhost. I was messing with DNS settings and MX records and SSHing into both servers and running SQL queries to back up and restore this blog’s database, since it was too big to handle by the WordPress export/import system. I amazed myself with what I accomplished and learned in that whole process, and wanted to dive into it more.

So at some point a few weeks ago, I pulled up an old box I had rusting in the basement and tried to boot it up. Apparently it had rusted a bit too long and either the CPU or something on the board was fried. I went onto Amazon and bought a motherboard and cpu, along with some RAM, a 2 TB hard drive, and a DVD player/recorder. I had a bunch of unused gift certificate money on account, so it technically didn’t cost me a dime, but came to about $300 something total. The components trickled in and I sadly realized that I was the owner of a micro ATX case, and a full ATX motherboard. So back to Amazon for a nice case.

The case arrived and I realized that my power supply had only the IDE type connectors, no SATA connectors, which I needed for my drives. I picked up a new power supply locally and I was in business. Since then, I added a new fan, a fan control unit, and a memory card reader. Here’s the building in progress:

The empty case with power supply:
IMG_0687

The motherboard installed:
IMG_0688

And the CPU and fan:
IMG_0689

All the front panel stuff wired up:
IMG_0690

Everything in place:
IMG_0702

Wide shot:
IMG_0703

Cover on:
IMG_0701

And a front view:
IMG_0699

I had a real blast building this, shopping around for parts, learning about different boards and chips, formats and standards. Stuff that I’d forgotten a lot about. For those who are interested, the specs are:

MB: Intel Media Series ATX Motherboard BOXDH55HC
CPU: Intel Core i3 Processor i3-540 3.06GHz 4MB LGA1156 CPU BX80616I3540
RAM: Corsair 4GB Dual Channel Corsair DDR3 Memory for Intel Core i5 Processors (CMX4GX3M2A1600C9)
HD: Western Digital 2 TB Caviar Green SATA Intellipower 64 MB Cache Bulk/OEM Desktop Hard Drive WD20EARS
Case: Cooler Master RC-310-BWN1-GP Elite 310 ATX, MATX Mid Tower Case with Window (Black/Blue)
Fan Controller: Scythe “KAZE MASTER ACE ” 5.25″ Bay Fan Controller- Black (KM02-BK)

Not a top of the line system, but decent enough, with lots of room to grow.

Software

Now that I had a box up and running, time to install some stuff. I went with Ubuntu 10.10. Installed VirtualBox and pulled out my old Windows install disks and set that up with Windows 2000, Windows XP, and Windows 7. The first two, mostly just because I could, and because I have 2TB of disk space to play with. Actually 3TB, because I salvaged another 1TB drive out of another device I wasn’t using.

I opened up ports for VNC, SSH, and HTTP, and set it up with www.dyndns.com so now I can access the machine from anywhere and do just about anything with it. Really having a blast exploring all the options.

Back to Ubuntu

All right, this is what I started to write about in the first place. I really enjoyed using Ubuntu on my server. I sat up in the living room SSHed or VNCed into the server, exploring stuff, installing new programs, finding out what I could do. It was great, but VNC is VNC. I set up VirtualBox on my PC and ran it from there as well. After a couple of weeks of doing both, I decided to make the jump to a full dual boot Ubuntu system. That’s what I did over this past weekend. It went very smoothly. I now had a dual boot system that defaults to Ubuntu, but also has Windows 7 as an option.

My next goal was to see if I could use Ubuntu full time as my main OS. For playing around, it was just fine, but if I was going to use it day in and day out, I needed to have a bunch of stable, viable, usable applications for doing all my day-to-day stuff. What amazed me was just how many of the apps I use on a regular basis have Linux versions. I don’t mean similar apps that do the same basic thing, but actual Linux versions of the exact same programs.

For example, I use Launchy as a task launcher, RapidSVN as an SVN UI, Tweetdeck for twitter, KeepassX for passwords, Skype for … Skype. all of these have Linux versions that I was able to install right off the bat. Made me feel quite at home and comfortable.

I’ve been making heavy use of Google Apps, having switched over my BIT-101.com email to Google apps. So mail, calendar, RSS, and documents were a no brainer and completely seamless. Chrome works fine on Ubuntu, too. With all that down, I felt I was almost able to make the switch. The big thing was going to be Flash/Flex/AIR development.

Obviously, CS5 does not exist on Linux yet. Nor does Flash Builder. But the Flex SDK and MXMLC works just fine there. You just need something to write your code in. There were two main choices – FDT and IntelliJ Idea. Both of which I happened to have licenses for. While IntelliJ is pretty awesome, it’s so different from Flash Builder, which I am used to, that I found it hard to really get comfortable with. FDT is Eclipse-based, like Flash Builder. The devil you know… as the old saying starts. So I decided to go with FDT.

Getting it set up was fairly easy, and I was hello worlding before I knew it. But the project I’m in the middle of presented a much bigger challenge – not a straight AS3 web project, but a Flex based, full screen AIR application that will be deployed on a kiosk. If I could get this going with FDT on Linux, I was home free. Some serious problems lay ahead. One was that I needed a debug player for 64 bit Linux. I dug one of those up somewhere – maybe labs? Then I was having problems with my embeds. Something is handled different on Windows and Linux with paths. I finally figured out I just needed to add a “../” in front of the embedded asset path. Not sure why it’s different. But that path works in both Windows and Linux, so it’s probably the “right” way. Next up was run/debug configurations. In FDT, if you are editing any class and you do a run or debug, it will create a run/debug configuration with that class as the main application. This is very different than Flash Builder, where you set the main application class and it will always use that. I finally worked through a couple of tutorials on the FDT site that straightened me out. Basically, you need to create your own configuration, and then, in preferences set Eclipse to always use the last configuration if one is unspecified. Handled.

The final problem was with AIR. All kinds of weird errors going on there. But no AIR file launching. After much searching, I finally realized that AIR SDK that you get when you download a Flex SDK is only good for Mac and PC. You have to go here and download the AIR SDK for Linux. I’m not sure how you are supposed to integrate the two of these things, but what I did was to go into the bin folder of my flex sdk folder, and remove adl, adl.exe, adt, and adt.bat, and replace them with the adl and adt files from the linux sdk. This is probably a very half-assed solution, but it actually worked. If anyone has any more robust directions, let me know, but with all of the above, I am now compiling and debugging my app without a hitch. I’ve also got MinimalComps compiling its swc using FDT, and the next release will be produced that way.

As for the time line on all this, I started trying to compile the app on Monday morning, but ran into all the problems mentioned above, so had to retreat back to Windows so I could get some work done for the day. I went home Monday night and worked through all the solutions I just mentioned. Tuesday I went to work and booted up Linux and haven’t looked back. That’s two full, very productive work days on Ubuntu alone, building a Flex based AIR app. I’d call that a success. I’ll definitely be finishing out the week on Ubuntu and heading into the sunset with it. 🙂

A bunch of people on twitter asked me about Flash, Photoshop, and the Creative Suite in general. The answer is that I don’t use Flash CS5 all that much. Well, actually I do use it fairly often, but not for long periods. I’ll fire it up to test out some snippet of code or spike out some idea. it’s great for that. But once the idea moves into something serious, it always gets moved into a more serious development environment. I will kind of miss that. Currently I’m looking into wonderfl.net to fill that gap. I’m not saying this is a solution for everyone. If you do a lot of timeline or library stuff, you really need Flash. For me, I just need a way to fire up something and lay down some fast code and see what it does without creating a workspace, package, classes, etc. wonderfl may serve that purpose in many cases.

As for graphics stuff, I haven’t run into a need for that yet in the last few days. Fireworks has been my weapon of choice for several years. I’m not sure what my solution will be for that yet. Naturally, when you think “Linux” and “graphics”, you think “Gimp”. It’s been years since I touched that, but I imagine when the need arises, I’ll look at it again, and then look around to see what else is out there too.

There’s also the possibility of running Windows on VirtualBox and installing CS5 in there. I think VirtualBox is great for some stuff, but large, resource heavy programs like Flash and Photoshop… the idea of those running in a VM scares me. I’ve tried running Visual Studio 2010 for Windows Phone stuff there, and it’s pretty slow. Also the Windows Phone emulator refuses to work in VirtualBox. An emulator in a virtual machine… go figure. Then there’s Wine, which may be able to run Some CS programs. I can’t speak for how successful that might be. My bottom line thought is that if you are REALLY dependent on Creative Suite programs and use them heavily day to day, Ubuntu is not the OS for you. You’re just setting yourself up for frustration.

On the PC I’ve been using Putty for SSH and TightVNC for VNC. Ubuntu has SSH and VNC capabilities built in, so that was easy. For IM, I’m using the built in Empathy client, which seems to handle my multitude of IM accounts perfectly well. Finally, you can’t work without some sounds of one kind of another emerging from your computer and into your ear holes. I go back and forth between podcasts and music. Ubuntu has RhythmBox preinstalled. It’s OK, but I’ve been checking out others. I’m pretty happy with Banshee at the moment, but will probably keep exploring.

After just two days, I’m already looking at editing my partitions to give Ubuntu some more room, and moving more of my files over to the Linux side. I need to keep the dual boot setup at least for my Windows Phone development, as I have one project half done, and will probably do some more stuff with that. And it’s just not happening virtually.

At any rate, as I also mentioned on twitter, if you are a professional developer, you really need to have access to a Windows box and a Mac, one way or the other, virtual or physical. I think any professional developer who bitches about this or that operating system or platform or language or device and sticks to one single platform, refusing to touch anything else is childish and unprofessional. At the very least, it’s a pretty poor long term career attitude. Learn more. Experiment. Try something new. You’ll be a better person for it. It’s fine to be an expert in a specific area, but don’t paint yourself into a coffin. (you like that one?) In addition to my home server and my dual boot laptop, I have a Mac book at home and a Mac book pro at work, both plugged in and ready to go. I have three fully charged phones within arms reach – my iPhone, Nexus One, and Samsung Focus (WP7). I don’t like to get too comfortable with any one thing. I feel like I’m stagnating. I used my Windows Phone for the last 3 months. Now i’m carrying the iPhone again, just for a change. What makes you more valuable – the fact that you can make a good snide remark about how much platform X sucks as compared to the platform you use? Or the fact that you can sit down and be comfortable and productive in any platform? Which makes you feel more confident?

Sorry. Got a little preachy there. Just get tired of hearing about technology wars when there is so much awesome and exciting stuff to learn and play with. Now more than ever. End of rant. Try Ubuntu. You might like it.

38 responses so far

More MinimalComps updates

Jan 27 2011 Published by under ActionScript, Components, Flash

A couple of things today.

First is on adding content to Windows and Panels. By default, if you added a child to one of these, it would just add it like any other child, positioning it from the top left of the parent’s position. In particular on the Window, this forced you to reposition your content so it wasn’t on top of the title bar. Also, in either case, if your content was larger than the parent, it would march on outside of the bounds of the parent.

To handle this, I created a content property on these components, which was positioned correctly, and masked the children added to it, so it looked correct. The recommended way of adding children to Panels or Windows was thus:

window.content.addChild(btn);
panel.content.addChild(myRadioBtn);
// etc.

or…

new PushButton(mywindow.content, 10, 10, "click me");
new RadioButton(mypanel.content, 10, 10, "option 1");
// etc.

Unfortunately, this just wasn’t very obvious, and in retrospect, pretty stupid. The proper way would be to override addChild to add the child to the content automatically. So, that’s what I did. I also added a new addRawChild method to each of these components, in case you are doing some custom hackery that really required adding children to the component itself. The following should illustrate the change:

If you were already using content, you won’t see any changes, but you don’t need to use it any more. If you were adding children with addChild and repositioning manually, you’ll probably need to adjust your code to remove those manual adjustments, again, particularly on the Window.

This change also applies to Accordion and Scrollpane, which are based on Panels and Windows.

I also adjusted MinimalConfigurator to account for this, which mainly means I was able to remove the code that checked if the parent had a content property. Now it can always just addChild.

The next change was something else that’s been bugging me for a long time – the PushButton down state. It added an inner drop shadow, but otherwise was not very visible, particularly when using toggle = true. It wasn’t very obvious when a button was toggled in the down state.

So I added a new property on the Style class: Style.BUTTON_DOWN, which is used to redraw the button face when it is down, making it slightly different and much more noticeable. I added values for this to the light and dark themes. If you’ve created custom themes, you can add this to it.

SVN has been updated, and a new SWC and zipped source package have been uploaded to Google Code.

ps. If you used MinimalComps and want to join the conversation, check out the new Google group.

2 responses so far

MinimalComps Google Group

Jan 22 2011 Published by under ActionScript, Components, Flash

As suggested by Vic C, I’ve set up a Google Group for MinimalComps. Discuss, request, share.

http://groups.google.com/group/minimalcomps

One response so far

MinimalConfigurator.getCompById

Jan 22 2011 Published by under ActionScript, Components, Flash

Just added a new feature, as suggested by Karim in the previous post. This saves a hash of all components that have id attributes, and then allows you to find any component by its id. Here’s an example:

package
{
	import com.bit101.components.*;
	import com.bit101.utils.MinimalConfigurator;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	public class Playground extends Sprite
	{
		private var config:MinimalConfigurator;
		
		public function Playground()
		{
			Component.initStage(stage);

			var xml:XML = <comps>
							<PushButton id="foo" label="hello" event="click:onClick" x="10" y="10"/>
						  </comps>;
			
			config = new MinimalConfigurator(this);
			config.parseXML(xml);
		}		
		
		public function onClick(event:Event):void
		{
			var btn:PushButton = config.getCompById("foo") as PushButton;
			btn.label = "goodbye";
			trace(btn.name); // foo
		}
	}
}

Also, it maps the id to the component’s native name property, in case that might be useful.

All in all, this allows you to access multiple components without having to make a bunch of public variables.

4 responses so far

MinimalComps Updates: Dark Style, HBox & VBox alignment

Jan 20 2011 Published by under ActionScript, Components, Flash

A couple of updates to MinimalComps.

First, go over to soulwire and check out the great GUI tool created there. One thing that struck me about it was the dark colors on the components. I liked it and set out to create a similar theme by setting dark values on the Style class. Easy enough. But I didn’t want to go through that every time I wanted to create the same look, so I added a new method on Style, called Style.setStyle. This can be “light” or “dark” (Style.LIGHT or Style.DARK). If you don’t set it, or set it to light, you’ll get something like this:

But with one line:

Style.setStyle(Style.DARK);

you can instead have this:

I like it a lot. If you haven’t used the Style class before, It’s just a list of static vars containing colors that are used whenever a component draws itself. Setting a value on Style does NOT update anything that’s already created, until that component re-draws itself, if it ever does. You should set your style values BEFORE you create a single component, and not change them, unless your’e going to take responsibility for redrawing anything. Same goes for this new method. If anyone comes up with any other useful preset styles that look decent, send them over and if I like them, I may add them to Style. And you’ll win a free set of Minimal Components!

The other change I made is to the HBox and VBox. These have really been bugging me because HBoxes always top-align their contents, and VBoxes always left-align their contents. You can set the x position of an element in a VBox and the y position of an element in a HBox, but it was tricky and non-dynamic. Now they each have an alignment property. This can be top, middle, bottom, or none for HBox and left, center, right, or none for VBox. These are static constants on the respective classes as well (HBox.TOP, HBox.MIDDLE, etc.).

The default alignment for both is NONE, meaning that they’ll work the way they always have. Left and top aligned, unless you’ve set the x or y property of an element as just described. If you set the alignment to anything else, it will ignore the current x or y property and align them exactly as you would expect. Here’s a demo:

Get Adobe Flash player

All these changes are checked into SVN. I have one other thing that I’m working on before I go and release a new SWC though.

10 responses so far

SWFSheet – create sprite sheets from SWFs

[EDIT: Just released a beta of SWFSheet 1.1 here: http://www.bit-101.com/blog/?p=2948]
[EDIT: Version 1.1 final released: http://www.bit-101.com/blog/?p=2977]

SWFSheet is a program I created in most of a day back in late December. I finally polished it up this week and it’s now ready for release. The idea is to take an animation created in Flash, and generate a sprite sheet from it. A sprite sheet, for those of you who may not be familiar, is a single large bitmap containing several frames of an animation, usually layed out in a grid. These can be loaded in very efficiently by games, and each frame shown to recreate the animation.

I had the idea for this program while attempting to port some Flash stuff to the iPhone. And later while making other mobile games, I found that Flash was still the best tool to create animations. It has a powerful time line, easy to use drawing tools, tweens, 3D, and of course, powerful scripting with ActionScript. However, getting a nice looking Flash animation into a sprite sheet that could be used with cocos2d on the iPhone/iPad or with XNA for Windows Phone 7 was not so easy. I did it by hand a couple of times, and it wasn’t very fun. Thus, SWFSheet was born.

SWFSheet is an AIR application and has been tested on Windows and Mac. You create your SWF however you want. Flash CS5 or earlier, Flash Builder, or anything else that outputs a SWF. It doesn’t matter how it’s created. Then you load the SWF into SWFSheet.

swfsheet screenshot

Immediately, you’ll see the live loaded SWF running in the upper left panel. The program will then capture an image of the SWF on each frame for the number of frames you have specified (default 15) and arrange them in a grid on the bitmap. Once that is done, it will then animate this bitmap using the same techniques you would use to animate a sprite sheet in a real game. This is seen in the lower left panel. You can adjust how many frames you want to capture to make sure you get your whole animation and have it loop smoothly. And you can adjust the frame of exactly how much area is captured in each frame, to maximize space on the bitmap. If there is not enough space to capture all frames, you can choose a larger bitmap. After any changes, you need to click “Capture” to re-capture the frames based on the new settings.

Often when scripting animations, you will have various transformations or other changes happening in an onEnterFrame type of loop. This can sometimes cause a glitch, as the first frame is captured before the first enterFrame handler fires, and thus does not have the initial transformations applied. There is a “Skip first frame” checkbox which handles this situation. There are also options for smoothing, which may or may not make any difference in a specific animation, and for transparency. By default, a loaded in SWF will have a transparent background, but you can override this to make an opaque bitmap with any color background you want. And you can change the preview frame rate – of course this doesn’t change the bitmap at all, but can give you an idea what your animation will look like at your target frame rate.

Note that there are a limited number of sized of bitmaps. Sprite sheets can almost always take advantage of extra efficiency when created in power-of-two sized squares – 64×64, 128×128, 256×256, etc. Thus, these are the only choices. A future version may make possible custom sizes if enough people ask for it.

Here’s the AIR installer:

SWFSheet Installer

And here are some test files to get started with:

Test Files

Enjoy!

ps. Another tool you might be interested in is Mike Jones’ Sprite Sheet Maker, which is more geared to making sprite sheets from a series of separate image files. Similar outcome, different use cases, depending on what kind of input you are starting from.

76 responses so far

Good bye 2010

As usual, it’s time to make my year end post. I’ll keep it relatively brief.

A few changes this year. This spring, I got kind of fed up with Apple, their control-happy policies, and the general direction they are heading. After 3 years of being 100% Mac, I switched back to Windows. It is an action that I not only do not regret the tiniest bit, but as Apple continues to evolve in the same direction, I’m happier than ever that I switched when I did. This is not to say that I’ve abandoned all iOS development and have thrown away my Mac. I still own two Apple computers. Both are plugged in and booted up and ready for action at all time. I have an iPhone, and iPad, an iPod Touch and a 5G iPod. They aren’t going anywhere. But the machine I open up in the morning and use all day long is my Sony Vaio, and I’m very happy with it. I’m not shoving it down your throat. If you’re happy with Apple, far be it from me to try to change your mind. I’m OK, you’re OK, right?

Around the same time I switched back to Windows, I also came into the ownership of a Google Nexus One. It took a while to really get used to it, as it’s definitely not the polished experience that the iPhone is. But I forced myself to stick with it for a week or so and really started to love it. From my viewpoint, the main difference was that it was MY phone, not Steve Jobs’. I could do pretty much whatever I wanted with it. Change the lock screen, change the task switcher, add memory, change the battery, put my icons where I want them, install unsigned apps, have live gadgets on the home screen, etc. etc. Once I got used to it, the iPhone just seemed unbearably sterile. Unfortunately, the model I had was a T-Mobile version, so I couldn’t get 3G on it with my AT&T sim. I suffered with Edge for a several months, but finally the wifi connection and even the Edge connection started getting really flaky. One day in September, just couldn’t connect to anything, so it was back to the iPhone.

Coming back to the iPhone, I have to admit, I really did appreciate the slickness of the UI. But I didn’t fall back in love with it. To be honest, I knew it was only a stopgap until the new Windows Phones came out. I got a Samsung Focus as soon as they came out and I absolutely love it. It is without a doubt the best phone I’ve owned. Note – it’s far from perfect. It’s a v1 product and it shows in many ways. But regardless of all that, there is so much RIGHT about what Microsoft did with it. I’m really excited to see where it goes in the coming years. I don’t expect it to overtake or even match Android or iOS any time in the near future, if at all, and I don’t really care. As long as I can continue to own one and see it improve, I’m a happy camper.

As for mobile development, I didn’t do much at all most of the year. But this autumn and winter I worked on one major and one minor iOS projects at Infrared5. After being away from Objective-C for so long, it was pretty bizarre trying to get back into it. It took a couple of days before it stopped feeling like I was typing with my toes, but eventually I got back in the groove. I played with Android dev briefly, but never really dove into it that much. But in October, I got my hands dirty with Windows Phone dev, with both XNA and Silverlight, and it has blown me away. I might even say it’s revitalized me as a developer. For a large part of the year I was on a very tough, frustrating project. It wore me down quite a bit. But with Visual Studio and C#, it’s like starting from scratch – in a good way! All the excitement without the learning curve. After many years of Flash development, writing ActionScript is almost second nature to me. But after just a couple of months in Visual Studio, I feel like I’m more at home with C# than I ever was with ActionScript. It’s a very, very similar language. If you took AS3 and removed all the little things that annoy or distract you and pull you out of the “flow” of coding, and replaced them with a whole bunch of little things that just work exactly the way you would expect them to, you’d have C#. And if you took Flash Builder and … no, that’s just not going to work. There’s no comparing Eclipse to Visual Studio.

Speaking of IDEs, after working in VS for a few months, and then going back to XCode… it really dawned on me just how bizarre an IDE that really is. I’m really trying not to bash any particular technology, but I can’t help feeling like XCode was designed on an anti-matter planet in an alternate universe by some bizarre aliens on really strong acid. I’m not even talking about the language – just the IDE. I sometimes find it hard to believe that it was created by and for programmers. I know it’s not “wrong”, just different. Most IDEs are relatively similar, like most western human languages are pretty similar. I may not speak Spanish, but I can see it and read the words even if I don’t know their meaning, and can catch a bit of a hint of what’s being said. Same with most IDEs – you can quickly find your way around them for the most part. But diving into XCode is like being dropped in an Asian or Middle Eastern country where everything just looks like random scratchings or scribbles to your unfamiliar eye. That’s what XCode is like – just a completely foreign programming paradigm. Again, not saying it’s bad or wrong. You live with it long enough and you become fluent in it. But boy is it different.

Also in the summer I got into Processing quite a bit. Far more than I ever had before. I’ve kind of drifted from it again, but it was a great experience. I’m sure I’ll drift back around to it again before long. This largely came about from my conference session for 2010, “Programming Art”, in which I covered a bunch of different tools and languages for creating algorithmic and generative art, including Context Free Art, Structure Synth, Processing, the Hype Framework, and others. I also really enjoyed getting my head around Structure Synth, and got a bit revived on it just recently with the newly released integrated raytracer. Fun stuff!

On a personal basis, it was a year of health. I ran over 1000 miles, lost a good deal of weight, and reverted the trend of my blood sugar and blood pressure, which were edging into borderline problem areas. I think I also did more travelling this year than I have in any previous years, with trips to San Francisco, Minneapolis, Kortrijk Belgium, Toronto, Japan, back to San Francisco, and Edmonton.

Well so much for keeping in brief. In summary, it was a year of trying new things and going back to old things, learning new platforms and languages. Going forward, I don’t think it’s possible, at least not for me, to be a “Flash Developer”, or an “iPhone Developer” or be stuck in any single platform. Now more than ever, there is just too much diversity and you have to have a foot in every camp. If someone needs a game or an app these days, they can’t really just release a single version of it. They’re going to need an iPhone version, and Android version, eventually a Windows Phone version, and some kind of web presence with it. Are you going to just ask for one slice of that pie? Are they going to farm out their app to 4-5 different shops, one for each platform? As a company at the very least, you need to be able to do it all. Ideally as a developer as well, you need to be able to do as many of those as possible. I know that’s where Adobe is trying to be strong with the iPhone and Android packagers for Flash. I’m still not convinced those are the solutions for most projects though. Native will always win.

As for 2011, I assume the fist good chunk of the year I’ll be doing a lot more WP7 dev. And since the XNA codebase is 99% the same for WP7, Windows, and XBox games, I look forward to releasing some stuff for Windows desktop and XBox as well. I’m sure I’ll also play with the new Mac App Store stuff, and more iOS stuff too. The WP7 game I’m working on now will definitely need an iOS port. But who knows where I’ll go from there?

8 responses so far

Using MinimalComps’ Scrollbar

Dec 20 2010 Published by under ActionScript, Components

The scrollbar component in minimalcomps was never really meant to be used as a standalone component. This is not to say that it can’t be, it’s just that the interface doesn’t really have the same simplicity and ease of use as the other components. However, a few people have asked about it, so here’s an example of how to use it.

First we’ll need something to scroll. We’ll create a sprite with a bunch of random lines and give it a scrollrect so that it has more content than it can show.


var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xeeeeee);
sprite.graphics.drawRect(0, 0, 100, 500);
sprite.graphics.endFill();
sprite.graphics.lineStyle(0);
sprite.graphics.lineStyle(0);
for(var i:int = 0; i < 100; i++) { sprite.graphics.lineTo(Math.random() * 100, Math.random() * 500); } sprite.scrollRect = new Rectangle(0, 0, 100, 100); addChild(sprite); [/code] I'm omitting all the imports. If you're attempting this, I assume you know how to import classes. If not, stop now and learn some AS3. 🙂 OK, now we'll create our scrollbar and put it just to the right of the sprite, and give it an event handler for the scroll event. [code lang="as3"] var scrollbar:VScrollBar = new VScrollBar(this, 100, 0, onScroll); function onScroll(event:Event):void { } [/code] This should look right, but won't do anything. We need to do 4 things to make it functional: 1. Set the thumb percent - i.e. how big the sliding button is, as a percentage of how big it could possibly be. By default it's 1.0, meaning it fills the whole area. You'll need to calculate this yourself, and it's generally the visible area of the thing you're scrolling, divided by the total size of it. In our case, we can see 100 pixels of the sprite, but it's height is 500. So we can say: [code lang="as3"] scrollbar.setThumbPercent(100 / sprite.height); [/code] 2. Set the maximum value of the slider. This is the most you want the object to scroll. Again, this takes come calculation. Generally, it's the total size minus the visible area. The sprite is 500 pixels high and we can see 100 pixels. So 500 - 100 = 400. [code lang="as3"] scrollbar.maximum = sprite.height - 100; [/code] 3. Customize how much you want the scrollbar to move when you click on the buttons or the back. The lineSize property controls how much it will move when you click on the up or down buttons, and the pageSize controls how much it moves when you click on the back. Generally lineSize is fine at 1, but you can bump it up to make things scroll more. And pageSize is usually the same as the visual area, so 100 in this case. In some cases you might want to make pageSize a bit less, so you have some overlap. This is up to you. [code lang="as3"] scrollbar.pageSize = 100; scrollbar.lineSize = 1; [/code] 4. Finally, you have to implement the event handler for the scroll event to make use of the new scroll value. In this case, we're changing the scrollrect to make it's top value equal the value of the scrollbar: [code lang="as3"] function onScroll(event:Event):void { sprite.scrollRect = new Rectangle(0, scrollbar.value, 100, 100); } [/code] See what I mean? Not exactly rocket science, but not exactly "minimal" either. But there you have it. If you need to use it, go for it. Here's all the code together: [code lang="as3"] import flash.display.Sprite; import flash.geom.Rectangle; import com.bit101.components.VScrollBar; import flash.events.Event; var sprite:Sprite = new Sprite(); sprite.graphics.beginFill(0xeeeeee); sprite.graphics.drawRect(0, 0, 100, 500); sprite.graphics.endFill(); sprite.graphics.lineStyle(0); for(var i:int = 0; i < 100; i++) { sprite.graphics.lineTo(Math.random() * 100, Math.random() * 500); } sprite.scrollRect = new Rectangle(0, 0, 100, 100); addChild(sprite); var scrollbar:VScrollBar = new VScrollBar(this, 100, 0, onScroll); scrollbar.setThumbPercent(100 / sprite.height); scrollbar.maximum = sprite.height - 100; scrollbar.pageSize = 100; scrollbar.lineSize = 1; function onScroll(event:Event):void { sprite.scrollRect = new Rectangle(0, scrollbar.value, 100, 100); } [/code]

6 responses so far

Older posts »