Chrome Extension: Resolution Test

Evenin,

I was just thinking about creating a background for my Twitter page when I thought it would be useful if there was a chrome extension that would resize your window to mimic different display resolutions. I did a search but I couldn’t find one, so I thought I’d have a go at creating one myself.

I haven’t done a lot of javascript before and its still very rusty, but if you’re running chrome on the dev branch you can install the extension here.

Enjoy :)

-Ben

[Thanks to famfamfam for the icons]

 

This has become incredibly popular!! Over 23,000 users and counting!

Get it here, or at the official extensions site

Current version: 2.0

Changelog:

  • 2.0
    • Added options page
    • Added ability to customise resolution list – add/remove/reorder (as requested by gogogadgetearl, Dima, Kirk, Tomek and many others)
    • Added option to close popup box on window resize (as requested by Famlam)
    • Added option to use desktop notifications
    • Improved design
    • Added 1024 x 600 as standard resolution (as requested by wikiyu)
    • Added 1366 x 768 as standard resolution (as requested by Ben Dickson)
    • Added ‘About’ section on options page with a link to buy me a beer should you be so inclined ;)
  • 1.80
    • Added Google Browser Size support (as requested by Steve)
    • Tidied up look and feel
    • Added icons for tasks
    • Reduced overall width
    • Fixed reset bug where sometimes the width wasn’t recorded correctly
  • 1.70
    • Added reset button (as requested by Kirk, t-dub)
    • Added 1024×600 as standard (as requested by danio)
    • Added checkboxes to open multiple resolutions at once
  • 1.61
    • Fixed large icon not showing up in extensions list
  • 1.6
    • Added new icons
  • 1.5
    • Added 1280 x 800 and 1280 x 1024
  • 1.4
    • Polished UI a bit
    • Auto-updating now works
    • Added custom option to fill in your own resolution

Creating Buttons Quickly and Easily with Actionscript 3

Hey guys, hope you’re all well.

As you know I’ve been working on a flash game recently that is due out soon (I’ll keep you posted) and one of the things I’ve found most over-complicated and time consuming is creating and managing buttons. For example, if we want to create a simple button that runs a function we’d have to write something like this:

   1:  button.addEventListener(MouseEvent.CLICK, someFunction);
   2:  button.buttonMode = true;
   3:  button.mousechildren = false;
   4:   
   5:  function someFunction (e:MouseEvent)
   6:  {
   7:      //button function here
   8:  }


That’s quite a lot for just a simple button, and what if we want a mouse over animation? Then it looks something like this (using Tweener):

   1:  button.addEventListener(MouseEvent.CLICK, someFunction);
   2:  button.buttonMode = true;
   3:  button.mousechildren = false;
   4:   
   5:  button.addEventListener(MouseEvent.MOUSE_OVER, overFunction);
   6:  button.addEventListener(MouseEvent.MOUSE_OUT, outFunction);
   7:   
   8:  function someFunction(e:MouseEvent)
   9:  {
  10:      //button function here
  11:  }
  12:   
  13:  function  overFunction(e:MouseEvent)
  14:  {
  15:      Tweener.addTween(e.currentTarget, {_brightness: 1, time: 0.3, transition: "easeInOutSine"});
  16:  }
  17:   
  18:  function  outFunction(e:MouseEvent)
  19:  {
  20:      Tweener.addTween(e.currentTarget, {_brightness: 0, time: 0.3, transition: "easeInOutSine"});
  21:  }


That’s a lot more already, and this is just for one button with a simple animation!

Then we have the issue of removing event listeners when we don’t need/want them anymore. In AS3 we need to write something like this:

   1:  button.removeEventListener(MouseEvent.CLICK, someFunction);


That might look like a relatively simple one line operation, but baring in mind we have to do this for every listener the button has (click, mouse over, mouse out etc) and we have to already know what listeners are attached and what function they perform, the whole process becomes far too time consuming for something that really shouldn’t be.

I’m not having a go at adobe for making the process convoluted, I agree with the methods used and I wouldn’t want it changed, but to save time I wrote a QuickButtons class to do all this stuff quickly and easily.

To setup the class initially you just put this variable definition:

   1:  public var qb:QuickButtons = new QuickButtons();


