Archive for August, 2009

Dynamic variable names in PHP

August 18th, 2009 No comments

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.

  1. // declare prefix. In a loop this would probably be a number.
  2. $prefix = "pfx";
  4. // build your variable
  5. ${"varname_{$prefix}"} = "success";
  7. //This would output "success"
  8. echo $varname_pfx;

Simple isn't it....

Become a dyneaming online video poker game player on the video poker games of where you can also learn the history of video poker !

Scaling a dynamic background image in proportion using flash

August 13th, 2009 11 comments

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.

  1. Stage.align = "TL";
  2. Stage.scaleMode = "noScale";
  4. //Get Background Image Container Movie Clip Name (instance)
  5. var backgroundImage:movieClip = "MovieClip Instance Name"
  7. // Create an object for the stage listener
  8. stageListener:Object = new Object();
  10. // Create a function for the event you want to listen for
  11. stageListener.onResize = function() {
  13. //Get the  stage width & height
  14. var sw:Number = Stage.width;
  15. var sh:Number = Stage.height;
  17. //Check to see if image width or height needs adjusting
  18. if ((sh / sw) > (backgroundImage._height / backgroundImage._width)) {
  20. //get image width and adjust height to fit
  21. scale = backgroundImage._width / backgroundImage._height;
  22. backgroundImage._height = sh;
  23. backgroundImage._width = sh * scale;
  24. } else {
  26. //get image height and adjust width to fit
  27. scale =backgroundImage._height / backgroundImage._width;
  28. backgroundImage_width = sw;
  29. backgroundImage._height = sw * scale;
  30. }
  32. //Center the background Image
  33. backgroundImage._x = (sw - backgroundImage._width) / 2;
  34. backgroundImage._y = (sh - backgroundImage._height) / 2;
  36. };
  37. // Add listener for the Stage object
  38. 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.

  1. 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!

Images not working in dompdf

August 6th, 2009 24 comments

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....

Using swfObject with Mootools

August 4th, 2009 11 comments

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..

  1. window.addEvent('domready', function() {
  3. //get the div I want to embed my flash into.
  4. var flashcontainer = $('flashcontainer');
  6. //set all the flash properties
  7. var file = 'file.swf';
  8. var moviename = 'nameMyFlash';
  9. var width = '640';
  10. var height = '424';
  11. var version = '9';
  12. var bgcolor = '#000000';
  14. //create the function that will fuse swfObject with mootools
  15. var embedFlash = function(){
  16. var so = new SWFObject(file, moviename, width, height, version, bgcolor);
  17. so.addParam("quality", "high");
  18. so.addParam("align", "middle");
  19. so.addParam("play", "true");
  20. so.addParam("loop", "true");
  21. so.addParam("scale", "exactfit");
  22. so.addParam("allowFullScreen", "true");
  23. so.addVariable("variable1", "variable 1 value goes here");
  24. so.addVariable("variable2", "variable 1 value goes here");
  25. so.write(flashcontainer);
  26. }
  28. //get button by id
  29. var myButton = $('mybutton');
  31. // create click event to fire my function called "embedFlash()"
  32. myButton.addEvent('click', embedFlash);
  34. });

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!

SEO Powered by Platinum SEO from Techblissonline