Tuesday, September 16, 2008

Generate a random tint using PHP

I found this to be a brilliant solution for quickly generating a random background colour, ideal for report a graph with lots of bars...

echo dechex(rand(1,10000000)));

I need it to still be legible so used the following to strip out the darker colours...

echo str_replace(array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"),"A",dechex(rand(1,10000000)));

Reaction to change

Its easy for me to say that I've found myself following this exact pattern...

I read a book a couple of years back (just the one!) and one section stuck in my mind, I found a similar extract earlier today. Armed with this, I now find it easier to suggest and provide solutions to management and clients.
Understanding how people will react to, even potential, change helps you to soften the impact of any change.

Peoples reactions to change.

1: Shock

Similar to grief people may need time to access what has just occurred... people can find this period difficult to understand the reasons for and why the change has happened.

2: Avoidance or denial

A common reaction is to deny the impact of a change... "Well this does affect me, we don't need to use it". Setting a date for the change and celebrating its instigation sometimes helps.

3: Anger

People are naturally going to be angry towards anything that will shake them out of their comfort zone, it is important to avoid any anger from spreading as this will delay the progress of change. Explain to them the change and why it is needed to the initial few and allowing them to engage with the project.

4: General Acceptance

"I've got to use it, i might as well get on with it!"

5: Exploration

A willingness to learn the new system and engagement in progressing the project on, perhaps a suggestion box exercise would further involve the users and make them feel a part of a positive movement forward with the company.

6: Next steps and continued momentum

Implementing further changes to build or improve on the recent success and further advance the company towards a smoother work flow.


Relate this to any changes you have faced and I'm sure that it will be familiar.

Monday, September 15, 2008

Pausing the timeline in Flash - Simple code insert

This is so basic but it saves masses of long drawn out timelines where you can find anything.

Drop the following into the first frame of your timeline (in a new layer or actions layer if that is how you work), and call it whenever needed.
Call it by adding a keyframe with paused(10) whenever you need to pause the timeline - in this case the pause is 10 seconds... how simple is that?
function paused(sec) {
stop();
var i = sec - 1;
var t = setInterval(function () {
if (i == 0) {
clearInterval(t);
play();
}
i--;
}, 1000);
}

Getting a button to work in Flash using ActionScript 3 - Simple code insert

I'm relatively new to Flash and ActionScript but I've always known that button aren't as simple as they should be.

I started using ActionScript 3 for the first time today it turns out that GetURL no longer exists! But i found the following works fine.

This is a basic run through, it assumes that you already know a little about flash, I hope it helps...
  1. Create a button graphic and convert it into a button - if you want it to be clear i just set the Blend mode to Alpha... this seemed to work fine!
  2. Name the button - in this case "buttonName".
  3. Drop the following code into the first frame of your timeline (into either a new layer or your actions layer if you are familiar with this way of working).
    buttonName.addEventListener(MouseEvent.CLICK, onMouseClick);

    function onMouseClick(e:MouseEvent):void
    {
    var request:URLRequest = new URLRequest(“http://www.urlhere.com”);
    navigateToURL(request, “_blank”);
    }
  4. Change the URL and buttonName to suit and remove the target _blank line if not required.
  5. Test the movie.
  6. Done.
Thanks to School of Flash for this one.

Friday, September 12, 2008

Okay, i couldn't help it...

I know i said that the blog would be geared towards code that i found useful and articles of interest...

but i couldn't help but to play around and upload a picture of the girlfriends kitten, sad i know but she is quite cute (who i'm refering to, you decide)

My first blog...

I'm new to this game and while i know that i will blog as often as i remember to, i doubt that it will be of any use to anyone!

I intend to post any snippets of HTML, PHP, SQL, AJAX and the likes that i use and write, especially ones where i have spent ages Googling to get right (hopefully it will make someone elses job a little easier if trying to do the same thing) along with links to useful tools and current affairs that i find interesting. This will also help me to remember things as i learn them.

Thank you for reading.