Archive for the 'web dev' Category
Embedding flash movies made easy
By Justin Silverton
There are a few way to embed a flash object or movie in a webpage:
1) Default code from adobe
It consists of an Object tag with an Embed tag placed inside it. This is the most popular Flash embed method and is the default choice when publishing your Flash movie from the Adobe Flash IDE. This is the most compatible way to embed a Flash movie, and will work in the widest range of browsers.
2) A separate flash movie
This method involves placing a Flash movie on the index page of your website, and this Flash movie then checks the versopm variable in the Flash player and redirects the user either to the Flash content inside the site, or an upgrade page.
Issues to consider with this method
- It will damage your search engine positioning - Since you are now using your index page as an empty Flash detection page, when people search for you in Google or other search engines, many times, the description text ends up showing up as “Detecting Flash Player” or even no description at all.
- It is not valid HTML or XHTML
3) The Adobe Flash Player Detection Kit
Adobe has a flash detection kit that comes with Flash versions 8 and higher.
Issues to consider with this method
- Not very user friendly
- has the same issues as #2
A better solution is to use SWFObject, a Javascript Flash Player detection and embedding script.
The script can detect the Flash plug-in in all major web browsers (on Mac and PC) and is designed to make embedding Flash movies as easy as possible. It is also search engine friendly, degrades gracefully, can be used in valid HTML and XHTML 1.0 documents.
SWFObject works in all the current web browsers, including, on PC: IE5/5.5/6, Netscape 7/8, Firefox, Mozilla, and Opera. On Mac: IE5.2, Safari, Firefox, Netscape 6/7, Mozilla, and Opera 7.5+.
How to use it
Usage is straight-forward and simple. Include the swfobject.js Javascript file, then use a small amount of Javascript on your page to embed your Flash movie. Here is some example code:
<script type="text/javascript" src="swfobject.js"></script>
<div id="yourcontent">
This text is replaced by the flash object
</div>
<script type="text/javascript">
var so = new SWFObject("test.swf", "mymovie", "400", "200", "8", "#FFFFFF");
so.write("yourcontent");
</script>
Here is a description of its parameters:
var so = new SWFObject(swf, id, width, height, version, background-color [, quality, xiRedirectUrl, redirectUrl, detectKey]);
Create a new SWFObject and pass in the required arguments:
- swf - The file path and name to your swf file.
- id - The ID of your object or embed tag. The embed tag will also have this value set as it’s name attribute for files that take advantage of swliveconnect.
- width - The width of your Flash movie.
- height - The height of your Flash movie.
- version - The required player version for your Flash content. This can be a string in the format of ‘majorVersion.minorVersion.revision’. An example would be: “6.0.65″. Or you can just require the major version, such as “6″.
- background-color - This is the hex value of the background color of your Flash movie.
Optional arguments are:
- quality - The quality you wish your Flash movie to play at. If no quality is specified, the default is “high”.
- xiRedirectUrl - If you would like to redirect users who complete the ExpressInstall upgrade, you can specify an alternate URL here.
- redirectUrl - If you wish to redirect users who don’t have the correct plug-in version, use this parameter and they will be redirected.
- detectKey - This is the url variable name the SWFObject script will look for when bypassing the detection. Default is ‘detectflash’. Example: To bypass the Flash detection and simply write the Flash movie to the page, you could add ?detectflash=false to the url of the document containing the Flash movie.
The latest version can be downloaded here
7 commentsThe evolution of Delphi for PHP
By Justin Silverton
Recently, CodeGear announced the latest addition to their product line called Delphi for PHP. It is a great new tool that allows developers to easily create php applications with a drag-and-drop GUI interface. What many people do not know is that a few of the components are actually based on open source projects. I feel that this is a a good thing, because many of these projects have been in use for awhile, thoroughly bug tested, and full of many great features.
Here is a list of the open source projects:
1) Qooxdoo framework

