Flex4 Declarations in ActionScript

抽空整理Cairgorn3时,由于喜欢Code,而不喜欢Block,所以想把Declarations声明放到AS中去,由于C3采用了spicefactory框架,所以按照spicefactory的官方说明,居然不能build,最后采用-keep方式查看code,修改了一下AS代码,不采用官方的方式,居然成功了,无语!
主文件:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="850"
height="450"
preinitialize="preinit();"
creationComplete="init()">
<fx:Style source="assets/contactsStyles.css"/>
<fx:Script source="Main.as"/>
</s:WindowedApplication>


<fx:Declarations>
<spicefactory:ContextBuilder>

<cairngorm:CairngormIntegrationSupport/>
<spicefactory:FlexConfig type="{InsyncContext}"/>
<spicefactory:MessageSettings unhandledErrors="{ErrorPolicy.RETHROW}"/>
</spicefactory:ContextBuilder>
</fx:Declarations>


以上声明,我想转到AS中去
private function preinit():void
{
var temp:ContextBuilderTag=new ContextBuilderTag();
var cairgormIS:CairngormIntegrationSupport=new CairngormIntegrationSupport();
var flexConfig:FlexConfigTag=new FlexConfigTag();
flexConfig.type=InsyncContext;
var messageST:MessageSettingsTag=new MessageSettingsTag();
messageST.unhandledErrors=ErrorPolicy.RETHROW
temp.processors=[cairgormIS, flexConfig, messageST];
temp.initialized(this, "contextBuilderTag")
}

Main.as文件

import com.adobe.cairngorm.CairngormIntegrationSupport;
import flash.display.DisplayObject;
import insync.presentation.ContactList;
import insync.presentation.ContactsNavigator;
import insync.presentation.Toolbar;
import mx.containers.HDividedBox;
import mx.containers.VBox;
import org.spicefactory.parsley.core.messaging.ErrorPolicy;
import org.spicefactory.parsley.flex.FlexConfig;
import org.spicefactory.parsley.flex.FlexContextBuilder;
import org.spicefactory.parsley.flex.tag.builder.ContextBuilderTag;
import org.spicefactory.parsley.flex.tag.builder.FlexConfigTag;
import org.spicefactory.parsley.flex.tag.builder.MessageSettingsTag;

private function preinit():void
{
var temp:ContextBuilderTag=new ContextBuilderTag();
var cairgormIS:CairngormIntegrationSupport=new CairngormIntegrationSupport();
var flexConfig:FlexConfigTag=new FlexConfigTag();
flexConfig.type=InsyncContext;
var messageST:MessageSettingsTag=new MessageSettingsTag();
messageST.unhandledErrors=ErrorPolicy.RETHROW
temp.processors=[cairgormIS, flexConfig, messageST];
temp.initialized(this, "contextBuilderTag")
}

private function init():void
{
var mainVBox:VBox=new VBox();
mainVBox.percentHeight=100;
mainVBox.percentWidth=100;
this.addElement(mainVBox);

var toolBar:Toolbar=new Toolbar();
toolBar.percentWidth=100;
mainVBox.addChild(toolBar);

var hdvidedBox:HDividedBox=new HDividedBox();
hdvidedBox.percentHeight=100;
hdvidedBox.percentWidth=100;
mainVBox.addChild(hdvidedBox);

var contactNav:ContactsNavigator=new ContactsNavigator();
contactNav.percentHeight=100;
contactNav.percentWidth=100;
hdvidedBox.addChild(contactNav);

var contactList:ContactList=new ContactList();
contactList.width=300;
contactList.percentHeight=100;
hdvidedBox.addChild(contactList);
}



spicefactory+spicelib(v2.3.1)源码包:org
cairngorm3源码包:com
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值