Showing posts with label Flash. Show all posts
Showing posts with label Flash. Show all posts

Tuesday, April 28, 2009

Flash Actionscript 3 Internal and External Sounds

For Flash AS3, you may used embedded MP3 sound files or external among other formats.

External Sound Method:

var sndVarName:Sound = new Sound();
sndVarName.load(new URLRequest("path_to_file.mp3")
);
sndVarName.play();

Pro: Quicker SWF load time
Con: Delay in initially playing

This method has a delay when before the sound plays, but reduces load-time of the flash swf since the file is the embedded.


Internal Sound Method

1. Right click on the library Item
2. Select properties
3. Check "export for actionscript"
4. Give a class name, usually something like Myclassname, uppercase with the first letter. I usually use names that aren't likely to be reserved.

var sndVarName:Clicker = new Clicker();
sndVarName.play();

Friday, August 8, 2008

Paid Resources, Flash, Audio, Sound Boards

Flash Actionscript Files
Quality Flash Resources

Audio Files
Quality Audio Resources


Flash Developer at FlashDen.net
Derek Kier at FlashDen.net

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




Tuesday, December 18, 2007

remove all movieclips from a container in actionscript


Container = _root;
for (obj in Container)
{
trace("Type:" + typeof(Container[obj]));

if (typeof(Container[obj])=="movieclip")
{
trace("Name:" + Container[obj]._name);
Container[obj].removeMovieClip();//for attached instances
unloadMovie(Container[obj]);//for loaded instances

if(Container == _root)

MC.removeMovieClip();
}
}

Friday, December 14, 2007

Thursday, December 13, 2007

Flash Actionscript Math Util


function distance(x1,y1,x2,y2,rounded)
{
var distanceX = x2-x1;
var distanceY = y2-y1;
if(rounded == false)
{
return(Math.sqrt(distanceX * distanceX + distanceY * distanceY));
}
else
{
return(Math.round(Math.sqrt(distanceX * distanceX + distanceY * distanceY)));
}
}

function random_numberGen(minimumNumberAllowed,maximumNumberAllowed)
{
do
{
randomX = (Math.round(Math.random()*maximumNumberAllowed));
}
while(randomX < minimumNumberAllowed)

return(randomX);
}

Flash dynamic Fade actionscript



slides_array = new Array
(
"swf/automated.swf",
"swf/buyNow.swf",
"swf/easy1.swf",
"swf/money.swf"

)

random_effects = new Array
(
"zoomin",
"zoomout",
"pan_right",
"pan_left"
)

trace(slides_array[0]);
slideNum = 0;
change_out_time = 5000;
fade_speed = 50;
slideLoaded = false;

trace( slides_array.length )


loadSlide();
function loadSlide()
{
loadMovie(slides_array[slideNum], window);
//call_changeout();
}
call_changeout();
function call_changeout()
{
fade_out_interval = setInterval(call_fade_out_Slide, change_out_time);
}

function call_fade_out_Slide()
{
fade_out_interval = setInterval(fade_out_Slide, fade_speed);
trace("call_fade_out called");
}

function fade_out_Slide()
{
trace(slideNum + " should fade");
if(window._alpha > 0)
{
window._alpha -= 5;
}
else
{
clearInterval(fade_out_interval);
call_nextSlide();
}
}


function call_nextSlide()
{
trace("call_nextSlide working");
if(slideNum < slides_array.length -1)
{
slideNum++;
}
else
{
slideNum = 0;
}
loadSlide();
window._alpha = 100;
}