PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/bin/std/flash9/Lib.hx

http://github.com/Yoomee/clippy
Haxe | 94 lines | 54 code | 16 blank | 24 comment | 9 complexity | ad76df2d01ec4990a3178a1fdb32d255 MD5 | raw file
 1/*
 2 * Copyright (c) 2005, The haXe Project Contributors
 3 * All rights reserved.
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are met:
 6 *
 7 *   - Redistributions of source code must retain the above copyright
 8 *     notice, this list of conditions and the following disclaimer.
 9 *   - Redistributions in binary form must reproduce the above copyright
10 *     notice, this list of conditions and the following disclaimer in the
11 *     documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23 * DAMAGE.
24 */
25package flash;
26
27class Lib {
28
29	public static var current : flash.display.MovieClip;
30
31	public inline static function getTimer() : Int {
32		return untyped __global__["flash.utils.getTimer"]();
33	}
34
35	public static function eval( path : String ) : Dynamic {
36		var p = path.split(".");
37		var fields = new Array();
38		var o : Dynamic = null;
39		while( p.length > 0 ) {
40			try {
41				o = untyped __global__["flash.utils.getDefinitionByName"](p.join("."));
42			} catch( e : Dynamic ) {
43				fields.unshift(p.pop());
44			}
45			if( o != null )
46				break;
47		}
48		for( f in fields ) {
49			if( o == null ) return null;
50			o = untyped o[f];
51		}
52		return o;
53	}
54
55	public static function getURL( url : flash.net.URLRequest, ?target : String ) {
56		var f = untyped __global__["flash.net.navigateToURL"];
57		if( target == null )
58			f(url);
59		else
60			(cast f)(url,target);
61	}
62
63	public static function fscommand( cmd : String, ?param : String ) {
64		untyped __global__["flash.system.fscommand"](cmd,if( param == null ) "" else param);
65	}
66
67	public static function trace( arg : Dynamic ) {
68		untyped __global__["trace"](arg);
69	}
70
71	public static function attach( name : String ) : flash.display.MovieClip {
72		var cl = untyped __as__(__global__["flash.utils.getDefinitionByName"](name),Class);
73		return untyped __new__(cl);
74	}
75
76	public inline static function as<T>( v : Dynamic, c : Class<T> ) : Null<T> {
77		return untyped __as__(v,c);
78	}
79
80	#if flash10
81
82	public inline static function vectorOfArray<T>( v : Array<T> ) : Vector<T> {
83		return untyped __vector__(v);
84	}
85
86	public inline static function vectorConvert<T,U>( v : Vector<T> ) : Vector<U> {
87		return untyped __vector__(v);
88	}
89
90	#end
91
92}
93
94