-
Most of my apps have been personal apps, or apps that i've built for my company. Some of my apps include one called xml text grabber, which takes an entire unit that's been developed in XML and outputs the text, titles, pages, and such for company use. Another is called grafu, which is an application that goes through the same XML structures, checks for errors with any graphic component, and outputs what line a graphic is on in the XML, the error involved, and what needs to be done to correct it.
Another is an application that goes through about 4000 XMLs at one time and fixes things that needs changing based on new standards. Another I've got is called Stress Reliever, which is an app that I've built, where you can beat up your computer's desktop.
I've got a lot of various applications that follow that standard. Then I also use the AIR Update Framework to update the apps, most of the time, my updates lie on a network location.
-
the stress reliever is hilarious. haha
when you use the air update framework for updates, you would put the new file in the specified location on your site and the app will look for updates for itself?
-
LOL, yeah, I've used it many times.
But the Update framework, you put an XML file on your server, and then new .air file in the same location. The update XML is similar to this:
<?xml version="1.0" encoding="utf-8"?>
<update xmlns="http://ns.adobe.com/air/framework/update/description/1.0">
<version>2.3.8</version>
<url>location of new air file</url>
<description><![CDATA[
This version has fixes for the following known issues:
*Issue.
]]></description>
</update>
-
is there actionscript associated with that? i would assume so
-
-
umm...copy paste? ha ha
sortof confused...
so i put all that code into myWindow.as and add that .swc in the publish settings and put:
import air.update.ApplicationUpdater;
var appUpdater:ApplicationUpdater = new ApplicationUpdater();
in the .fla actions layer with a movieclip?
-
Code:
import air.update.ApplicationUpdater;
import air.update.events.StatusFileUpdateEvent;
import air.update.events.StatusUpdateErrorEvent;
import air.update.events.StatusFileUpdateErrorEvent;
import air.update.events.DownloadErrorEvent;
import air.update.events.StatusUpdateEvent;
import air.update.events.UpdateEvent;
import flash.events.ErrorEvent;
import flash.events.MouseEvent;
import flash.desktop.NativeApplication;
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowType;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import fl.controls.Button;
import Namespace;
import XML;
import com.jw.window.jwUpdateWindow;
var appUpdater:ApplicationUpdater = new ApplicationUpdater();
var window:NativeWindow;
var windowContent:jwUpdateWindow = new jwUpdateWindow();
var existentListeners:Dictionary = new Dictionary();
//initialize the updater; gets called when the application is loaded
function initializeUpdater():void {
setApplicationNameAndVersion();
appUpdater.updateURL = "Your updater XML file link";
//we set the event handlers for INITIALIZED nad ERROR
appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdateInit);
appUpdater.addEventListener(ErrorEvent.ERROR, onError);
appUpdater.addEventListener(StatusUpdateEvent.UPDATE_STATUS, onStatusUpdate);
appUpdater.addEventListener(StatusUpdateErrorEvent.UPDATE_ERROR, onStatusUpdateError);
appUpdater.addEventListener(ProgressEvent.PROGRESS, onDownloadProgress);
appUpdater.addEventListener(UpdateEvent.DOWNLOAD_COMPLETE, onDownloadComplete);
appUpdater.addEventListener(DownloadErrorEvent.DOWNLOAD_ERROR, onDownloadError);
//initialize the updater
appUpdater.initialize();
}
function initializeUpdaterNoMenu():void {
setApplicationNameAndVersion();
appUpdater.updateURL = "your update XML URL goes here";
//we set the event handlers for INITIALIZED nad ERROR
appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdateInit);
appUpdater.addEventListener(ErrorEvent.ERROR, onError);
appUpdater.addEventListener(StatusUpdateEvent.UPDATE_STATUS, onStatusUpdateNoMenu);
appUpdater.addEventListener(StatusUpdateErrorEvent.UPDATE_ERROR, onStatusUpdateError);
appUpdater.addEventListener(ProgressEvent.PROGRESS, onDownloadProgress);
appUpdater.addEventListener(UpdateEvent.DOWNLOAD_COMPLETE, onDownloadComplete);
appUpdater.addEventListener(DownloadErrorEvent.DOWNLOAD_ERROR, onDownloadError);
//initialize the updater
appUpdater.initialize();
}
//listener for INITIALIZED event of the applicationUpdater;
function onUpdateInit(evt:UpdateEvent):void {
//start the process of checking for a new update and to install
appUpdater.checkNow();
}
//Handler function for error events triggered by the ApplicationUpdater.initialize
function onError(evt:ErrorEvent):void {
//trace(evt);
createWindow();
displayWindowError(evt.errorID, evt.text);
}
//handler function for StatusUpdateEvent.UPDATE_STATUS
//this is called after the update descriptor was downloaded and interpreted successfuly
function onStatusUpdate(evt:StatusUpdateEvent):void {
//trace(evt);
//prevent the default (start downloading the new version)
evt.preventDefault();
createWindow();
windowContent.bar.visible = false; //hide the progress bar
//create the window for displaying Update available
if (evt.available) {
window.visible = true;
windowContent.title = "Update Available";
windowContent.enableDescription = true;
windowContent.description = evt.version + " " + evt.details[0][1];
windowContent.buttonLeft.label = "Update";
windowContent.buttonRight.label = "Cancel";
addEventToButton(windowContent.buttonLeft, MouseEvent.CLICK, startDownload);
addEventToButton(windowContent.buttonRight, MouseEvent.CLICK, closeWindow);
//we don't have an update, so display this information
} else {
window.visible = true;
windowContent.title = "No Update Available";
windowContent.enableDescription = false;
windowContent.buttonLeft.visible = false;
windowContent.buttonRight.label = "Close";
addEventToButton(windowContent.buttonRight, MouseEvent.CLICK, closeWindow);
}
}
function onStatusUpdateNoMenu(evt:StatusUpdateEvent):void {
//trace(evt);
//prevent the default (start downloading the new version)
evt.preventDefault();
createWindow();
windowContent.bar.visible = false; //hide the progress bar
//create the window for displaying Update available
if (evt.available) {
window.visible = true;
windowContent.title = "Update Available";
windowContent.enableDescription = true;
windowContent.description = evt.version + " " + evt.details[0][1];
windowContent.buttonLeft.label = "Update";
windowContent.buttonRight.label = "Cancel";
addEventToButton(windowContent.buttonLeft, MouseEvent.CLICK, startDownload);
addEventToButton(windowContent.buttonRight, MouseEvent.CLICK, closeWindow);
//we don't have an update, so display this information
} else {
window.visible = false;
windowContent.title = "No Update Available";
windowContent.enableDescription = false;
windowContent.buttonLeft.visible = false;
windowContent.buttonRight.label = "Close";
addEventToButton(windowContent.buttonRight, MouseEvent.CLICK, closeWindow);
closeWindow(null);
}
}
//error listener for an error when the updater could not download or
//interpret the update descriptor file.
function onStatusUpdateError(evt:StatusUpdateErrorEvent):void {
createWindow();
displayWindowError(evt.subErrorID, evt.text);
}
//error listener for DownloadErrorEvent. Dispatched if there is an error while connecting or
//downloading the update file. It is also dispatched for invalid HTTP statuses
//(such as “404 - File not found”).
function onDownloadError(evt:DownloadErrorEvent):void {
createWindow();
displayWindowError(evt.subErrorID, evt.text);
}
//start the download of the new version
function startDownload(evt:MouseEvent):void {
appUpdater.downloadUpdate();
createWindow();
windowContent.bar.visible = true;
windowContent.bar.setProgress(0, 100);
}
//listener for the ProgressEvent when a download of the new version is in progress
function onDownloadProgress(evt:ProgressEvent):void {
windowContent.bar.setProgress(evt.bytesLoaded, evt.bytesTotal);
}
//listener for the complete event for downloading the application
//just close the window; the downloaded version will be automatically installed,
//and then the application gets restarted
function onDownloadComplete(evt:UpdateEvent):void {
closeWindow(null);
}
//sets the state of the window in error display mode
function displayWindowError(errorId:int, errorText:String):void {
windowContent.title = "Error";
windowContent.enableDescription = true;
windowContent.description = "Error ID: " + errorId + ". " + errorText;
windowContent.buttonLeft.visible = false;
windowContent.buttonRight.label = "Close";
windowContent.bar.visible = false;
addEventToButton(windowContent.buttonRight, MouseEvent.CLICK, closeWindow);
}
//create a window using NativeWindow, and as a content jwUpdateWindow class
function createWindow():void {
if (window == null) {
var options:NativeWindowInitOptions = new NativeWindowInitOptions();
options.systemChrome = NativeWindowSystemChrome.STANDARD;
options.type = NativeWindowType.NORMAL;
options.resizable = false;
window = new NativeWindow(options);
window.title = "Application Updates";
window.x = 300;
window.y = 200;
window.stage.stageHeight = 230;
window.stage.stageWidth = 450;
window.stage.scaleMode = StageScaleMode.NO_SCALE;
window.stage.align = StageAlign.TOP_LEFT;
window.stage.addChild(windowContent);
window.addEventListener(Event.CLOSE, closeWindow);
windowContent.bar.visible = false;
}
window.alwaysInFront = true;
window.visible = false;
}
//close the window
function closeWindow(evt:Event):void {
appUpdater.removeEventListener(UpdateEvent.INITIALIZED, onUpdateInit);
appUpdater.removeEventListener(ErrorEvent.ERROR, onError);
appUpdater.removeEventListener(StatusUpdateEvent.UPDATE_STATUS, onStatusUpdate);
appUpdater.removeEventListener(StatusUpdateErrorEvent.UPDATE_ERROR, onStatusUpdateError);
appUpdater.removeEventListener(ProgressEvent.PROGRESS, onDownloadProgress);
appUpdater.removeEventListener(UpdateEvent.DOWNLOAD_COMPLETE, onDownloadComplete);
appUpdater.removeEventListener(DownloadErrorEvent.DOWNLOAD_ERROR, onDownloadError);
window.removeEventListener(Event.CLOSE, closeWindow);
window.close();
appUpdater = new ApplicationUpdater();
windowContent = new jwUpdateWindow();
existentListeners = new Dictionary();
window = null;
}
//hide the window
function hideWindow():void {
window.visible = false;
}
//sets the application name and version in the main window
function setApplicationNameAndVersion():void {
var appXML:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = appXML.namespace();
//lblVersion.text = appXML.ns::version;
//lblName.text = appXML.ns::name;
}
//add to the given button, the listener for given type (actually we use only the type MouseEvent.CLICK).
//we use a dictionary to store for each button the listener registered.
//when this function gets called, first we remove any registered listener. Next we register the listener
//on the button, and next we save to dictionary.
function addEventToButton(button:Button, type:String, listener:Function):void {
//remove existent listneres
if (existentListeners[button] != null) {
var arr:Array = existentListeners[button] as Array;
button.removeEventListener(type, arr[0]);
}
existentListeners[button] = [];
button.addEventListener(type, listener);
existentListeners[button][0] = listener;
button.visible = true;
}
initializeUpdaterNoMenu();//initialize the updater
Code:
package com.jw.window {
import flash.display.MovieClip;
import fl.controls.ProgressBar;
import fl.controls.Button;
import fl.controls.TextArea;
import flash.text.*;
//this class sets the type for the jwUpdateWindow component
//we use it as a proxy to the UI controls from the jwUpdateWindow component
//(buttons, labels, text area, or progress bar)
public class jwUpdateWindow extends MovieClip {
public function jwUpdateWindow() {
var fmt1:TextFormat = new TextFormat("Arial", 15, 0x000000, true, false, false, null, null, null, null, null, null, null);
var fmt2:TextFormat = new TextFormat("Arial", 20, 0xFFFFFF, true, false, false, null, null, null, null, null, null, null);
description_1.setStyle("textFormat", fmt1);
title_1.setTextFormat(fmt2);
title_1.defaultTextFormat = fmt2;
}
public function set title(text:String):void {
title_1.text = text;
}
public function set description(text:String):void {
description_1.text = text;
}
public function set enableDescription(enable:Boolean):void {
description_1.visible = enable;
}
public function enableBar(enable:Boolean):void {
bar_1.visible = enable;
}
public function get bar():ProgressBar {
return bar_1;
}
public function get buttonLeft():Button {
return button_1;
}
public function get buttonRight():Button {
return button_2;
}
}
}
-
are you saying put that code in the app's .fla file?
-
You could make it into a class, but the code from the first block resides in my FLA file. The second set is code from a class that I use.
-
i have the source files from that adobe article...can i use those?
-
You can do whatever you'd like to do, but I suggest going through that article, that way you can learn the jist of whats going on.
-
will do...thanks for the help
-