/** * Copyright (c) 2006 Peter Goodman * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php */ class FA.movie_fns extends FA.query { private function parent(o:MovieClip) : String { var a:String = ''; if(o._parent != undefined and o._parent instanceof MovieClip) { if(o._parent._name != '') { a += '.' + o._parent._name; a += this.parent(o._parent); } } return a; } private function cache(m:MovieClip) : MovieClip { if(_global.fa_cache[m._name] == undefined) { var as:Array = this.parent(m).split('.'); as.reverse(); _global.fa_cache[m._name] = ('_root.' + as.join('.')) + m._name; } return m; } public function movieClip(n, d) : MovieClip { if(_o[0] instanceof MovieClip) { d = d || _root.getNextHighestDepth(); if(!_global.mc_cache[n] && !this.get(n) && _o[0]._name != n) { _o[0].createEmptyMovieClip(n, d); } } return this.cache(this.get(n)); } public function duplicate(n, d) : MovieClip { if (_o[0] instanceof MovieClip) { d = d || _root.getNextHighestDepth(); _o[0].duplicateMovieClip(n, d); } return this.cache(_o[0]._parent[n]); } public function mask(m:String) { if(_o[0] instanceof MovieClip) { if(_o[0]._parent[m] != undefined && _o[0]._parent[m] instanceof MovieClip) { _o[0]._parent[m].setMask(this._get()); } } return this; } public function text(e, d) : FA.query { d = d || _root.getNextHighestDepth(); d--; return this.each(function(i){ if (this instanceof MovieClip) { this.createTextField(e._name, ++d, e._x, e._y, e._width, e._height); var fi:TextField = this[e._name]; var fo:TextFormat = new TextFormat(); var n = true; var vf:Object = { align: n, blockIndent: n, bold: n, bullet: n, color: n, font: n, indent: n, italic: n, leading: n, leftMargin: n, rightMargin: n, tabStops: n, target: n, size: n, underline: n, url: n }; for (var p in e) { if (vf[p]) { fo[p] = f[p]; } else { fi[p] = f[p]; } } fi.setTextFormat(fo); } else if (this instanceof XML) { this.createTextNode(e); } }); } public function movie(e:Object) : FA.query { return this.each(function(i){ if(this instanceof MovieClip) { this.loadMovie(e.url, e.method || e.variables); } }); } public function unmovie() : FA.query { return this.each(function(i){ if(this instanceof MovieClip) { this.unloadMovie(); } }); } public function audio(e) : FA.query { return this.each(function(i){ if(this instanceof MovieClip) { this.attachAudio(e); } }); } public function unaudio() : FA.query { return this.audio(false); } }