Wednesday, December 3, 2008
Screen and print css definitions
<link rel="stylesheet" type="text/css" href="screen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="print.css" media="print" />
Thursday, October 9, 2008
PHP - Modify a global variable from within a function
So you have a PHP script and every now and again you want to add an ancor link and include 'next', 'previous' and 'top' buttons as the page is generated. Defining a PHP function and just calling it within a loop or at any point would be the easiest method (I think!) but how to send the previous ancor referance?
Marketing aside the following method allows you to do it.
<?Modify and adapt how you wish but this worked perfectly for me...
$current_ancor = 1;
//defining the ancor as 1 allows you to go +1 and -1
function latestAncor(){
global $current_ancor;
//get the variable from outside of the function
$next_ancor = $current_ancor+1;
$prev_ancor = $current_ancor-1;
$line = '<a name="ancor_number_'.$current_ancor.'"></a>
<a href="#top">Top button</a>
<a href="#ancor_number_'.$prev_ancor.'">Previous</a>
<a href="#ancor_number_'.$next_ancor.'">Next</a>';
$current_ancor++;
$GLOBALS["current_ancor"] = $current_ancor;
//this updates the current_ancor variable outside of the function
//with the next ancor number
return $line;
}
?>
Call the function whereever you like using <? echo latestAncor();?>
NOTE: You may need to ensure that register globals is set to on or off in your PHP?
Tuesday, September 16, 2008
Generate a random tint using PHP
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
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
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 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...
- 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!
- Name the button - in this case "buttonName".
- 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”);
} - Change the URL and buttonName to suit and remove the target _blank line if not required.
- Test the movie.
- Done.