/** * Copyright (c) 2006 Peter Goodman * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php */ //-------------------------------------------- // A class of generic functions used in the query // class. //-------------------------------------------- dynamic class FA.build.fn extends FA.Query { //-------------------------------------------- // Loop through an array or object and apply // a function to each loop. This also corrects // the functions scope so that whatever each row // of the loop is becomes 'this' //-------------------------------------------- public function each (loop_function:Function) : FA.Query { if (!_is_dirty and _object.length != undefined) { for (var row in _object) { loop_function.apply(_object[row], [row]) } } return this; } //-------------------------------------------- // A two purpose function. Set can either set a // single value by supplying both function parameters // (key and value). If only the first parameter is // received and it is a object, all of the methods in // that object will be set the the thing that we are // modifying. //-------------------------------------------- public function set (object_or_key, value) : FA.Query { if (!_is_dirty) { if (object_or_key.constructor == Object) { for (var property in object_or_key) { _object[property] = object_or_key[property]; } } else { _object[object_or_key] = value; } } return this; } //-------------------------------------------- // Simple get function. it will either try to // get a specific thing from what we are using, // if that doesn't exist and 0 is specified, than // it will return what we are modifying. //-------------------------------------------- public function get (key) { var wanted_value; if (key == undefined) { // return the object we are modifying wanted_value = _object; } else { if (_object[key] != undefined) { wanted_value = _object[key]; } else { // xml if (_object.attributes != undefined) { wanted_value = this.attrib(key); } // to be like jQuery else if (key == 0) { wanted_value = _object; } } } return wanted_value; } //-------------------------------------------- // Clear all graphics made. //-------------------------------------------- public function clear () : FA.Query { if (_object instanceof MovieClip or _object instanceof Video) { _object.clear(); } return this; } }