首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

崩溃的 air 打印 以及 自动 更新 有关问题

2012-11-23 
崩溃的 air 打印 以及 自动 更新 问题AIR问题?特别注明一下air2要自己下sdk?一年前air做打印弹出一个确认

崩溃的 air 打印 以及 自动 更新 问题

AIR问题

?

特别注明一下air2要自己下sdk

?

一年前air做打印弹出一个确认框框,没法去掉这个框框,于是放只能放弃air.

?

搜到个国外论坛找到了swfkit 这玩意将swf打包成exe?

?

在PrintJob前加上下面两句话问题得已解决

?

接一来是自动更新的问题,值得庆幸的是 swfkit脚本可以调用exe,无耐同事找了一个开源的dephi程序完成了自动升级

?

?

?

?

var fp:FlashPlayer=new FlashPlayer();fp.showPrintDlg=false;var printJob:PrintJob=new PrintJob();

?

?

幸福的时光都是短暂的。悲剧的事情发生了。开源的升级程序让那该死的360报成木马。客户有意见了。

?

?

一阵冷汗后 ?又想回到air去完成自动升级,air2可以调exe了。又可以升级。感觉上蛮良好。弹出打印对话框的事再议,同

?

事写了一个程序 不断 监听 那个对话框。出来了就默认点击确认,对话框问题解决了。

?

?

幸福的时光仍是短暂。调试的一切正常,我的心都快喷出来了。纠结我一年的问题今天都解决了。

?

官方打印问题居然也解决了。

?

增强的打印机交互

新的打印支持可以更好地控制从 AIR 应用程序打印内容的方式,包括选择打印机、纸张大小和副本数。通过新的 API,开发人员可以检索其他打印信息,例如可打印区域、打印机是否可以打印彩色以及打印作业当前是否处于活动状态。还可以在打印时不显示打印对话框。

var printJob:PrintJob=new PrintJob();if(printJob.start2(null,false)){}
?

打包运行。fuck,调用exe报异常。完成没心理准备。他姐的真是打击啊。还好,有事不决问google,菩萨保佑有解决方

?

案, flex不成熟真是不成熟,不成熟弄死你我。打包出来的air安装是无法调用exe的。必需打成本地文件:

?

?

adt -package -target native TechPos.exe TechPos.air
?

?

高兴啊。试一下,打印问题是好的。 air的更新好做:代码如下

?

