Flash Builder - AS3, kode yang di komentari.
Jadi saya ngoding di Adobe Flash Builder (v4.6), lalu banyak kode yang saya komentari. Lalu saya merasa --eman-eman-- kalau dihapus. Jadi saya dokumentasikan saja di blog saya.
/* update - 201604141142 */
datatree.addEventListener(CollectionEvent.COLLECTION_CHANGE,function(ev:CollectionEvent):void {
trace(datatree.getItemAt(ev.location)); //berhasil
trace(tree_displ.getParentItem(datatree.getItemAt(ev.location))); //berhasil
trace(ev.location);
trace(tree_displ.getParentItem(ev.items));
var obj = ev.items;
var par = tree_displ.getParentItem(ev.items); // false: null
var par = tree_displ.getParentItem(datatree.getItemAt(ev.location));
if(par === null) {
level 1
datatree.getItemAt(ev.location).children = null;
} else {
level 2
}
if(par === null) { //berarti level paling atas
trace(tree_displ.getItemIndex(ev.items));
}
trace(tree_displ.getItemIndex(ev.items));
trace(datatree.getItemIndex(ev.items));
trace('-------------------------------------------');
});
/* update - 201604141135 */
refrasher(function():void {
trace(dataset.getItemAt(idx+1).label);
},idx);
trace(dataset.getItemAt(idx).children.getItemAt(0).label);
trace(dataset.getItemAt(idx).children.getItemIndex(dataset.getItemAt(idx).children.getItemAt(0))); //bisa tapi 0 terus
trace(dataset.getItemIndex(dataset.getItemAt(idx).children.getItemAt(0)));
treevw.indexToItemRenderer(idx);
dataset.getItemAt(idx).children.refresh();
dataset.itemUpdated(treevw.getItemAt(idx));
if(dataset.refresh()) { trace('freshed'); }
trmapping(0);
dataset.enableAutoUpdate();
dataset.addEventListener(CollectionEvent.COLLECTION_CHANGE,function(ev:CollectionEvent):void {
trace('cngaed: '+ev.toString());
});
dataset.addEventListener(CollectionEventKind.REFRESH,function(ev:CollectionEventKind):void {
trace('reffdsss');
});
private function trmapping(idx:int):void { //browse-tree
try {
var o:Object = dataset.getItemAt(idx); //selalu baris pertama
if(dataset.refresh()) { //harus komplit dulu
trace("idx: "+idx+", "+o.KODE); //cameo
dataset.getItemAt(idx).children.addItem(tree_busyinfo);
// request
master_aset.aset2kode(o.KODE+'.*');
master_aset.aset2kode.addEventListener(ResultEvent.RESULT,function(data:Object):void {
master_aset.aset2kode.removeEventListener(ResultEvent.RESULT,arguments.callee);
dataset.getItemAt(idx).children.removeAll();
var res:Array = data.result;
if(res.length > 0) {
for (var i:int = 0; i < res.length; i++) {
var obj:Object = res[i];
obj.label = obj.KODE+" - "+obj.URAI;
obj.children = new ArrayCollection();
dataset.getItemAt(idx).children.addItem(obj);
}
} else {
dataset.getItemAt(idx).children = null;
}
trace("asetman.enclosing_method(data)");
dataset.itemUpdated(dataset.getItemAt(idx)); //pertama update item.
if(dataset.getItemAt(idx).children === null) { //validasi children
//tak ada cildren, refrash/bisa lanjut?
} else { //berarti punya children, walaupun 1
trace("-- ada anak");
//dapatkan penempatan index child-pertama, kalau -1, berarti refrash belum selesai
var fcii = dataset.getItemIndex(dataset.getItemAt(idx).children.getItemAt(0)); // first-children item-index
trace("id anak pertama:"+fcii);
if(fcii < 0) {
//tunggu
dataset.addEventListener(CollectionEventKind.REFRESH,function():void {
dataset.removeEventListener(CollectionEventKind.REFRESH,arguments.callee); // sekali
var fcii2 = dataset.getItemIndex(dataset.getItemAt(idx).children.getItemAt(0)); // first-children item-index v2
trmapping(fcii2);
});
} else {
//mapping ulang
trmapping(fcii);
}
dataset.addEventListener(CollectionEventKind.REFRESH,function():void {
});
if(dataset.getItemAt(idx).children.length > 0) { //kalau ada children
dapatkan index, dari children pertama
var nidx = dataset.getItemIndex(dataset.getItemAt(idx).children[0]);
trace("anak: "+nidx);
}
}
trace(dataset.getItemAt(idx).children.length);
dataset.refresh();
trmapping(idx+1);
});
} else {
setTimeout(function():void {
trmapping(idx);
},0);
}
} catch(error:Error) { trace("asetman.trmapping(idx) - donothing"); }
}
/* update - 201604141127 */
private function trmap(idx:int):void {
trace(dataset.getItemAt(idx).label);
tr_idx = idx;
dataset.getItemAt(idx).children.addItem(tr_busyinfo);
master_aset.aset2kode(dataset.getItemAt(idx).KODE+".*");
master_aset.aset2kode.addEventListener(ResultEvent.RESULT,function(data:Object):void {
master_aset.aset2kode.removeEventListener(ResultEvent.RESULT,arguments.callee);
dataset.getItemAt(idx).children.removeAll();
var res = data.result;
if(res.length > 0) {
for (var i:int = 0; i < res.length; i++) {
var obj:Object = res[i];
obj.label = obj.KODE+" - "+obj.URAI;
obj.children = new ArrayCollection();
dataset.getItemAt(idx).children.addItem(obj);
}
} else {
dataset.getItemAt(idx).children = null;
}
if(dataset.getItemAt(idx).children !== null) {
trace('cek anak:');
trace(dataset.getItemAt(idx).children.getItemAt(0).label); // berhasil
}
dataset.itemUpdated(dataset.getItemAt(idx)); //berhasil
trfresh(function():void {
try {
dataset.getItemAt(idx+1);
trmap(idx+1);
} catch(error:Error) {
trace("asetman2.enclosing_method()");
trace(dataset.getItemAt(1).label);
}
});
});
}
/* update - 201604111052 */
var netconfig:avz.net = new net("baseConfig/validateDbSetting");
netconfig.success(function(data:*):void {
trace(data[0]);
if (data[0]) {
//donothing
} else {
tw_dbsetting();
}
});
/* update - 201604080940 */
public var gin_dbsetting:gin.dbsetting;
PopUpManager.addPopUp(gin_dbsetting,null,true); //fail
PopUpManager.createPopUp(this,gin_dbsetting,true); //fail
PopUpManager.createPopUp(null,gin_dbsetting,true); //fail
PopUpManager.centerPopUp(gin_dbsetting); //fail
PopUpManager.createPopUp(this,new gin_dbsetting(),true);
protected function app_ready():void {
var Net:avz.net = new net("ExampleService/returnOneParam","halo dunia");
Net.success(function(res):void { trace('Berhasil');trace(res); });
Net.fail(function():void { trace('Gagal'); });
Net.always(function():void { trace('=============='); });
var btn:Button = new Button;
btn.label = 'tes koneksi';
btn.addEventListener(MouseEvent.CLICK,function(ev:MouseEvent):void {
Net.req_args("ExampleService/returnOneParam");
setTimeout(function() {
Net.req_args("from ExampleService/returnOneParam");
},1000);
});
addElement(btn);
btn.x = 100;
btn.y = 100;
}
protected function app_ready():void {
is_signed = true;
if(is_signed) {
addElement(gin_dashboard);
gin_dashboard.horizontalCenter = 0;
gin_dashboard.verticalCenter = 0;
} else {
addElement(gin_signin);
gin_signin.horizontalCenter = 0;
gin_signin.verticalCenter = 0;
}
}
/* initial */
sidebar.sidebar_btn_home.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
var b:Button = sidebar.getChildAt(0) as Button;
b.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
trace(sidebar['sidebar_btn_home']);
this['sidebar_btn_home'].dispatchEvent(new MouseEvent(MouseEvent.CLICK));
_front_signup.dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
var c:Class = getDefinitionByName(getQualifiedClassName('home')) as Class;
var o:Object = new c();
trace(c);
var c:Class = getDefinitionByName('main.aset.home') as Class;
var o:Object = new c();
trace(o);
var content_class:Class = getDefinitionByName('main.content.'+dashboard_content_list[i][0]) as Class;
var content_obj:Object = new content_class();
dashboard_content[dashboard_content_list[i][0]] = content_obj;
var com_class:Class = getDefinitionByName('gin.aset.'+com_name) as Class;
trace(com_class);
var com_class:Class = Class(getDefinitionByName('gin.aset.'+com_name)); //work-bitch
var com_obj:Object = new com_class();
trace(com_obj.toString());
var com_obj:Object = new com_class();
addChild(DisplayObject(com_obj));
var c:Class = getDefinitionByName(getQualifiedClassName('gin.aset.home')) as Class;
var o:ClassFactory = ClassFactory(c);
var o:ClassFactory = new ClassFactory(c);
var e:Object = o.newInstance();
var c:Class = Class(getDefinitionByName(getQualifiedClassName('gin.aset.home')));
var c:String = getQualifiedClassName('gin.aset.home');
var c:Class = Class(
getDefinitionByName(
getQualifiedSuperclassName('gin.aset.home')
)
);
var o:Object = new c();
// dashboard-com
var com_class:Object = getDefinitionByName('gin.aset.'+com_list[i][0]);
trace(com_class);
var dash_com_class:Class = getDefinitionByName('gin.aset.'+com_list[i][0]) as Class;
var dash_com_obj:Object = new dash_com_class;
var dash_com_obj:Object = getDefinitionByName('com.'+com_list[i][0]) as Object;
com[com_list[i][0]]:Object = new dash_com_class();
trace(com.home);
trace(dash_com_class);
com.com_list[i][0]:gin.aset.* = new com_list[i][0]();
sidebar_nav[nav_btn_list[i][0]]:Class;
sidebar_nav[nav_btn_list[i][0]]:gin.aset[nav_btn_list[i][0]] = new nav_btn_list[i][0];
trace(nav_btn_list[i][0]);
var c:Object = getDefinitionByName('gin.aset.'+nav_btn_list[i][0]);
trace('gin.aset.'+nav_btn_list[i][0]);
nav_btn[nav_btn_list[i][0]]:gin.aset[nav_btn_list[i][0]] = new nav_btn_list[i][0]();
import mx.containers.Accordion;
import spark.components.NavigatorContent;
import spark.components.Button;
protected var nav:Accordion;
protected var nav_ncontent:NavigatorContent;
protected var nav_vgroup:VGroup;
protected var nav_button:Button;
protected var nav_value:Array = [
['Index',['satu','dua','tiga']],
['test',['sanga','dasa','sewelas']]
];
protected function dashboard_ready():void {
generate_nav();
trace(test_btn.height);
for (var i:int = 0; i < nav_value.length; i++) {
nav_content = new NavigatorContent();
nav_content.label = nav_value[i][0];
for (var j:int = 0; j < nav_value[i][1].length; j++) {
nav_button = new Button();
nav_button.label = nav_value[i][1][j];
nav_content.addElement(nav_button);
trace(nav_button.getBounds(nav_content));
}
nav_content.height = 100;
nav.addElement(nav_content);
trace(nav_value[i][0]);
trace(nav_value[i][1]);
}
addElement(nav);
nav_content = new NavigatorContent();
nav_content.label =
content.addElement(nav);
}
protected function generate_nav():void {
//nav
nav = new Accordion; //mx
sidebar.addElement(nav);
nav.percentWidth = 100;
for (var i:int = 0; i < nav_value.length; i++) {
//content
nav_ncontent = new NavigatorContent; //s
nav.addChild(nav_ncontent);
nav_ncontent.percentWidth = 100;
nav_ncontent.label = nav_value[i][0];
//group
nav_vgroup = new VGroup; //s
nav_ncontent.addElement(nav_vgroup);
nav_vgroup.gap = 0;
nav_vgroup.percentWidth = 100;
for (var j:int = 0; j < nav_value[i][1].length; j++) {
//button
nav_button = new Button; //s
nav_vgroup.addElement(nav_button);
nav_button.label = nav_value[i][1][j];
nav_button.setStyle("cornerRadius",0);
nav_button.percentWidth = 100;
}
}
}
Komentar
Posting Komentar
Komentar ...