first commit

This commit is contained in:
2020-10-20 00:58:15 +02:00
commit 7f1b9bfca5
222 changed files with 56918 additions and 0 deletions

View File

@ -0,0 +1,13 @@
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
package com.yahoo.astra.fl.utils {
import fl.controls.ColorPicker;
import fl.controls.ComboBox;
import fl.controls.LabelButton;
import fl.controls.List;
import fl.controls.NumericStepper;
import fl.controls.RadioButtonGroup;
import fl.controls.TextArea;
import fl.controls.TextInput;

View File

@ -0,0 +1,166 @@
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
package com.yahoo.astra.fl.utils
{
import com.yahoo.astra.utils.InstanceFactory;
import fl.core.UIComponent;
import fl.managers.StyleManager;
import flash.display.DisplayObject;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
import flash.utils.getQualifiedSuperclassName;
/**
* Utility functions for use with UIComponents.
*
* @author Josh Tynjala
*/
public class UIComponentUtil
{
/**
* Using an input, such as a component style, tries to convert the input
* to a DisplayObject.
*
* <p>Possible inputs include Class, a String representatation of a
* fully-qualified class name, Function, any existing instance of
* a DisplayObject, or InstanceFactory.</p>
*
* @see com.yahoo.astra.utils.InstanceFactory
*
* @param target the parent of the new instance
* @param input the object to convert to a DisplayObject instance
*/
public static function getDisplayObjectInstance(target:DisplayObject, input:Object):DisplayObject
{
if(input is InstanceFactory)
{
return InstanceFactory(input).createInstance() as DisplayObject;
}
//added Function as a special case because functions can be used with the new keyword
else if(input is Class || input is Function)
{
return (new input()) as DisplayObject;
}
else if(input is DisplayObject)
{
(input as DisplayObject).x = 0;
(input as DisplayObject).y = 0;
return input as DisplayObject;
}
var classDef:Object = null;
try
{
classDef = getDefinitionByName(input.toString());
}
catch(e:Error)
{
try
{
classDef = target.loaderInfo.applicationDomain.getDefinition(input.toString()) as Object;
}
catch (e:Error)
{
// Nothing
}
}
if(classDef == null)
{
return null;
}
return (new classDef()) as DisplayObject;
}
/**
* Gets the class of an object. If the object is a DisplayObject,
* may retrieve the class from the containing app domain.
*
* @param target A Class or a fully qualified class name (String).
*/
public static function getClassDefinition(target:Object):Class
{
if(target is Class)
{
return target as Class;
}
try
{
return getDefinitionByName(getQualifiedClassName(target)) as Class;
}
catch (e:Error)
{
if(target is DisplayObject)
{
try
{
return target.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(target)) as Class;
}
catch(e:Error)
{
//nothing
}
}
}
return null;
}
/**
* Works like getStyleValue() on UIComponent, except it makes component
* and shared styles available globally rather than just in the component's
* class.
*
* @param target the component for which to retrieve the style value
* @param styleName the name of the style to retrieve
*/
public static function getStyleValue(target:UIComponent, styleName:String):Object
{
var value:Object = target.getStyle(styleName);
value = value ? value : StyleManager.getComponentStyle(target, styleName);
if(value)
{
return value;
}
var classDef:Class = UIComponentUtil.getClassDefinition(target);
var defaultStyles:Object;
//borrowed from fl.managers.StyleManager
// Walk the inheritance chain looking for a default styles object.
while(defaultStyles == null)
{
// Trick the strict compiler.
if(classDef["getStyleDefinition"] != null)
{
defaultStyles = classDef["getStyleDefinition"]();
break;
}
try
{
classDef = target.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(classDef)) as Class;
}
catch(err:Error)
{
try
{
classDef = getDefinitionByName(getQualifiedSuperclassName(classDef)) as Class;
}
catch (e:Error)
{
defaultStyles = UIComponent.getStyleDefinition();
break;
}
}
}
if(defaultStyles.hasOwnProperty(styleName))
{
return defaultStyles[styleName];
}
return null;
}
}
}

View File

@ -0,0 +1,69 @@
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
package com.yahoo.astra.fl.utils{
/**
* The XMLUtil class is an all-static class
* with methods for working with XML within Flash.
* Not to be confused with fl.utils.XMLUtil.
* You do not create instances of XMLUtil;
* instead you simply call static methods such as
* the <code>XMLUtil.createArrayFromXML()</code> method.
*
* @author Alaric Cole
* @see com.yahoo.astra.fl.data.XMLDataProvider
*/
public class XMLUtil
{
/**
* Creates an object with properties extracted from XML attributes
* @param node
*/
public static function createObjectFromXMLAttributes(node:XML):Object
{
//create an object and give it props from this nodes attributes
var obj:Object = {};
var attrs:XMLList = node.attributes();
for each (var attr:XML in attrs)
{
obj[attr.localName()] = attr.toString();
}
return obj;
}
/**
* Creates a hierarchical array from XML or an XMLList
* @param xml An XML or XMLList object
*/
public static function createArrayFromXML(xml:Object):Array
{
var nodes:XMLList;
var ar:Array = [];
if (xml is XML)
{
nodes = XML(xml).children();
} else if (xml is XMLList)
{
nodes = xml as XMLList;
} else
{
throw new TypeError("Error: Type Coercion failed: cannot convert " + xml + " to XML or XMLList.");
return null;
}
//loop through top level nodes
for each (var node:XML in nodes)
{
var obj:Object = createObjectFromXMLAttributes(node);
//loop through any nodes in this node
var propNodes:XMLList = node.*;
var data:Array = createArrayFromXML(propNodes);
if (data.length)
{
obj.data = data;
}
ar.push(obj);
}
return ar;
}
}
}