Then whenever we want to add a function button anywhere in your code we can just write:

   1:  qb.setupFunctionButton(button, someFunction, true);


Where ‘button’ is the movie clip you want turned into a button, ‘someFunction’ is the function you want it to run and ‘true’ means it will add the default over/out animations (this can be defined at the bottom of the class file).

So that’s nice and simple, but what if we want to do a custom animation for this button? Then we have this:

   1:  qb.setupCustomButton(button, overFunction, outFunction, someFunction, true);


Where ‘button’ is the movie clip you want turned into a button, ‘overFunction’ and ‘outFunction’ are the over/out animation functions, ‘someFunction’ is the function you want it to run and ‘true’ means it will use the hand cursor.

If we want to setup a button that opens a URL we can use:

   1:  qb.setupURLButton(button, "http://someURL.com", "_blank", true);


Where ‘button’ is the movie clip you want turned into a button, the first string is the url you want to link to, the second string is the target frame and ‘true’ means it will add the default over/out animations.

I also wrote a function for text that automatically places a catchment box behind it, it looks similar to the above:

   1:  qb.setupTextURLButton(button, "http://someURL.com", "_blank", true);


There is some more in there too but you can find them in the class once you’ve downloaded it.

We still have one more issue however, what about removing listeners? Unfortunately we don’t have a magical ‘removeAllEventListeners’ function built into flash, but I have written my own one that will work only with events added to buttons by my class. We simply put:

   1:  qb.removeListeners(button);


If you want to see how this works just have a look in the class. In a nutshell it stores all the added events in and array on the button’s movie clip and then removes them one by one.

So, there we have it, the first version of my QuickButtons class. I’ll add to it as I work perhaps but its good enough to save you a lot of time as it is now. You can use it and edit it for anything as much as you like, so long as you keep my name at the top I don’t mind :) Let me know if you need any help with it in the comments, you can download the class here.

Enjoy!

-Ben

Wave Giveaway Results

 

Well the replies started quickly but then fizzled out so all 11 people who entered get an invite!

If you are one the following people please message me your email addresses on Twitter and I’ll send them out:

@c_crampton

@distordz 

@satyadeep_ 

@Rishabh_Singla 

@Fillie86 

@dunwan 

@benfurnival 

@SixSidedSquid 

@philcampbell

@guiapprobato

@Jesse111

Well, that was fun :)

-Ben

Progress & Catholicism

Lo,

Work on the game is going well and as soon as I have a worthy build to show I’ll get it on here, I’m very nearly at the end of the main game mechanics and its actually pretty fun to play :D

Garry (garry.tv) posted a link to this on his Twitter which I watched early this morning and I thought I’d share it with you on here. Its a brilliant argument from Stephen Fry and Christopher Hitchins against the notion that “The Catholic church is a force for good in the world.” Enjoy:

[Edit - Had to remove embedded player as it kept playing automatically, to see it click here

-Ben

Happy November

Hello! I am still alive. Its been ages I know, consider my wrists duly slapped.

Recently I’ve been working a lot and going to the gym so I haven’t had nearly as much free time as I used to, but here I am!

So why am I blogging today? Because today marks the first day I’m being paid to make a game. No, I haven’t gotten a job in the games industry just yet, I’m making a Christmas Flash game for the web within my current job, and its proving rather fun ;)

I think I have about 3 weeks to do it roughly, I might post some progress builds on this blog if I can along the way, here’s one I made earlier:

 

In other news, some mates and I went to the EuroGamer Expo last Saturday, it was sick. Lots of promising games on display, my highlights being: Split/Second, Aliens Vs Predator, New Super Mario Bros. Wii, and of course, Left4Dead 2. In the afternoon we were privileged enough to have a developer’s session with writer Chet Faliszek from Valve who was talking about the Hard Rain campaign in Left4Dead 2. It was really great to get such an in-depth insight into the design of this campaign and to get some of the back story about the Left4Dead world, such as that witches love sugar and are active during the day (this is why they walk around in daylight maps). We also saw scavenge mode which looks to be awesome fun, and he talked about realism mode too – no glows, no alerts, no rescues. The full transcript of the talk is written up here if you want to read, its very interesting.

Also, been playing the Lef4Dead 2 demo, cannot wait for this to come out now, its lining up to be my favourite game of 2009.

Much love,

-Ben