Dear readers… WTF! do you want from me?
I noticed that alot of readers are registering to this blog and don't know why. I don't send/offer any newsletters and there aren't any member only pages. Are you registering because you expect something?
I'm wanting to become more involved with my readers and want to start by asking you all what you would like to see/read when you come to my blog. Why are you registering? Are my posts actually helping you?
Any feedback, good or bad will be greatly appreciated.
Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
Find links within text and convert to active links with PHP
Recently I have had to integrate some tweets into a clients website via RSS. The problem I found is that the links are hidden in the description and are not active. The solution is as simple as using 3 regular expressions and replace the text URL with a HTML URL using PHPs eregi_replace function.
function activateLinks($string) { // This regular expression looks for <strong>http:// </strong>type url $string = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="1" target=_blank>1</a>', $string); // This regular expression looks for <strong>www. </strong>type url $string = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '1<a href="http://2" target=_blank>2</a>', $string); // This regular expression looks for <strong>email@email.com</strong> $string = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '<a href="mailto:1" target=_blank>1</a>', $string); return $string; } //call function where ever you need it $string= 'Scaling a dynamic background image in proportion using flashvisit (http://www.flashnutz.com) or email me on brian@flashnutz.com'; echo activateLinks($string);
The output of the string would be
//output of $string $string = 'Scaling a dynamic background image in proportion using flash visit (<a href="http://www.flashnutz.com">http://www.flashnutz.com</a>) or email me on <a href="mailto:brian@flashnutz.com"> brian@flashnutz.com</a>';
My next post will be how to read your twitter posts with php and then use this function to active the links within them.
Happy coding...
Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
Using none web standard fonts with Google Font API
Google has launched Google Font API and Google Font Directory Beta.
A developer will be able to link and use a range of fonts legally without the need of them being installed on your machine or web directory, through a single line of code.
The Google Font Directory currently has 18 licensed fonts available like the font I'm using in this article and will offer more as time goes by.
Below is an example of how to use Google Directory.
For example if you want to use the font used in this article Droid Sans you would copy the code below and put it as the first element in the <head> of your document.
<link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
The API will generate the necessary CSS specific to the user's browser so you can use the font on your page. Simply use the font Droid Sans in your CSS font stack like any other font, for example:
h1 { font-family: 'Droid Sans', arial, serif; }
And that's it. To easy!
Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
List files in a directory using php
To display a list of files within a directory using PHP you need to use opendir() and readdir(). Below is a function that will return the list of files and remove the . and .. from the listing.
//full path of directory $dir = "/var/www/images/"; function listFiles($dir){ //open directory and read its contents if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { //only display filenames if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle); } }
You might run into trouble trying to find the correct full path of the images. For example in a windows hosting environment the path could be (c://blah/blah), in a Linux environment it could be (/var/www/blah/blah).
To find the exact path for your environment use phpinfo(). Once you have the php info look for the DOCUMENT_ROOT entry.
Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
Dynamic variable names in PHP
I'm going to show you how to use dynamic variable names in php. It's quite simple, just put your variable name in between {} symbols.
// declare prefix. In a loop this would probably be a number. $prefix = "pfx"; // build your variable ${"varname_{$prefix}"} = "success"; //This would output "success" echo $varname_pfx;
Simple isn't it....
Become a dyneaming online video poker game player on the video poker games of CasinoBonus.org where you can also learn the history of video poker !
Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
Scaling a dynamic background image in proportion using flash
Recently I was playing around with scaling background images and had issues with how the scaling behaved and image quality. When scaling an image in proportion you want to make sure that the image container is centered to the movie clip it belongs to.
My example below is the scaling code within a stage listener which will re size the background image according to the stage width & height.
Stage.align = "TL"; Stage.scaleMode = "noScale"; //Get Background Image Container Movie Clip Name (instance) var backgroundImage:movieClip = "MovieClip Instance Name" // Create an object for the stage listener stageListener:Object = new Object(); // Create a function for the event you want to listen for stageListener.onResize = function() { //Get the stage width & height var sw:Number = Stage.width; var sh:Number = Stage.height; //Check to see if image width or height needs adjusting if ((sh / sw) > (backgroundImage._height / backgroundImage._width)) { //get image width and adjust height to fit scale = backgroundImage._width / backgroundImage._height; backgroundImage._height = sh; backgroundImage._width = sh * scale; } else { //get image height and adjust width to fit scale =backgroundImage._height / backgroundImage._width; backgroundImage_width = sw; backgroundImage._height = sw * scale; } //Center the background Image backgroundImage._x = (sw - backgroundImage._width) / 2; backgroundImage._y = (sh - backgroundImage._height) / 2; }; // Add listener for the Stage object Stage.addListener(stageListener);
Now the the simple line of code that makes this work so well is the quality preservation part. Just add this after your dynamic image has loaded.
backgroundImage.forceSmoothing = true;
An actionscript 3 version would not be much different to this and should be fairly easy to workout. If your struggling just let me know.
Buy great image scaling software after you learn the roulette slang and online roulette history you need to beat roulette at CasinoBonus.org!
Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
Images not working in dompdf
What is dompdf? Well basically its a HTML to PDF converter. It's rendering engine is built in PHP and is style-driven which means it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements.
I won't go into detail of how to use it (unless you want me to or would like to write about it), but recently I had an issue with images not rendering in the pdf. At first I thought it was a permissions problem, then I thought it was an image type problem. It turns out it was a file location issue.
instead of the file location being:
<img src="images/myimage.jpg" style="width:200px;height:200px">
It should be:
<img src="/var/www/images/myimage.jpg" style="width:200px;height:200px">
So as you can see it needs to reference the file from the server side file directory and not just from within the web directory.
Wish someone wrote this, when I needed it....

Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
Using swfObject with Mootools
I'm sure most of us use swfObject, which in my opinion is the best option when it comes to embedding flash.
Lately I've been having a lot of fun with mootools and needed a way to embed flash dynamically. Basically I wanted my flash file to be embedded after a mootools click event was triggered.
So without further ado..
window.addEvent('domready', function() { //get the div I want to embed my flash into. var flashcontainer = $('flashcontainer'); //set all the flash properties var file = 'file.swf'; var moviename = 'nameMyFlash'; var width = '640'; var height = '424'; var version = '9'; var bgcolor = '#000000'; //create the function that will fuse swfObject with mootools var embedFlash = function(){ var so = new SWFObject(file, moviename, width, height, version, bgcolor); so.addParam("quality", "high"); so.addParam("align", "middle"); so.addParam("play", "true"); so.addParam("loop", "true"); so.addParam("scale", "exactfit"); so.addParam("allowFullScreen", "true"); so.addVariable("variable1", "variable 1 value goes here"); so.addVariable("variable2", "variable 1 value goes here"); so.write(flashcontainer); } //get button by id var myButton = $('mybutton'); // create click event to fire my function called "embedFlash()" myButton.addEvent('click', embedFlash); });
And that's it.. Hope it helps....
You can download the latest tools used above from the links below:
MooTools - download release 1.2.3 or SWFObject 2.2
Your slots payouts will be out of proportion from the progressive slots when you hit the slots bonus using the slots secrets of CasinoBonus.org!
Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
FLA crashes when publishing, saving or simply viewing the action tab
Today I came across an annoying issue with a CS3 file that I had edited a month ago. I was required to make simple edits so I re-opened the fla file. It crashed every time I tried publishing, saving or simply viewing the action tab and could not figure out why. After hours of debugging I finally fixed the problem by simply copying it from the network to my desktop. Basically every time I tried opening the fla file from the network it crashed. I don't have an exact reason why this is happening because other files work fine, however this is the solution to fix it.

Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post
Building a Preloader in ActionScript 3
We are going to explore how to build a preloader in as3. Before building the preloader you will need to understand how to load external images/data with ActionScript 3.
If you read the loading external images post you will know that the image was loaded into the contentLoaderInfo property of the Loader object. This is what the code looks like.
var imgLoader:Loader = new Loader(); imgLoader.contentLoaderInfo.addEventListner(Event.COMPLETE, loaderCompleteHandler); function loaderCompleteHandler(e:Event):void{ trace('Image has loaded.'); } imgLoader.load(new URLRequest('image.jpg'));
To monitor the loading progress of this externally loaded image we need to use the LoaderInfo object which is a package of information about the load that is passed to the event listener of contentLoaderInfo. The properties of the LoaderInfo class along with the event object will provide all the information needed to build our preloader.
The available properties of the LoaderInfo class are:
- bytesLoaded
- bytesTotal
- content
- frameRate
- height
- width
- loader
The available event types of the LoaderInfo class are:
- COMPLETE
- INIT
- PROGRESS
- UNLOAD
From the event types above we need to use the PROGRESS event type like the following.
imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preloaderHandler);
Then to display the bytes being loaded we need to use the bytesLoaded and bytesTotal properties, and trace them when the function preloaderHandler is triggered. If you divide the 2 and multiply by 100 you will get the percentage loaded.
function preloaderhandler(e:ProgressEvent):void{ trace('bytesLoaded: ' + e.bytesLoaded); trace('bytesTotal: ' + e.bytesTotal); trace('percentage loaded: ' + Math.round((e.bytesLoaded/e.bytesTotal)*100) + "%"); }
The complete source code looks like this.
var imgLoader:Loader = new Loader(); imgLoader.contentLoaderInfo.addEventListner(Event.COMPLETE, loaderCompleteHandler); imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preloaderHandler); function loaderCompleteHandler(e:Event):void{ trace('Image has loaded.'); } function preloaderhandler(e:ProgressEvent):void{ trace('bytesLoaded: ' + e.bytesLoaded); trace('bytesTotal: ' + e.bytesTotal); trace('percentage loaded: ' + Math.round((e.bytesLoaded/e.bytesTotal)*100) + "%"); } imgLoader.load(new URLRequest('image.jpg'));
Enjoy. I'll write a post soon on how to integrate this preloader script with a simple animation.
Plurk This Post
Buzz This Post
Delicious
Digg This Post
Ping This Post
Reddit
Stumble This Post