Qooxdoo is the basis for many of the VCL controls. And not all of the properties of the qooxdoo controls that are used are available to the IDE Object Inspector. Learning the API can help you discover the other properties that you can set using JavaScript.
information about the API can be found here
2) VCL4PHP
This project is a class library of PHP components which replicate VCL for Win32. VCL for PHP is PHP framework to develop web applications, it’s OpenSource and it’s licensed using LGPL. It is the basis for the majority of the libraries within Delphi for PHP.
Features
- Fully OO applications
- Complete MVC model
- Properties, Methods and Events>
- I18N functionality
- Template Engines
- Ajax abstraction
- Database abstraction and data-aware components
- Input filtering using objects
- Webservices integration
Project available here
3) walterzorn vector graphics library
This JavaScript VectorGraphics library provides graphics capabilities for JavaScript: functions to draw circles, ellipses (ovals), oblique lines, polylines and polygons (for instance triangles, rectangles) dynamically into a webpage. Usage of this Vector Graphics library should be easy even if you don’t have JavaScript experience. Another goal during development of this JavaScript Draw Shapes Vector Graphics Library was to achieve optimized performance and cleanly arranged pixel stair-step patterns (pixel-optimization).
This library is available for download here
a nice animation example here
4) xajax - ajax library
The xajax PHP object generates JavaScript wrapper functions for the PHP functions you want to be able to call asynchronously from your application. When called, these wrapper functions use JavaScript’s XMLHttpRequest object to asynchronously communicate with the xajax object on the server which calls the corresponding PHP functions. Upon completion, an xajax XML response is returned from the PHP functions, which xajax passes back to the application. The XML response contains instructions and data that are parsed by xajax’s JavaScript message pump and used to update the content of your application.
Features
- xajax’s unique XML response / javascript message-pump system does the work for you, automatically handling the data returned from your functions and updating your content or state according to the instructions you return from your PHP functions. Because xajax does the work, you don’t have to write javascript callback handler functions.
- xajax is object oriented to maintain tighter relationships between the code and data, and to keep the xajax code separate from other code. Because it is object oriented, you can add your own custom functionality to xajax by extending the xajaxResponse class and using the addScript() method.
- xajax works in Firefox, Mozilla, probably other Mozilla based browsers, Internet Explorer, and Safari.
- In addition to updating element values and innerHTML, xajax can be used to update styles, css classes, checkbox and radio button selection, or nearly any other element attribute.
- xajax supports passing single and multidimensional arrays and associative arrays from javascript to PHP as parameters to your xajax functions. Additionally, if you pass a javascript object into an xajax function, the PHP function will receive an associative array representing the properties of the object.
- xajax provides easy asynchronous Form processing. By using the xajax.getFormValues() javascript method, you can easily submit an array representing the values in a form as a parameter to a xajax asynchronous function:
xajax_processForm(xajax.getFormValues(’formId’);
. It even works with complex input names like “checkbox[][]” and “name[first]” to produce multidimensional and associative arrays, just as if you had submitted the form and used the PHP $_GET array
Non-open source software worth mentioning
Qstudio

CodeGear partnered with qadram software to jointly develop Delphi for PHP. qadram software, the development team behind VCL for PHP, had been working on a pre-beta project called Qstudio that became the foundation of Delphi for PHP.Development of Delphi for PHP is being done by CodeGear and qadram software at CodeGear headquarters in Scotts Valley, CA.
Interested in Delphi for PHP? a free, 14-day trial (as opposed to the 1-day trial when it was first released) can be found here
No commentsConverting PHP scripts to dlls
By Justin Silverton
I came across this great open source project that allows you to convert your php scripts to a fast/cgi executable that can be executed by any web server that supports it (including apache and IIS).
From the site:
“Roadsend Compiler is an open source, native compiler for the PHP language. It compiles PHP source code to stand alone, native binaries which do not require an interpreter. Roadsend Compiler can build online web applications with Fast/CGI, offline web applications with an embedded web server (MicroServer), desktop GUI applications with PHP-GTK, and console applications. It is known to build on Linux, Windows (using mingw), and FreeBSD.”
Benefits of using the roadsend compiler
- Faster execution time, because your php script is now a native binary and does not have to be interpreted each time it is accessed.
- Better than a solution such as zend encoder or ion cube because it does not require the server to have any extra extensions (besides fast/cgi support installed). It also provides a good obfuscation solution.
- The ability to create stand-alone web applications. These applications include a built-in webserver that allows the execution of php scripts as if they were a local application.
Issues to consider
- Because this is an executable, it needs to be re-compiled for any operating system that you would like to support (freebsd, linux, windows, etc.)
more information can be found at the main roadsend website here
5 commentsDelphi for php released
By Justin Silverton
After all the hype, Delphi for PHP is finally available.

Announcement from codegear here
“CodeGear, a leader in developer tools, today announced that Delphi® for PHP – an integrated visual Rapid Application Development (RAD) environment for the popular PHP Web development language – is now shipping worldwide.
Delphi for PHP brings the RAD productivity benefits that Delphi users have enjoyed for years to PHP Web developers. PHP, designed to allow Web developers to write dynamically generated pages quickly, is the most prominent dynamic Web language today and has become one of the top 10 programming languages overall.”
Features
- VCL for PHP,an open-source PHP 5 visual component library with more than 50 reusable components and seamless AJAX integration
- out-of-the-box integration with InterBase®, MySQL, Oracle®, Microsoft SQL Server, and other popular databases
- an integrated PHP debugger; drag-and-drop database application development using the Data Explorer for InterBase and MySQL
- a code editor with Code Insight, Code Explorer, and Code Templates. Deployment options include Windows, Linux, Solaris and other platforms
Pricing
The product is available for an introductory price of $249.
Download Trial
A one-day trial can be downloaded here
7 commentsHow to add keyboard shortcuts to your website
By Justin Silverton
The following javascript code will allow you to add keyboard shortcuts to any webpage.
The code
(put this on any page where you want keyboard shortcuts)
<html>
<head>
<script type="text/javascript" language="JavaScript" src="shortcut.js"></script>
</head>
<body onkeydown='keyShortcut()'>
</html>
(put this in a file called shortcut.js and upload to the same directory as the webpage with the above code). This example will display an alert message when the escape key is pressed.
function keyShortcut() {
var e = window.event;
var code = e.keyCode;
if (code == 112) { //checks for the escape key
alert('escape key pressed');
}
}
The following are some more keyboard codes that can be used within the above script (in the if code == X, where X is one of the codes below).
| key | Code |
| tab | 9 |
| enter | 13 |
| leftwindow key | 91 |
| right window key | 92 |
| f1 | 112 |
| f2 | 113 |
| f3 | 114 |
| f4 | 115 |
| f5 | 116 |
| f6 | 117 |
| f7 | 118 |
| f8 | 119 |
| f9 | 120 |
| f10 | 121 |
| f11 | 122 |
| f12 | 123 |
Other Methods
HTML has built-in methods that allow you to add keyboard shortcuts to certain elements on a page. These are also supported by firefox, Internet Explorer, and Opera.
accesskey = Character
The accesskey attribute is used to assign a shortcut key to an HTML element of the following types A, AREA, BUTTON, INPUT, LABEL, LEGEND, and TEXTAREA 1.
When the user performs the appropriate keystroke focus is moved to the element.
If the element is a link the link is followed to the referenced document.
If the element is an input or label the cursor is moved to that element.
Depending on the browser, the keystroke to use the accesskey will differ (CHARACTER is any character in the containing documents charset).
- Internet Explorer use: ALT-CHARACTER
- Mozilla Firefox use: ALT-SHIFT-CHARACTER
- Opera use: SHIFT-ESC then CHARACTER





