抽空整理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