Oct 30, 2008

ActionScript: Passing parameters to onRelease and other event functions

As it turns out, you can't use parameters directly when defining an event function, for example:
myMovie.onRelease = function(param1,param2,param3) {
   //my code
The example above will generate a compiler error. This won't work either:
var = 1;
var2 = "something else";
myMovie.onRelease = function() {
   //var and var1 are unaccessible at this point
The solution for this is simple, yet effective. You need to define your paramaters to a movieclip, so that you can reach them with the operator "this".
myMovie.param1 = "something";
mymovie.param2 = "something else";
myMovie.onRelease = function() {

Oct 4, 2008

PHP: function to see if an email is valid

function email_valid($email) {
 return (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email));
Return values are true/false.

Oct 2, 2008

jQuery - update DIV's HTML dynamically

jQuery is a JavaScript library, downloadable here. It uses AJAX calls to get external data. Retrieving this data is simple - I used two functions:
function geturl(addr) {
var r = $.ajax({
 type: 'GET',
 url: addr,
 async: false
return r;

function changediv() {

UPDATE: For asynchronous ajax calls see example in the comments below.