// Filters specified tags from a supplied XML Node resource by tag name.
// Returns a new associative array with the filtered tags' attributes.
private function filterXMLAssocArray(filterNodeName:String, xmlNodes:Array):Array{
var tmpArray:Array = new Array();
var indexCounter:Number = 0;
for (var i:Number = 0; i<xmlNodes.length; i++){
if (xmlNodes[i].nodeName == filterNodeName){
tmpArray[indexCounter] = new Array();
tmpArray[indexCounter] = xmlNodes[i].attributes;
indexCounter ++;
}
}
return tmpArray;
};
function hexToRGB ( hex:Number ){
var returnObj:Object = new Object();
var returnObj .r = hex >> 16;
var temp = hex ^ r << 16;
var returnObj .g = temp >> 8;
var returnObj .b = temp ^ g << 8;
return returnObj;
}
function RGBToHex (r, g, b ){
var hex = r << 16 ^ g << 8 ^ b;
return hex;
}
/**
* Sets a object with an rbg tint
*
* @param r Red amount
* @param g Green amount
* @param b Blue amount
* @param amount The alpha amount on all colors
* @returns A color object to use with setTransform
*/
function setTint(r, g, b, amount):Object{
var trans = new Object();
trans.ra = trans.ga = trans.ba = 100 - amount;
var ratio = amount / 100;
trans.rb = r * ratio;
trans.gb = g * ratio;
trans.bb = b * ratio;
return trans;
}
class com.orazal.tools.DrawingUtils {
/**
* Uses flash's drawing api to draw a rectangle
*
* @param target The movieclip where the rectangle will be drawn
* @param x The horizontal position from where to begin drawing
* @param y The vertical position from where to begin drawing
* @param w The rectangle width
* @param h The rectangle height
* @param fill The fill object
* @param line The line object
*/
public static function drawRectangle(target:MovieClip, x:Number, y:Number, w:Number, h:Number, fill:Object, line:Object):Void {
with (target) {
beginFill(fill.color, fill.alpha);
if(line){
lineStyle(line.width, line.color, line.alpha);
}
moveTo(x, y);
lineTo(x+w, y);
lineTo(x+w, y+h);
lineTo(x, y+h);
lineTo(x, y);
endFill();
}
}
}
onClipEvent (enterFrame) {
var speed:Number = 10;//This can be any number you want.
this._x += speed;// moves the MovieClip along the x axis. Change the _x to _y to move the MovieClip along the y axis.
if (_x>=600) {// as long as the registration point for the MovieClip is Greater Than or Equal To 600, the MovieClip will move.
this._x= speed/2;
}
}