Wednesday, May 14, 2008

mnemonic devices, things to memorize

AS3

class definitions

class properties

AS2

class definitions

class properties

Tuesday, May 13, 2008

Programming Snippets

http://snipplr.com/search.php

Should build Snippets Table in MYSQL

programming_language
section
title
description
keywords
content


Javascript


FORM

select box controls

get selected value

document.getElementById('mode').options[document.getElementById('mode').selectedIndex].value

change selected option in select box by value

document.getElementById('placement').value="mediaplayer";

change selected option in select box by index number

document.getElementById('adSequence').selectedIndex = 0;

function handler_form1()
{
handler_mode();
placement_value();
}

function handler_mode()
{
//getEl = document.getElementById('mode').options
thisSelectBox = document.getElementById('mode');
selected_mode = document.getElementById('mode').options[document.getElementById('mode').selectedIndex].value;
alert(selected_mode);

switch(selected_mode)
{
case "marquee":
document.getElementById('placement').value="mediaplayer";
document.getElementById('skip_upload').value = 'no';
document.getElementById('ad_width').style.display = 'block';
break;
case "interactive":
document.getElementById('skip_upload').value = 'yes';
document.getElementById('ad_width').style.display = 'none';
break;
}

alert(document.getElementById('skip_upload').value);
}

function placement_value()
{
selected_placement = document.getElementById('placement').options[document.getElementById('placement').selectedIndex].value;
alert(selected_placement);
}

visibility methods

document.getElementById('ad_width').style.visibility = 'visible';
document.getElementById('ad_width').style.visibility = 'hidden';

document.getElementById('ad_width').style.display = 'block';
document.getElementById('ad_width').style.display = 'none';
document.getElementById('ad_width').style.display = 'inline';
//inline
inline will make the element act as an inline element—it will be composed into the output flow as if it were a >, even if it were normally a block element such as a


Prevalidation

onkeyup="javascript:limit_characters_field(this.id,5);numbers_only_field(this.id);"

function limit_characters_field(ID,intMax)
{
thisID = document.getElementById(ID);

if(thisID.value.length > intMax)
{
alert('no more than ' + intMax +' characters');
}

thisID.value = thisID.value.slice(0, intMax);
}

function numbers_only_field(ID)
{
thisID = document.getElementById(ID);
original_str = thisID.value;
var pattern = new RegExp(/\D/);
newStr = original_str.replace(pattern,'');
thisID.value = newStr;
//var result = patt1.test(str);

if(pattern.test(original_str) == true)
{
alert('numbers only');
}
}

AJAX

XMLHttpRequest

properties
  1. readyState
    1. 0-uninitialized - contains no data
    2. 1-loading - data is loading
    3. 2-loaded
    4. 3-interactive - may interact, but data hasn't finished loading
    5. 4- complete - object IS initialized
  2. responseText
  3. responseXML
  4. status
    1. 200 -ok
    2. 400 - bad request
    3. 401 - unauthorized
    4. 403 - forbidden
    5. 404 - not found
    6. 500 - internal server error
  5. statusText
event handler
  1. onreadystatechange
methods
  1. abort();
  2. getAllResponseHeaders()
  3. getResponseHeader("headername")
  4. open("method","url",async,["user","pword"])
    1. open("GET","myFile.xml",true)
  5. send(content)
  6. setRequestHeader("label","value")


FLASH


AS2

Multidimensional Associative Array

info = new Array();
info["fast"] = "peugoet 306";
info["sporty"] = "citreon saxo";
info["old"] = "ford fiesta";
info["types"] = {gold:"24k",silver:"sterling"};//new Array({gold:"24k",silver:"sterling"});
info["material"] = {gems:{diamond:"pretty diamond",silver:"sterling"},wood:"sterling"};

function getData(info)
{
trace("test " + info['old']);
trace("test " + info["types"].silver);
trace("material " + info["material"].gems.diamond);
}

function symbol_htmlNumber_conversion(str)
{
if(!char_symbol_array)
{
var intX:Number = 0;
char_symbol_array = new Array();
char_symbol_array['symbol'] = new Array();
char_symbol_array['htmlNumber'] = new Array();

char_symbol_array['symbol'][intX] = " ";
char_symbol_array['htmlNumber'][intX] = " ";
intX++;

char_symbol_array['symbol'][intX] = "!";
char_symbol_array['htmlNumber'][intX] = "!";
intX++;

char_symbol_array['symbol'][intX] = '"';
char_symbol_array['htmlNumber'][intX] = """;
intX++;

char_symbol_array['symbol'][intX] = "#";
char_symbol_array['htmlNumber'][intX] = "#";
intX++;

char_symbol_array['symbol'][intX] = "$";
char_symbol_array['htmlNumber'][intX] = "$";
intX++;

char_symbol_array['symbol'][intX] = "%";
char_symbol_array['htmlNumber'][intX] = "%";
intX++;

char_symbol_array['symbol'][intX] = "&";
char_symbol_array['htmlNumber'][intX] = "&";
intX++;

char_symbol_array['symbol'][intX] = "'";
char_symbol_array['htmlNumber'][intX] = "'";
intX++;

char_symbol_array['symbol'][intX] = "(";
char_symbol_array['htmlNumber'][intX] = "(";
intX++;

char_symbol_array['symbol'][intX] = ")";
char_symbol_array['htmlNumber'][intX] = ")";
intX++;

char_symbol_array['symbol'][intX] = "*";
char_symbol_array['htmlNumber'][intX] = "*";
intX++;

char_symbol_array['symbol'][intX] = "+";
char_symbol_array['htmlNumber'][intX] = "+";
intX++;

//not finished, still needs more symbols
}

Combo Box Listener

playerEvent_cb.addItem({data:"playing_video",txt:"txt",param2:"param2", label:"playing video"});
playerEvent_cb.addItem({data:"idle",txt:"txt",param2:"param2", label:"idle"});
playerEvent_cb.addItem({data:"video_ended",txt:"txt",param2:"param2", label:"idle"});

cb.addItem({data:"0 param",txt:"txt",param2:"param2", label:"playing video"});
cb.addItem({data:"1 param",txt:"txt",param2:"param2", label:"idle"});
cb.addItem({data:"video_ended",txt:"txt",param2:"param2", label:"idle"});



//cb listener handler

var cbListener:Object = new Object();
cbListener.change = function(evt_obj:Object) {


var item_obj:Object = evt_obj.target.selectedItem;

var i:String;
for (i in item_obj) {
trace(i + ":\t" + item_obj[i]);
}
trace("");

};
playerEvent_cb.addEventListener("change", cbListener);
cb.addEventListener("change", cbListener);



Submit.onPress = function()
{
info.playerEvent = playerEvent_cb.selectedItem['txt'];
trace(info.playerEvent);
}

PHP
Form functions

function mk_option($selectID,$value,$text,$data_arr){

if($data_arr[$selectID])
{
$selected = $data_arr[$selectID] == $value ? ' SELECTED' : '';
}

$option =
''.$text.'';

return $option;
}

sample
mk_option:
function getPageDD($data_arr){
//'Home'.


$out =
'';

return $out;
}



BATCH

Basic Commands

md - make directory