private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI();private function checkForUpdate(server:String,port:String,validateFile:String = "update.xml"):void {      appUpdater.updateURL = "http://"+server+":"+port+"/posinstall/"+validateFile; // Server-side XML file describing update      appUpdater.isCheckForUpdateVisible = false; // We won't ask permission to check for an update      appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdate); // Once initialized, run onUpdate      appUpdater.addEventListener(ErrorEvent.ERROR, onError); // If something goes wrong, run onError  appUpdater.addEventListener(UpdateEvent.CHECK_FOR_UPDATE,onError);appUpdater.addEventListener(UpdateEvent.INITIALIZED,onError);appUpdater.addEventListener(UpdateEvent.DOWNLOAD_START,onError);appUpdater.addEventListener(UpdateEvent.DOWNLOAD_COMPLETE,onError);appUpdater.addEventListener(UpdateEvent.BEFORE_INSTALL,onError);appUpdater.addEventListener(StatusUpdateEvent.UPDATE_STATUS,onError);appUpdater.addEventListener(DownloadErrorEvent.DOWNLOAD_ERROR,onError);    appUpdater.initialize(); // Initialize the update framework  }    private function onError(event:ErrorEvent):void {      Alert.show("请检查服务器设置是否正确!"+event.toString());  }  private function onUpdate(event:UpdateEvent):void {      appUpdater.checkNow(); // Go check for an update now  }  
<?xml version="1.0" encoding="utf-8"?><update xmlns="http://ns.adobe.com/air/framework/update/description/1.0"><version>2.0</version><url>http://localhost:8080/app.air</url><description>--><![CDATA[-->New version includes:-->    * Feature 1-->    * Feature 2-->    * Feature 3        --> ]]>--></description></update>
?

?

哎,真是万恶的adobe啊。居然更新不成功!

?

再拿app.air 安装 测试。。更新成功!

?

看到了曙光,真是开源的伟大啊?http://code.google.com/p/nativeapplicationupdater/

?

?

<?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"                                            xmlns:updater="http://updater.riaspace.com/"                                           creationComplete="updater.initialize()">        <fx:Script>                <![CDATA[                        import air.update.events.UpdateEvent;                        protected function updater_initializedHandler(event:UpdateEvent):void                        {                                updater.checkNow();                        }                ]]>        </fx:Script>        <fx:Declarations>                <updater:NativeApplicationUpdater id="updater"                         updateURL="https://yoursecurehost.com/download/update.xml"                        initialized="updater_initializedHandler(event)"/>        </fx:Declarations>                <s:Label text="You are updated to version: {updater.currentVersion}"                         horizontalCenter="0" verticalCenter="0" />        </s:WindowedApplication>Here is an update descriptor xml that the updateURL property is pointing to:<?xml version="1.0" encoding="utf-8"?><update xmlns="http://ns.riaspace.com/air/framework/update/description/1.1">        <!-- Mac update -->        <dmg>                <version>1.0.1</version>                <url>https://yoursecurehost.com/download/YourApplication.dmg</url>            <description>            <![CDATA[                * This a Mac update                ]]>        </description>        </dmg>                <!-- Win update -->        <exe>                <version>1.0.1</version>                <url>https://yoursecurehost.com/download/YourApplication.exe</url>            <description>            <![CDATA[                * This a Win update                ]]>        </description>        </exe>        <!-- Debian update -->        <deb>                <version>1.0.1</version>                <url>https://yoursecurehost.com/download/YourApplication.deb</url>            <description>            <![CDATA[                * This a Debian update                ]]>        </description>        </deb>        <!-- Redhat/Fedora/OpenSUSE update -->        <rpm>                <version>1.0.1</version>                <url>https://yoursecurehost.com/download/YourApplication.rpm</url>            <description>            <![CDATA[                * This a Redhat/Fedora/OpenSUSE update                ]]>        </description>        </rpm>        </update>

?

?

不尽人意的是不是官方提供的。就是检测下载,覆盖安装。。

?

?

测试期间弄了一段ant脚本。官方copy过来的还不能跑。有一些调整。也贴出来吧。

?

有一些变量可能要自己替换,以供大家参考吧

?

注意红色的地方,我被困了一下。-C变量是指进入当前目录,包含哪些目录只要加arg 就可以了

?

?

<property name="SDK_HOME" value="D:/Program Files/Adobe/Adobe Flash Builder 4 Plug-in/sdks/3.5.0.air.2"/>     <property name="ADL" value="${SDK_HOME}/bin/adl.exe"/>     <property name="ADT.JAR" value="${SDK_HOME}/lib/adt.jar"/><property name="MXMLC.JAR" value="${SDK_HOME}/lib/mxmlc.jar"/><!-- Project properties -->     <property name="PROJ_ROOT_DIR" value="${PROJECT_ROOT}/src/pos"/>     <property name="APP_NAME" value="TechPos"/>     <property name="APP_ROOT_DIR" value="${APP_ROOT}"/>     <property name="APP_ROOT_FILE" value="${APP_NAME}.swf"/>     <property name="APP_DESCRIPTOR" value="${PROJ_ROOT_DIR}/${APP_NAME}-app.xml"/>     <property name="AIR_NAME" value="${APP_NAME}.air"/>     <property name="release"  location="${PROJ_ROOT_DIR}/release"/>     <property name="STORETYPE" value="pkcs12"/>     <property name="KEYSTORE" value="aaaaaa.p12"/>      <property name="MAIN_SOURCE_FILE" value="${PROJ_ROOT_DIR}/${APP_NAME}.mxml"/>
<target name="init" depends="clean">     <mkdir dir="${release}"/>     </target>      <target name="test">     <echo>${APP_DESCRIPTOR}</echo>    <echo>${APP_ROOT_DIR}</echo>        <exec executable="${ADL}">             <arg value="${APP_DESCRIPTOR}"/>             <arg value="${APP_ROOT_DIR}"/>         </exec>      </target>      <target name="package" depends="clean" description="package">         <java jar="${ADT.JAR}" fork="true" failonerror="true">             <arg value="-package"/>             <arg value="-storetype"/>             <arg value="${STORETYPE}"/>             <arg value="-keystore"/>             <arg value="${KEYSTORE}"/>         <arg value="-storepass"/>        <arg value="aaaaaa"/>            <arg value="${DEPLOY_DIR}/${AIR_NAME}"/>             <arg value="${APP_DESCRIPTOR}"/>             <arg value="-C"/>             <arg value="${APP_ROOT_DIR}"/>             <arg value="${APP_ROOT_FILE}"/>         <arg value="opendoor.exe"/>         <arg value="public"/>        <arg value="images"/>         <arg value="lag"/>         <arg value="logo"/>         </java>     </target> 
<target name="keystore">        <java jar="${ADT.JAR}" fork="true" failonerror="true">            <arg value="-certificate"/>            <arg value="-cn"/>            <arg value="SelfSigned"/>            <arg value="1024-RSA"/>            <arg value="aaaaaa.p12"/>            <arg value="aaaaaa"/>        </java>    </target> 
?

要是哪一天flex ?air 等等更完美了。。。 别忘通知我一声

?

?

?

热点排行
Bad Request.