Flex Air 周边整合之碎语

本文分享了使用FlexAir框架开发薪酬系统的过程,包括采用C++处理MySQL连接、利用FluorineFx调用本地DLL文件及实现软件自动更新等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

手边近期有一个项目(薪酬系统)要开工,开始用Flex Air打理框架

1、Flex Air 依然作为本地前台;
2、中介语言不再采用php(amfphp),java(lds)或c#(FluorineFx)来搞了,直接采用assql;
3. 数据库采用远程数据库Mysql

[Note]
1.由于涉及远程数据库,所以用C++编辑Mysql联机参数,再采用[url=http://www.covergraph.com/blog/archives/alchemy_0.5_setup.exe]Alchemy[/url]编译成swc来封装

//MySqlService.cpp

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "AS3.h"

AS3_Val GetMysqlArg(void* self, AS3_Val args)
{

char* val = NULL;
//本机
AS3_Val localconn = AS3_Object("host:StrType,port:StrType,username:StrType,password:StrType,database:StrType","127.0.0.1","3306","xxxxx", "xxxx","xxxxx");
//网络
AS3_Val netconn = AS3_Object("host:StrType,port:StrType,username:StrType,password:StrType,database:StrType","xxx.xxx.xx.xx","3306","xxxxx", "xxxx","xxxx");

AS3_ArrayValue( args, "StrType", &val );
if(val == NULL)
{
return localconn;
}

return netconn;

}

int main()
{
AS3_Val cMethod = AS3_Function( NULL, GetMysqlArg);
AS3_Val result = AS3_Object("GetMysqlArg: AS3ValType",cMethod);
AS3_Release(cMethod);
AS3_LibInit( result );

return 0;
}


//主程式运用

var cppMySqlService:CLibInit=new cmodule.mysqlservice.CLibInit;
var mysqlArgObj:Object=cppMySqlService.init();
//与远程数据库联机
var mysqlServie:Object=mysqlArgObj.GetMysqlArg("net");
SQLGlobal.set_mysql_host(mysqlServie.host);
SQLGlobal.set_mysql_port(int(mysqlServie.port))
SQLGlobal.set_mysql_username(mysqlServie.username)
SQLGlobal.set_mysql_password(mysqlServie.password)
SQLGlobal.set_mysql_database(mysqlServie.database)


2.由于项目又要涉及windows的相关操作,如调用.dll([url=http://aperture.fluorinefx.com/]FluorineFx Aperture framework[/url])等并且还有考虑到以后软件的自动更新,所以在前期得将程序以exe包形式发布,由于air官方不支持exe包的自动更新,所以采用了[url=http://code.google.com/p/nativeapplicationupdater/]nativeApplicationUpdater[/url]来处理,这样既兼顾了自动更新,也兼顾了与本地系统的API的交互;

protected function isNewerFunction(currentVersion:String, updateVersion:String):Boolean
{
if (currentVersion == updateVersion)
{
trace("版本一样,直接进入平台")
DoShowLogin()
}
else
{
trace("版本不一样")
//提示用户是否更新
Alert.show("软件有新的更新:版本(" + updater.updateVersion + ").下载安装更新吗?", "提示信息", 3, null, versionCloseHandler, null, 3)
}
return true;
}

private function versionCloseHandler(event:CloseEvent):void
{
if (event.detail == Alert.YES)
{
trace("更新");
doGoUpdate()
}
else
{
//客户不更新,直接登陆界面
DoShowLogin()
}
}

protected function doGoUpdate():void
{

doCreateDownloadingView()
updater.addEventListener(DownloadErrorEvent.DOWNLOAD_ERROR, updater_downloadErrorHandler);
updater.addEventListener(UpdateEvent.DOWNLOAD_COMPLETE, updater_downloadCompleteHandler);
updater.downloadUpdate();
}

private function doCreateDownloadingView():void
{

//清空对象,创建下载更新包自定义界面
MainAppContainer.removeAllChildren();

var viewHGroup:HGroup=new HGroup();
viewHGroup.setStyle("horizontalCenter", 0)
viewHGroup.setStyle("verticalCenter", 0);
viewHGroup.setStyle("verticalAlign", "top");
MainAppContainer.addChild(viewHGroup)

var bitmapImg:BitmapImage=new BitmapImage();
bitmapImg.source='/assets/system_upgrade.png';
viewHGroup.addElement(bitmapImg)

var viewVGroup:VGroup=new VGroup();
viewVGroup.percentWidth=100;
viewVGroup.setStyle("horizontalAlign", "center")
viewHGroup.addElement(viewVGroup)

var infoLabel:Label=new Label();
infoLabel.text="更新说明:"
viewVGroup.addElement(infoLabel)

var richTxt:RichText=new RichText();
richTxt.text=updater.updateDescription;
viewVGroup.addElement(richTxt);

var prgBar:ProgressBar=new ProgressBar();
prgBar.label="下载中... %3%";
prgBar.source=updater;
viewVGroup.addElement(prgBar);
}

protected function updater_errorHandler(event:ErrorEvent):void
{
Alert.show(event.text);
}
protected function updater_initializedHandler(event:UpdateEvent):void
{
trace("初始化毕,执行检查")
updater.checkNow();
}
protected function updater_updateStatusHandler(event:StatusUpdateEvent):void
{
if (event.available)
{
event.preventDefault();
}
else
{
Alert.show("Your application is up to date!");
}
}
private function updater_downloadCompleteHandler(event:UpdateEvent):void
{
trace("下载完成")
updater.installUpdate();
}

private function updater_downloadErrorHandler(event:DownloadErrorEvent):void
{
Alert.show("下载更新安装包出错,请稍候再试!");
}

/******************************************************************************/
public function DoShowLogin():void
{
trace("显示登陆界面")
this.stage.nativeWindow.visible=false
var logoWin:LoginWindow=new LoginWindow()
logoWin.open(true)
logoWin.nativeWindow.x=Capabilities.screenResolutionX / 2 - logoWin.width / 2;
logoWin.nativeWindow.y=Capabilities.screenResolutionY / 2 - logoWin.height / 2;
}

3.每一个控制单元仍然采用module来处理,本想采用常态的模式*.mxml来作界面,as编写操练,写了两三个模块单元,每次切换到Design模式,Adobe他爷爷,哇卡卡,最后还是把这个转换成全as,本想偷点懒,不想,还更花时间和精力。以后再也不想用尝试mxml(界面)+as(操纵)的方式,还有继续用全as来实现。卡死我了!

4.Tlf这么久了,还没有明显进步,[url=http://blogs.adobe.com/tlf/]Text Layout Framework Team[/url],why!!!!!!!!!!!!,难道非得要第三方来编写TableElement,CodeElement,MediaElement吗?
基于C2000 DSP的电力电子、电机驱动和数字滤波器的仿真模型构建及其C代码实现方法。首先,在MATLAB/Simulink环境中创建电力电子系统的仿真模型,如三相逆变器,重点讨论了PWM生成模块中死区时间的设置及其对输出波形的影响。接着,深入探讨了C2000 DSP内部各关键模块(如ADC、DAC、PWM定时器)的具体配置步骤,特别是EPWM模块采用上下计数模式以确保对称波形的生成。此外,还讲解了数字滤波器的设计流程,从MATLAB中的参数设定到最终转换为适用于嵌入式系统的高效C代码。文中强调了硬件在环(HIL)和支持快速原型设计(RCP)的重要性,并分享了一些实际项目中常见的陷阱及解决方案,如PCB布局不当导致的ADC采样异常等问题。最后,针对中断服务程序(ISR)提出了优化建议,避免因ISR执行时间过长而引起的系统不稳定现象。 适合人群:从事电力电子、电机控制系统开发的技术人员,尤其是那些希望深入了解C2000 DSP应用细节的研发工程师。 使用场景及目标:①掌握利用MATLAB/Simulink进行电力电子设备仿真的技巧;②学会正确配置C2000 DSP的各项外设资源;③能够独立完成从理论设计到实际产品落地全过程中的各个环节,包括但不限于数字滤波器设计、PWM信号生成、ADC采样同步等。 其他说明:文中提供了大量实用的代码片段和技术提示,帮助读者更好地理解和实践相关知识点。同时,也提到了一些常见错误案例,有助于开发者规避潜在风险。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值