[Embed(source="index.xml", mimeType="application/octet-stream")]
private static var index_xml : Class;
[Embed(source="picture.png")]
private static var picture_png : Class;
public class res {
[Embed(source="test.png")]
public static var test: Class;
public static var res_test: int;
}
public class res_test extends mx.core.BitmapAsset {
public function res_test() {
super();
}
}
public class LanguageProvider {
private var fobj_languageData: Array = new Array();
public function Clear(): void {
fobj_languageData = new Array();
}
public function AddLanguageData(fileName : String): void {
var id : String = "";
var parent : XML = null;
for each (var item: XML in ResourcesManager.FileAsXML(fileName)..*.(hasOwnProperty("@value"))) {
id = item.name();
parent = item.parent();
while (parent != null) {
id = parent.name() + "." + id;
parent = parent.parent();
}
fobj_languageData[id] = item.@value;
}
}
public function GetStringFor(item : String): String {
var result: String = fobj_languageData[item];
if (result != null) return result; else return "<-!->";
}
}
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.events.CloseEvent;
import mx.core.Application;
// private
private var fbol_init: Boolean = false;
private var fobj_closeHandler: Function = null;
// protected
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (!fbol_init) {
var x:Number;
var y:Number;
if (parent == systemManager) {
x = (screen.width - width) / 2;
y = (screen.height - height) / 2;
}
else if (parent != null) {
x = (parent.width - width) / 2;
y = (parent.height - height) / 2;
}
else {
x = (Application.application.width - width) / 2;
y = (Application.application.height - height) / 2;
}
// Set my position, because my parent won't do it for me.
move(Math.round(x), Math.round(y));
fbol_init = true;
}
}
// public
public virtual function Show(closeHandler:Function = null): void {
fobj_closeHandler = closeHandler;
if (closeHandler != null) this.addEventListener(CloseEvent.CLOSE, closeHandler);
PopUpManager.addPopUp(this, Sprite(Application.application), true);
}
public virtual function Close(): void {
PopUpManager.removePopUp(this);
fbol_shown = false;
dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
if (fobj_closeHandler != null) removeEventListener(CloseEvent.CLOSE, fobj_closeHandler);
}
]]>
</mx:Script>
</mx:Panel>
<?xml version="1.0" encoding="utf-8"?>
<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml"
width="100"
height="100"
creationComplete="OnCreationComplete()"
borderThickness="0"
editable="false"
horizontalScrollPolicy="off"
verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
// static
private static var fobj_styleSheet : StyleSheet = null;
public static function SetStyleSheet(ss : StyleSheet):void {
fobj_styleSheet = ss;
}
// private
private function OnCreationComplete(): void {
if (fobj_styleSheet != null) this.styleSheet = fobj_styleSheet;
}
]]>
</mx:Script>
</mx:TextArea>
Source: https://habr.com/ru/post/43311/