http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/Config.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/Config.as b/TourDeFlex/TourDeFlex/src/Config.as index 85a6384..ba2a287 100644 --- a/TourDeFlex/TourDeFlex/src/Config.as +++ b/TourDeFlex/TourDeFlex/src/Config.as @@ -16,142 +16,142 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package -{ - import classes.LocalQuickStart; - - import flash.filesystem.File; - import flash.filesystem.FileMode; - import flash.filesystem.FileStream; - import flash.system.Capabilities; - - public class Config - { - [Bindable] public static var PROGRAM_TITLE:String = "Tour de Flex"; - [Bindable] public static var APP_VERSION:String = "0"; - [Bindable] public static var OBJECTS_FILE_VERSION:String = "0"; - [Bindable] public static var OBJECTS_TOTAL:int = 0; - [Bindable] public static var ABOUT_MENU_LIST:XMLList; - [Bindable] public static var IS_ONLINE:Boolean = false; - [Bindable] public static var USE_SPLASH:Boolean = true; - - //public static var SETTINGS_FILE:String = "settings.xml"; - //public static function get SETTINGS_URL():String {return "data/" + SETTINGS_FILE;} - //public static var settingsXml:XML; - - [Bindable] public static var ABOUT_MENU_TITLE:String = "Flex Resources"; - - [Bindable] public static var SPLASH_URL:String = "data/assets/intro.flv"; - [Bindable] public static var QUICK_START_REMOTE_URL:String = "http://tourdeflex.blogspot.com"; - [Bindable] public static var QUICK_START_LOCAL_URL:String = "data/quickstart.html"; - - public static var OBJECTS_FILE:String = "objects-desktop2.xml"; - public static function get OBJECTS_URL():String {return "data/" + OBJECTS_FILE;} - public static var LOCAL_OBJECTS_ROOT_PATH:String = "objects/"; - - public static var OBJECTS_UPDATER_FILE:String = "objects-desktop2-update.xml"; - public static function get OBJECTS_UPDATER_URL():String {return "http://tourdeflex.adobe.com/download/" + OBJECTS_UPDATER_FILE;} - public static var APP_UPDATER_URL:String = "http://tourdeflex.adobe.com/download/update4.xml"; - - public static var ONLINE_STATUS_URL:String = "http://tourdeflex.adobe.com/ping.html"; - public static var OFFLINE_URL:String = "data/offline.html"; - - private static var BASE_URL:String = "http://tourdeflex.adobe.com/server/"; - [Bindable] public static var DATA_EXCHANGE_URL:String = BASE_URL + "main.php"; - - private static var COMENTS_URL_QUERY_STRING:String = "main.php?Request=GetComments&ObjectId="; - public static var COMMENTS_URL:String = BASE_URL + COMENTS_URL_QUERY_STRING; - - public static var HEADER_GRADIENT_IMAGE:String = "images/header_gradient.png"; - public static var HEADER_IMAGE:String = "images/header_logo.png"; - - public static var TREE_NO_ICON:String = "images/tree_noIcon.png"; - - public function Config() - { - } - - /* - public static function loadSettings():void - { - setLocalization(); - - var loader:URLLoader = new URLLoader(new URLRequest(Config.SETTINGS_URL)); - loader.addEventListener(Event.COMPLETE, settingsXmlLoaded); - - var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor; - var ns:Namespace = appXml.namespace(); - APP_VERSION = appXml.ns::version; - } - */ - - public static function setLocalization():void - { - //var localLanguage:String = Capabilities.languages[0].toString().toLowerCase(); //for 'en-us' - var localLanguage:String = Capabilities.language.toLowerCase(); //for 'en' - trace("LANG=" + localLanguage); - //localLanguage = "jp"; //for testing - //trace(localLanguage); - - if(localLanguage != "en" && localLanguage != "en-us") - { - //Config.QUICK_START_REMOTE_URL = appendLanguage(Config.QUICK_START_REMOTE_URL, localLanguage); - //Config.QUICK_START_LOCAL_URL = appendLanguage(Config.QUICK_START_LOCAL_URL, localLanguage); - - var localizedObjectFile:String = "objects-desktop_" + localLanguage + ".xml"; - var staticObjectFile:File = File.applicationDirectory.resolvePath("data/" + localizedObjectFile); - if(staticObjectFile.exists) - { - OBJECTS_FILE = localizedObjectFile; - Config.OBJECTS_UPDATER_FILE = "objects-desktop-update_" + localLanguage + ".xml"; - //SETTINGS_FILE = "settings_" + localLanguage + ".xml"; - } - } - } - - public static function appendLanguage(oldPath:String, lang:String):String - { - var newPath:String = oldPath; - - var pos:int = oldPath.lastIndexOf("."); - if(pos > 0) - { - var ext:String = oldPath.substring(pos, oldPath.length); - newPath = oldPath.substring(0, pos); - newPath += "_" + lang + ext; - } - - return newPath; - } - - /* - private static function settingsXmlLoaded(event:Event):void - { - var loader:URLLoader = URLLoader(event.target); - settingsXml = new XML(loader.data); - PROGRAM_TITLE = settingsXml.@title; - ABOUT_MENU_LIST = settingsXml.AboutMenu.Item; - ABOUT_MENU_TITLE = settingsXml.AboutMenu.@title; - } - */ - - public static function isAppFirstTimeRun():Boolean - { - var isFirstTime:Boolean = false; - var appFirstTimeRunFile:File = File.applicationStorageDirectory.resolvePath("versions/" + APP_VERSION); - - if(!appFirstTimeRunFile.exists) - { - var fileStream:FileStream = new FileStream(); - fileStream.open(appFirstTimeRunFile, FileMode.WRITE); - fileStream.writeUTFBytes(APP_VERSION); - fileStream.close(); - - isFirstTime = true; - } - - return isFirstTime; - } - - } +package +{ + import classes.LocalQuickStart; + + import flash.filesystem.File; + import flash.filesystem.FileMode; + import flash.filesystem.FileStream; + import flash.system.Capabilities; + + public class Config + { + [Bindable] public static var PROGRAM_TITLE:String = "Tour de Flex"; + [Bindable] public static var APP_VERSION:String = "0"; + [Bindable] public static var OBJECTS_FILE_VERSION:String = "0"; + [Bindable] public static var OBJECTS_TOTAL:int = 0; + [Bindable] public static var ABOUT_MENU_LIST:XMLList; + [Bindable] public static var IS_ONLINE:Boolean = false; + [Bindable] public static var USE_SPLASH:Boolean = true; + + //public static var SETTINGS_FILE:String = "settings.xml"; + //public static function get SETTINGS_URL():String {return "data/" + SETTINGS_FILE;} + //public static var settingsXml:XML; + + [Bindable] public static var ABOUT_MENU_TITLE:String = "Flex Resources"; + + [Bindable] public static var SPLASH_URL:String = "data/assets/intro.flv"; + [Bindable] public static var QUICK_START_REMOTE_URL:String = "http://tourdeflex.blogspot.com"; + [Bindable] public static var QUICK_START_LOCAL_URL:String = "data/quickstart.html"; + + public static var OBJECTS_FILE:String = "objects-desktop2.xml"; + public static function get OBJECTS_URL():String {return "data/" + OBJECTS_FILE;} + public static var LOCAL_OBJECTS_ROOT_PATH:String = "objects/"; + + public static var OBJECTS_UPDATER_FILE:String = "objects-desktop2-update.xml"; + public static function get OBJECTS_UPDATER_URL():String {return "http://tourdeflex.adobe.com/download/" + OBJECTS_UPDATER_FILE;} + public static var APP_UPDATER_URL:String = "http://tourdeflex.adobe.com/download/update4.xml"; + + public static var ONLINE_STATUS_URL:String = "http://tourdeflex.adobe.com/ping.html"; + public static var OFFLINE_URL:String = "data/offline.html"; + + private static var BASE_URL:String = "http://tourdeflex.adobe.com/server/"; + [Bindable] public static var DATA_EXCHANGE_URL:String = BASE_URL + "main.php"; + + private static var COMENTS_URL_QUERY_STRING:String = "main.php?Request=GetComments&ObjectId="; + public static var COMMENTS_URL:String = BASE_URL + COMENTS_URL_QUERY_STRING; + + public static var HEADER_GRADIENT_IMAGE:String = "images/header_gradient.png"; + public static var HEADER_IMAGE:String = "images/header_logo.png"; + + public static var TREE_NO_ICON:String = "images/tree_noIcon.png"; + + public function Config() + { + } + + /* + public static function loadSettings():void + { + setLocalization(); + + var loader:URLLoader = new URLLoader(new URLRequest(Config.SETTINGS_URL)); + loader.addEventListener(Event.COMPLETE, settingsXmlLoaded); + + var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor; + var ns:Namespace = appXml.namespace(); + APP_VERSION = appXml.ns::version; + } + */ + + public static function setLocalization():void + { + //var localLanguage:String = Capabilities.languages[0].toString().toLowerCase(); //for 'en-us' + var localLanguage:String = Capabilities.language.toLowerCase(); //for 'en' + trace("LANG=" + localLanguage); + //localLanguage = "jp"; //for testing + //trace(localLanguage); + + if(localLanguage != "en" && localLanguage != "en-us") + { + //Config.QUICK_START_REMOTE_URL = appendLanguage(Config.QUICK_START_REMOTE_URL, localLanguage); + //Config.QUICK_START_LOCAL_URL = appendLanguage(Config.QUICK_START_LOCAL_URL, localLanguage); + + var localizedObjectFile:String = "objects-desktop_" + localLanguage + ".xml"; + var staticObjectFile:File = File.applicationDirectory.resolvePath("data/" + localizedObjectFile); + if(staticObjectFile.exists) + { + OBJECTS_FILE = localizedObjectFile; + Config.OBJECTS_UPDATER_FILE = "objects-desktop-update_" + localLanguage + ".xml"; + //SETTINGS_FILE = "settings_" + localLanguage + ".xml"; + } + } + } + + public static function appendLanguage(oldPath:String, lang:String):String + { + var newPath:String = oldPath; + + var pos:int = oldPath.lastIndexOf("."); + if(pos > 0) + { + var ext:String = oldPath.substring(pos, oldPath.length); + newPath = oldPath.substring(0, pos); + newPath += "_" + lang + ext; + } + + return newPath; + } + + /* + private static function settingsXmlLoaded(event:Event):void + { + var loader:URLLoader = URLLoader(event.target); + settingsXml = new XML(loader.data); + PROGRAM_TITLE = settingsXml.@title; + ABOUT_MENU_LIST = settingsXml.AboutMenu.Item; + ABOUT_MENU_TITLE = settingsXml.AboutMenu.@title; + } + */ + + public static function isAppFirstTimeRun():Boolean + { + var isFirstTime:Boolean = false; + var appFirstTimeRunFile:File = File.applicationStorageDirectory.resolvePath("versions/" + APP_VERSION); + + if(!appFirstTimeRunFile.exists) + { + var fileStream:FileStream = new FileStream(); + fileStream.open(appFirstTimeRunFile, FileMode.WRITE); + fileStream.writeUTFBytes(APP_VERSION); + fileStream.close(); + + isFirstTime = true; + } + + return isFirstTime; + } + + } } \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/Preferences.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/Preferences.as b/TourDeFlex/TourDeFlex/src/Preferences.as index 49c7e35..4144fd5 100644 --- a/TourDeFlex/TourDeFlex/src/Preferences.as +++ b/TourDeFlex/TourDeFlex/src/Preferences.as @@ -16,53 +16,53 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package -{ - import flash.filesystem.File; - import flash.filesystem.FileMode; - import flash.filesystem.FileStream; - - public class Preferences - { - //-------------------------------------------------------------------------- - // Variables - //-------------------------------------------------------------------------- - private static var filePath:String = "preferences.xml"; - [Bindable] public static var preferencesXml:XML = <Preferences />; - - //-------------------------------------------------------------------------- - // Loading/setup - //-------------------------------------------------------------------------- - public function Preferences() - { - - } - - public static function load():void - { - var preferencesFile:File = File.applicationStorageDirectory.resolvePath(filePath); - if(preferencesFile.exists) - { - var fileStream:FileStream = new FileStream(); - fileStream.open(preferencesFile, FileMode.READ); - preferencesXml = XML(fileStream.readUTFBytes(fileStream.bytesAvailable)); - fileStream.close(); - } - } - - //-------------------------------------------------------------------------- - // Saving - //-------------------------------------------------------------------------- - public static function save():void - { - var preferencesFile:File = File.applicationStorageDirectory.resolvePath(filePath); - var fileStream:FileStream = new FileStream(); - fileStream.open(preferencesFile, FileMode.WRITE); - fileStream.writeUTFBytes(preferencesXml.toXMLString()); - fileStream.close(); - } - - //-------------------------------------------------------------------------- - //-------------------------------------------------------------------------- - } +package +{ + import flash.filesystem.File; + import flash.filesystem.FileMode; + import flash.filesystem.FileStream; + + public class Preferences + { + //-------------------------------------------------------------------------- + // Variables + //-------------------------------------------------------------------------- + private static var filePath:String = "preferences.xml"; + [Bindable] public static var preferencesXml:XML = <Preferences />; + + //-------------------------------------------------------------------------- + // Loading/setup + //-------------------------------------------------------------------------- + public function Preferences() + { + + } + + public static function load():void + { + var preferencesFile:File = File.applicationStorageDirectory.resolvePath(filePath); + if(preferencesFile.exists) + { + var fileStream:FileStream = new FileStream(); + fileStream.open(preferencesFile, FileMode.READ); + preferencesXml = XML(fileStream.readUTFBytes(fileStream.bytesAvailable)); + fileStream.close(); + } + } + + //-------------------------------------------------------------------------- + // Saving + //-------------------------------------------------------------------------- + public static function save():void + { + var preferencesFile:File = File.applicationStorageDirectory.resolvePath(filePath); + var fileStream:FileStream = new FileStream(); + fileStream.open(preferencesFile, FileMode.WRITE); + fileStream.writeUTFBytes(preferencesXml.toXMLString()); + fileStream.close(); + } + + //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/TourDeFlex-app.xml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/TourDeFlex-app.xml b/TourDeFlex/TourDeFlex/src/TourDeFlex-app.xml index 3f5594d..102abff 100644 --- a/TourDeFlex/TourDeFlex/src/TourDeFlex-app.xml +++ b/TourDeFlex/TourDeFlex/src/TourDeFlex-app.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,8 +17,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -<application xmlns="http://ns.adobe.com/air/application/2.0"> - +<application xmlns="http://ns.adobe.com/air/application/2.0"> + <!-- Adobe AIR Application Descriptor File Template. Specifies parameters for identifying, installing, and launching AIR applications. @@ -30,128 +30,128 @@ limitations under the License. minimumPatchLevel - The minimum patch level of the AIR runtime required to run the application. Optional. ---> - - <!-- The application identifier string, unique to this application. Required. --> - <id>TourDeFlex</id> - - <!-- Used as the filename for the application. Required. --> - <filename>TourDeFlex</filename> - - <!-- The name that is displayed in the AIR application installer. Optional. --> - <name>TourDeFlex</name> - - - <publisherID>E7BED6E5DDA59983786DD72EBFA46B1598278E07.1</publisherID> - <!-- An application version designator (such as "v1", "2.5", or "Alpha 1"). Required. --> - <version>2.0</version> - - <!-- Description, displayed in the AIR application installer. Optional. --> - <description>Tour de Flex - Adobe Systems, Inc.</description> - - <!-- Copyright information. Optional --> - <!-- <copyright>Copyright 2010, Adobe Systems, Inc.</copyright> --> - - <!-- Settings for the application's initial window. Required. --> - <initialWindow> - <!-- The main SWF or HTML file of the application. Required. --> - <!-- Note: In Flex Builder, the SWF reference is set automatically. --> - <content>[This value will be overwritten by Flex Builder in the output app.xml]</content> - - <!-- The title of the main window. Optional. --> - <!-- <title></title> --> - - <!-- The type of system chrome to use (either "standard" or "none"). Optional. Default standard. --> - <!-- <systemChrome></systemChrome> --> - <systemChrome>none</systemChrome> - - <!-- Whether the window is transparent. Only applicable when systemChrome is false. Optional. Default false. --> - <!-- <transparent></transparent> --> - - <!-- Whether the window is initially visible. Optional. Default false. --> - <!-- <visible></visible> --> - - <!-- Whether the user can minimize the window. Optional. Default true. --> - <!-- <minimizable></minimizable> --> - - <!-- Whether the user can maximize the window. Optional. Default true. --> - <!-- <maximizable></maximizable> --> - - <!-- Whether the user can resize the window. Optional. Default true. --> - <!-- <resizable></resizable> --> - - <!-- The window's initial width. Optional. --> - <!-- <width></width> --> - - <!-- The window's initial height. Optional. --> - <!-- <height></height> --> - - <!-- The window's initial x position. Optional. --> - <!-- <x></x> --> - - <!-- The window's initial y position. Optional. --> - <!-- <y></y> --> - - <!-- The window's minimum size, specified as a width/height pair, such as "400 200". Optional. --> - <!-- <minSize></minSize> --> - - <!-- The window's initial maximum size, specified as a width/height pair, such as "1600 1200". Optional. --> - <!-- <maxSize></maxSize> --> - </initialWindow> - - <!-- The subpath of the standard default installation location to use. Optional. --> - <!-- <installFolder></installFolder> --> - - <!-- The subpath of the Windows Start/Programs menu to use. Optional. --> - <!-- <programMenuFolder></programMenuFolder> --> - +--> + + <!-- The application identifier string, unique to this application. Required. --> + <id>TourDeFlex</id> + + <!-- Used as the filename for the application. Required. --> + <filename>TourDeFlex</filename> + + <!-- The name that is displayed in the AIR application installer. Optional. --> + <name>TourDeFlex</name> + + + <publisherID>E7BED6E5DDA59983786DD72EBFA46B1598278E07.1</publisherID> + <!-- An application version designator (such as "v1", "2.5", or "Alpha 1"). Required. --> + <version>2.0</version> + + <!-- Description, displayed in the AIR application installer. Optional. --> + <description>Tour de Flex - Adobe Systems, Inc.</description> + + <!-- Copyright information. Optional --> + <!-- <copyright>Copyright 2010, Adobe Systems, Inc.</copyright> --> + + <!-- Settings for the application's initial window. Required. --> + <initialWindow> + <!-- The main SWF or HTML file of the application. Required. --> + <!-- Note: In Flex Builder, the SWF reference is set automatically. --> + <content>[This value will be overwritten by Flex Builder in the output app.xml]</content> + + <!-- The title of the main window. Optional. --> + <!-- <title></title> --> + + <!-- The type of system chrome to use (either "standard" or "none"). Optional. Default standard. --> + <!-- <systemChrome></systemChrome> --> + <systemChrome>none</systemChrome> + + <!-- Whether the window is transparent. Only applicable when systemChrome is false. Optional. Default false. --> + <!-- <transparent></transparent> --> + + <!-- Whether the window is initially visible. Optional. Default false. --> + <!-- <visible></visible> --> + + <!-- Whether the user can minimize the window. Optional. Default true. --> + <!-- <minimizable></minimizable> --> + + <!-- Whether the user can maximize the window. Optional. Default true. --> + <!-- <maximizable></maximizable> --> + + <!-- Whether the user can resize the window. Optional. Default true. --> + <!-- <resizable></resizable> --> + + <!-- The window's initial width. Optional. --> + <!-- <width></width> --> + + <!-- The window's initial height. Optional. --> + <!-- <height></height> --> + + <!-- The window's initial x position. Optional. --> + <!-- <x></x> --> + + <!-- The window's initial y position. Optional. --> + <!-- <y></y> --> + + <!-- The window's minimum size, specified as a width/height pair, such as "400 200". Optional. --> + <!-- <minSize></minSize> --> + + <!-- The window's initial maximum size, specified as a width/height pair, such as "1600 1200". Optional. --> + <!-- <maxSize></maxSize> --> + </initialWindow> + + <!-- The subpath of the standard default installation location to use. Optional. --> + <!-- <installFolder></installFolder> --> + + <!-- The subpath of the Windows Start/Programs menu to use. Optional. --> + <!-- <programMenuFolder></programMenuFolder> --> + <!-- The icon the system uses for the application. For at least one resolution, - specify the path to a PNG file included in the AIR package. Optional. --> + specify the path to a PNG file included in the AIR package. Optional. --> <icon> <image16x16>images/icons/tdfx_16.png</image16x16> <image32x32>images/icons/tdfx_32.png</image32x32> <image48x48>images/icons/tdfx_48.png</image48x48> <image128x128>images/icons/tdfx_128.png</image128x128> - </icon> - + </icon> + <!-- Whether the application handles the update when a user double-clicks an update version of the AIR file (true), or the default AIR application installer handles the update (false). - Optional. Default false. --> - <!-- <customUpdateUI></customUpdateUI> --> - + Optional. Default false. --> + <!-- <customUpdateUI></customUpdateUI> --> + <!-- Whether the application can be launched when the user clicks a link in a web browser. - Optional. Default false. --> - <allowBrowserInvocation>true</allowBrowserInvocation> - - <!-- Listing of file types for which the application can register. Optional. --> - <!-- <fileTypes> --> - - <!-- Defines one file type. Optional. --> - <!-- <fileType> --> - - <!-- The name that the system displays for the registered file type. Required. --> - <!-- <name></name> --> - - <!-- The extension to register. Required. --> - <!-- <extension></extension> --> - - <!-- The description of the file type. Optional. --> - <!-- <description></description> --> - - <!-- The MIME type. Optional. --> - <!-- <contentType></contentType> --> - - <!-- The icon to display for the file type. Optional. --> - <!-- - <icon> - <image16x16>images/icons/16x16-Icon.png</image16x16> - <image32x32>images/icons/32x32-Icon.png</image32x32> - <image48x48>images/icons/48x48-Icon.png</image48x48> - <image128x128>images/icons/128x128-Icon.png</image128x128> - </icon> - --> - - <!-- </fileType> --> - <!-- </fileTypes> --> - -</application> + Optional. Default false. --> + <allowBrowserInvocation>true</allowBrowserInvocation> + + <!-- Listing of file types for which the application can register. Optional. --> + <!-- <fileTypes> --> + + <!-- Defines one file type. Optional. --> + <!-- <fileType> --> + + <!-- The name that the system displays for the registered file type. Required. --> + <!-- <name></name> --> + + <!-- The extension to register. Required. --> + <!-- <extension></extension> --> + + <!-- The description of the file type. Optional. --> + <!-- <description></description> --> + + <!-- The MIME type. Optional. --> + <!-- <contentType></contentType> --> + + <!-- The icon to display for the file type. Optional. --> + <!-- + <icon> + <image16x16>images/icons/16x16-Icon.png</image16x16> + <image32x32>images/icons/32x32-Icon.png</image32x32> + <image48x48>images/icons/48x48-Icon.png</image48x48> + <image128x128>images/icons/128x128-Icon.png</image128x128> + </icon> + --> + + <!-- </fileType> --> + <!-- </fileTypes> --> + +</application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/classes/ApplicationUpdaterManager.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/classes/ApplicationUpdaterManager.as b/TourDeFlex/TourDeFlex/src/classes/ApplicationUpdaterManager.as index 4a69b36..20a3b38 100644 --- a/TourDeFlex/TourDeFlex/src/classes/ApplicationUpdaterManager.as +++ b/TourDeFlex/TourDeFlex/src/classes/ApplicationUpdaterManager.as @@ -16,40 +16,40 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package classes -{ - import air.update.ApplicationUpdaterUI; - import air.update.events.UpdateEvent; - - import flash.desktop.NativeApplication; - import flash.events.ErrorEvent; - import flash.events.Event; - - import mx.controls.Alert; - - public class ApplicationUpdaterManager - { - private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI(); - - public function ApplicationUpdaterManager() - { - appUpdater.updateURL = Config.APP_UPDATER_URL; - appUpdater.isCheckForUpdateVisible = false; - //appUpdater.isInstallUpdateVisible = false; - appUpdater.addEventListener(ErrorEvent.ERROR, appUpdater_error); - appUpdater.addEventListener(UpdateEvent.INITIALIZED, appUpdater_update); - appUpdater.initialize(); - } - - private function appUpdater_update(event:UpdateEvent):void - { - appUpdater.checkNow(); - } - - private function appUpdater_error(event:ErrorEvent):void - { - Alert.show(event.toString()); - } - - } +package classes +{ + import air.update.ApplicationUpdaterUI; + import air.update.events.UpdateEvent; + + import flash.desktop.NativeApplication; + import flash.events.ErrorEvent; + import flash.events.Event; + + import mx.controls.Alert; + + public class ApplicationUpdaterManager + { + private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI(); + + public function ApplicationUpdaterManager() + { + appUpdater.updateURL = Config.APP_UPDATER_URL; + appUpdater.isCheckForUpdateVisible = false; + //appUpdater.isInstallUpdateVisible = false; + appUpdater.addEventListener(ErrorEvent.ERROR, appUpdater_error); + appUpdater.addEventListener(UpdateEvent.INITIALIZED, appUpdater_update); + appUpdater.initialize(); + } + + private function appUpdater_update(event:UpdateEvent):void + { + appUpdater.checkNow(); + } + + private function appUpdater_error(event:ErrorEvent):void + { + Alert.show(event.toString()); + } + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/classes/Document.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/classes/Document.as b/TourDeFlex/TourDeFlex/src/classes/Document.as index e029609..909ae65 100644 --- a/TourDeFlex/TourDeFlex/src/classes/Document.as +++ b/TourDeFlex/TourDeFlex/src/classes/Document.as @@ -16,20 +16,20 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package classes -{ - public class Document - { - public var name:String = ""; - public var path:String = ""; - public var openLinksExternal:String = ""; - - public function Document(name:String = "", path:String = "", openLinksExternal:String = "") - { - this.name = name; - this.path = path; - this.openLinksExternal = openLinksExternal; - } - - } +package classes +{ + public class Document + { + public var name:String = ""; + public var path:String = ""; + public var openLinksExternal:String = ""; + + public function Document(name:String = "", path:String = "", openLinksExternal:String = "") + { + this.name = name; + this.path = path; + this.openLinksExternal = openLinksExternal; + } + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/classes/LocalQuickStart.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/classes/LocalQuickStart.as b/TourDeFlex/TourDeFlex/src/classes/LocalQuickStart.as index f3cbdbf..3e44e8b 100644 --- a/TourDeFlex/TourDeFlex/src/classes/LocalQuickStart.as +++ b/TourDeFlex/TourDeFlex/src/classes/LocalQuickStart.as @@ -16,144 +16,144 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package classes -{ - /******************************** - * This class has been deprecated - *********************************/ - - - import flash.events.Event; - import flash.events.IOErrorEvent; - import flash.filesystem.File; - import flash.filesystem.FileMode; - import flash.filesystem.FileStream; - import flash.net.SharedObject; - import flash.net.URLLoader; - import flash.net.URLRequest; - import flash.system.Capabilities; - - public class LocalQuickStart - { - - //-------------------------------------------------------------------------- - // Variables - //-------------------------------------------------------------------------- - public static var url:String = "quickstart.html"; - - private static var cookieName:String = "TourDeFlex"; - private static var onlineVersion:String = ""; - private static var localLanguage:String = "en"; - private static var onlineVersionUrl:String = ""; - - - //-------------------------------------------------------------------------- - // Load/setup - //-------------------------------------------------------------------------- - public function LocalQuickStart() - { - } - - public static function update():void - { - var staticContainerPath:String = "data/"; - var updatableFile:File = File.applicationStorageDirectory.resolvePath(url); - var staticFile:File = File.applicationDirectory.resolvePath(staticContainerPath + url); - - localLanguage = Capabilities.language.toLowerCase(); - //localLanguage = "jp"; - - if(localLanguage != "en") - { - var newUrl:String = Config.appendLanguage(url, localLanguage); - var newStaticFile:File = File.applicationDirectory.resolvePath(staticContainerPath + newUrl); - if(newStaticFile.exists) - staticFile = newStaticFile; - } - - if(Config.isAppFirstTimeRun() || !updatableFile.exists) - staticFile.copyTo(updatableFile, true); - - url = updatableFile.url; - - checkForNewLocalQuickStart(); - } - - //-------------------------------------------------------------------------- - // Helper/shared functions - //-------------------------------------------------------------------------- - private static function checkForNewLocalQuickStart():void - { - var loader:URLLoader = new URLLoader(new URLRequest(Config.QUICK_START_LOCAL_UPDATER_URL)); - loader.addEventListener(Event.COMPLETE, updaterXmlLoaded); - loader.addEventListener(IOErrorEvent.IO_ERROR, updaterXmlLoadedError); - } - - private static function updaterXmlLoadedError(event:IOErrorEvent):void - { - } - - private static function updaterXmlLoaded(event:Event):void - { - var loader:URLLoader = URLLoader(event.target); - var updaterXml:XML = new XML(loader.data); - - var currentVersion:String = "0"; - var cookie:SharedObject = SharedObject.getLocal(cookieName); - if(cookie.data.localQuickStartVersion != null) - currentVersion = cookie.data.localQuickStartVersion; - - onlineVersion = updaterXml.version; - var onlineVersionDescription:String = updaterXml.description; - - if(onlineVersion > currentVersion) - { - onlineVersionUrl = updaterXml.url; - downloadNewVersion(onlineVersionUrl); - if(onlineVersionDescription.length > 0) - { - // Only show notice if a description was provided, otherwise, silent install - //Alert.show(onlineVersionDescription, "Updated to Version " + onlineVersion); - } - } - } - - private static function downloadNewVersion(path:String):void - { - if(localLanguage != "en") - path = Config.appendLanguage(path, localLanguage); - - var loader:URLLoader = new URLLoader(new URLRequest(path)); - loader.addEventListener(Event.COMPLETE, updatedVersionLoaded); - loader.addEventListener(IOErrorEvent.IO_ERROR, updatedVersionLoadingError); - } - - private static function updatedVersionLoadingError(event:IOErrorEvent):void - { - var loader:URLLoader = new URLLoader(new URLRequest(onlineVersionUrl)); - loader.addEventListener(Event.COMPLETE, updatedVersionLoaded); - loader.addEventListener(IOErrorEvent.IO_ERROR, updatedVersionLoadingError); - } - - private static function updatedVersionLoaded(event:Event):void - { - var file:File = File.applicationStorageDirectory; - file = file.resolvePath(url); - if(file.exists) - file.deleteFile(); - - var loader:URLLoader = URLLoader(event.target); - - var fileStream:FileStream = new FileStream(); - fileStream.open(file, FileMode.WRITE); - fileStream.writeUTFBytes(loader.data); - fileStream.close(); - - var cookie:SharedObject = SharedObject.getLocal(cookieName); - cookie.data.localQuickStartVersion = onlineVersion; - cookie.flush(); - } - //-------------------------------------------------------------------------- - //-------------------------------------------------------------------------- - } +package classes +{ + /******************************** + * This class has been deprecated + *********************************/ + + + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.filesystem.File; + import flash.filesystem.FileMode; + import flash.filesystem.FileStream; + import flash.net.SharedObject; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.system.Capabilities; + + public class LocalQuickStart + { + + //-------------------------------------------------------------------------- + // Variables + //-------------------------------------------------------------------------- + public static var url:String = "quickstart.html"; + + private static var cookieName:String = "TourDeFlex"; + private static var onlineVersion:String = ""; + private static var localLanguage:String = "en"; + private static var onlineVersionUrl:String = ""; + + + //-------------------------------------------------------------------------- + // Load/setup + //-------------------------------------------------------------------------- + public function LocalQuickStart() + { + } + + public static function update():void + { + var staticContainerPath:String = "data/"; + var updatableFile:File = File.applicationStorageDirectory.resolvePath(url); + var staticFile:File = File.applicationDirectory.resolvePath(staticContainerPath + url); + + localLanguage = Capabilities.language.toLowerCase(); + //localLanguage = "jp"; + + if(localLanguage != "en") + { + var newUrl:String = Config.appendLanguage(url, localLanguage); + var newStaticFile:File = File.applicationDirectory.resolvePath(staticContainerPath + newUrl); + if(newStaticFile.exists) + staticFile = newStaticFile; + } + + if(Config.isAppFirstTimeRun() || !updatableFile.exists) + staticFile.copyTo(updatableFile, true); + + url = updatableFile.url; + + checkForNewLocalQuickStart(); + } + + //-------------------------------------------------------------------------- + // Helper/shared functions + //-------------------------------------------------------------------------- + private static function checkForNewLocalQuickStart():void + { + var loader:URLLoader = new URLLoader(new URLRequest(Config.QUICK_START_LOCAL_UPDATER_URL)); + loader.addEventListener(Event.COMPLETE, updaterXmlLoaded); + loader.addEventListener(IOErrorEvent.IO_ERROR, updaterXmlLoadedError); + } + + private static function updaterXmlLoadedError(event:IOErrorEvent):void + { + } + + private static function updaterXmlLoaded(event:Event):void + { + var loader:URLLoader = URLLoader(event.target); + var updaterXml:XML = new XML(loader.data); + + var currentVersion:String = "0"; + var cookie:SharedObject = SharedObject.getLocal(cookieName); + if(cookie.data.localQuickStartVersion != null) + currentVersion = cookie.data.localQuickStartVersion; + + onlineVersion = updaterXml.version; + var onlineVersionDescription:String = updaterXml.description; + + if(onlineVersion > currentVersion) + { + onlineVersionUrl = updaterXml.url; + downloadNewVersion(onlineVersionUrl); + if(onlineVersionDescription.length > 0) + { + // Only show notice if a description was provided, otherwise, silent install + //Alert.show(onlineVersionDescription, "Updated to Version " + onlineVersion); + } + } + } + + private static function downloadNewVersion(path:String):void + { + if(localLanguage != "en") + path = Config.appendLanguage(path, localLanguage); + + var loader:URLLoader = new URLLoader(new URLRequest(path)); + loader.addEventListener(Event.COMPLETE, updatedVersionLoaded); + loader.addEventListener(IOErrorEvent.IO_ERROR, updatedVersionLoadingError); + } + + private static function updatedVersionLoadingError(event:IOErrorEvent):void + { + var loader:URLLoader = new URLLoader(new URLRequest(onlineVersionUrl)); + loader.addEventListener(Event.COMPLETE, updatedVersionLoaded); + loader.addEventListener(IOErrorEvent.IO_ERROR, updatedVersionLoadingError); + } + + private static function updatedVersionLoaded(event:Event):void + { + var file:File = File.applicationStorageDirectory; + file = file.resolvePath(url); + if(file.exists) + file.deleteFile(); + + var loader:URLLoader = URLLoader(event.target); + + var fileStream:FileStream = new FileStream(); + fileStream.open(file, FileMode.WRITE); + fileStream.writeUTFBytes(loader.data); + fileStream.close(); + + var cookie:SharedObject = SharedObject.getLocal(cookieName); + cookie.data.localQuickStartVersion = onlineVersion; + cookie.flush(); + } + //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/classes/ObjectData.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/classes/ObjectData.as b/TourDeFlex/TourDeFlex/src/classes/ObjectData.as index 01ef169..e9125fd 100644 --- a/TourDeFlex/TourDeFlex/src/classes/ObjectData.as +++ b/TourDeFlex/TourDeFlex/src/classes/ObjectData.as @@ -16,321 +16,321 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package classes -{ - import flash.desktop.NativeApplication; - import flash.events.Event; - import flash.events.IOErrorEvent; - import flash.filesystem.File; - import flash.filesystem.FileMode; - import flash.filesystem.FileStream; - import flash.net.URLLoader; - import flash.net.URLRequest; - - import mx.collections.ArrayCollection; - import mx.collections.Sort; - import mx.collections.SortField; - import mx.collections.XMLListCollection; - import mx.controls.Alert; - import mx.managers.CursorManager; - - import plugin.Component; //HS - - public class ObjectData - { - //-------------------------------------------------------------------------- - // Variables - //-------------------------------------------------------------------------- - [Bindable] public var topLevelCategoriesXml:XMLList; - [Bindable] public var listXml:XMLListCollection; - [Bindable] public var treeXml:XMLListCollection; - [Bindable] public var featuredTreeXml:XMLListCollection; - [Bindable] public var searchTags:Array; - private var objectXml:XML; - private var selectedTopLevelCategory:String = ""; - private var previousSortType:String; - - //-------------------------------------------------------------------------- - // Loading/setup - //-------------------------------------------------------------------------- - public function ObjectData() - { - loadData(); - } - - public function loadData():void - { - var objectsUrl:String = Config.OBJECTS_URL; - trace(objectsUrl); - var updatableObjectFile:File = File.applicationStorageDirectory.resolvePath(Config.OBJECTS_FILE); - var staticObjectFile:File = File.applicationDirectory.resolvePath(Config.OBJECTS_URL); - - if(Config.isAppFirstTimeRun() || !updatableObjectFile.exists) - staticObjectFile.copyTo(updatableObjectFile, true); - - var loader:URLLoader = new URLLoader(new URLRequest("file://" + updatableObjectFile.nativePath)); - loader.addEventListener(Event.COMPLETE, objectsXmlLoaded); - } - - private function objectsXmlLoaded(event:Event):void - { - trace("OBJECTS LOADED"); - var loader:URLLoader = URLLoader(event.target); - objectXml = new XML(loader.data); - - loadSettings(); - loadCategoriesAndObjects() - checkForNewObjectXml(); - } - - private function loadCategoriesAndObjects():void - { - Config.OBJECTS_FILE_VERSION = objectXml.@version; - Config.OBJECTS_TOTAL = XMLList(objectXml..Object).length(); - - var searchTagsLabels:Array = String(objectXml.@searchTags).split(","); - var searchTagsTotals:Array = String(objectXml.@searchTagsTotals).split(","); - var searchTagsCombined:Array = new Array(); - - for(var i:int=0; i<searchTagsLabels.length; i++) - searchTagsCombined.push([searchTagsLabels[i], searchTagsTotals[i]]); - - searchTags = searchTagsCombined; - - topLevelCategoriesXml = new XMLList(objectXml.children().@name); - selectedTopLevelCategory = topLevelCategoriesXml[0]; - filterTopLevelCategory(selectedTopLevelCategory); - } - - //-------------------------------------------------------------------------- - // Filtering - //-------------------------------------------------------------------------- - public function filterTopLevelCategory(category:String):void - { - selectedTopLevelCategory = category; - listXml = new XMLListCollection(objectXml.Category.(@name == category)..Object); - //treeXml = new XMLListCollection(XMLList(objectXml.Category.(@name == category))); - treeXml = new XMLListCollection(XMLList(objectXml.Category)); - } - - public function filterList(filterText:String, onlyTags:Boolean = false):XMLList // HS - { - filterText = filterText.toLowerCase(); - var filterTextTerms:Array = filterText.split(" "); - var filteredList:XMLList = new XMLList(); - - //for each(var objectItem:XML in objectXml.Category.(@name == selectedTopLevelCategory)..Object) - //for each(var objectItem:XML in objectXml..Object) - - var objectsToSearch:XML = objectXml.copy(); - delete objectsToSearch.Category.(@name == "Featured").*; - - for each(var objectItem:XML in objectsToSearch..Object) - { - var name:String = objectItem.@name.toLowerCase(); - var tags:String = objectItem.@tags.toLowerCase(); - var author:String = objectItem.@author.toLowerCase(); - - for each(var term:String in filterTextTerms) - { - var found:Boolean = false; - if(onlyTags) - { - if(tags.indexOf(term) != -1) - found = true; - } - else - { - if(name.indexOf(term) != -1 || author.indexOf(term) != -1 || tags.indexOf(term) != -1) - found = true; - } - - if(found) - { - filteredList += objectItem; - break; - } - } - } - - listXml = new XMLListCollection(filteredList); - sort(previousSortType); - return filteredList; //HS - } - - public function sort(sortType:String = ObjectListSortTypes.ALPHABETICAL):void - { - previousSortType = sortType; - var sortField:String = "@name"; - var descending:Boolean = false; - var numeric:Boolean = false; - - switch(sortType) - { - case ObjectListSortTypes.ALPHABETICAL: - sortField = "@name"; - break; - case ObjectListSortTypes.MOST_RECENT: - sortField = "@dateAdded"; - descending = true; - break; - case ObjectListSortTypes.MOST_POPULAR: - sortField = "@viewCount"; - descending = true; - numeric = true; - break; - } - - var sort:Sort = new Sort(); - sort.fields = [new SortField(sortField, true, descending, numeric)]; - listXml.sort = sort; - listXml.refresh(); - } - - //-------------------------------------------------------------------------- - // Settings / localization - //-------------------------------------------------------------------------- - private function loadSettings():void - { - Config.PROGRAM_TITLE = objectXml.Settings.@title; - Config.ABOUT_MENU_LIST = objectXml.Settings.AboutMenu.Item; - Config.ABOUT_MENU_TITLE = objectXml.Settings.AboutMenu.@title; - - var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor; - var ns:Namespace = appXml.namespace(); - Config.APP_VERSION = appXml.ns::version; - } - - //-------------------------------------------------------------------------- - // Checking for new objects.xml and updating it - //-------------------------------------------------------------------------- - private function checkForNewObjectXml():void - { - var loader:URLLoader = new URLLoader(new URLRequest(Config.OBJECTS_UPDATER_URL)); - loader.addEventListener(Event.COMPLETE, objectsUpdaterXmlLoaded); - loader.addEventListener(IOErrorEvent.IO_ERROR, objectsUpdaterXmlLoadedError); - } - - private function objectsUpdaterXmlLoadedError(event:IOErrorEvent):void - { - } - - private function objectsUpdaterXmlLoaded(event:Event):void - { - var loader:URLLoader = URLLoader(event.target); - var objectsUpdaterXml:XML = new XML(loader.data); - - var currentVersion:String = objectXml.@version; - var onlineVersion:String = objectsUpdaterXml.version; - var onlineVersionDescription:String = objectsUpdaterXml.description; - - if(onlineVersion > currentVersion) { - downloadNewObjectXml(objectsUpdaterXml.url); - if(onlineVersionDescription.length > 0) { - // Only show notice if a description was provided, otherwise, silent install - var myPattern:RegExp = /\r\n/g; - onlineVersionDescription = onlineVersionDescription.replace(myPattern,"\n"); - Alert.show(onlineVersionDescription, "Samples Database Updated to Version " + onlineVersion); - } - } - } - - private function downloadNewObjectXml(path:String):void - { - var loader:URLLoader = new URLLoader(new URLRequest(path)); - loader.addEventListener(Event.COMPLETE, updatedObjectsXmlLoaded); - CursorManager.setBusyCursor(); - } - - public function updatedObjectsXmlLoaded(event:Event):void - { - var file:File = File.applicationStorageDirectory; - file = file.resolvePath(Config.OBJECTS_FILE); - if(file.exists) - file.deleteFile(); - - var loader:URLLoader = URLLoader(event.target); - - objectXml = new XML(loader.data); - loadSettings(); - loadCategoriesAndObjects(); - - var fileStream:FileStream = new FileStream(); - fileStream.open(file, FileMode.WRITE); - fileStream.writeUTFBytes(objectXml.toXMLString()); - fileStream.close(); - CursorManager.removeBusyCursor(); - - } - //-------------------------------------------------------------------------- - //-------------------------------------------------------------------------- - //------------------------------------------------------------------------ - // Convert the XML objects into Component objects so they map to the remote - // java object for easier processing by plug-in. HS - //------------------------------------------------------------------------ - private function createComponentsFromXML(xmlList:XMLList):ArrayCollection - { - var objectsAsComponents:ArrayCollection = new ArrayCollection(); - for each(var object:XML in xmlList) - { - trace("Component name " + object.attribute("name") + " id " + object.attribute("id")); - var c:Component = new Component(); - c.id = object.attribute("id"); - c.name = object.attribute("name"); - c.author = object.attribute("author"); - c.description = object.attribute("description"); - objectsAsComponents.addItem(c); - } - return objectsAsComponents; - } - //----------------------------------------------------- - // Find the matching components based on the search string - // passed from the Eclipse plug-in and add them to an Array - // Collection as component objects for return via Merapi. HS - //----------------------------------------------------- - public function getFilteredComponents(filter:String):ArrayCollection - { - // First setup the XML list based on the search string from the plugin - var resultList:XMLList = filterList(filter); - var objectsAsComponents:ArrayCollection = createComponentsFromXML(resultList); - return objectsAsComponents; - } - //----------------------------------------------------- - // Fetch the list of featured components and convert them - // to component objects and add them to the array collection - // that will be returned to the eclipse plug-in. HS - //----------------------------------------------------- - public function getFeaturedComponents():ArrayCollection - { - // First setup the XML list based on the search string from the plugin - // Featured Components are the first child in the object XML... - - var featXml:XML = objectXml.children()[0]; - trace("Top level categories: " + featXml + objectXml.contains("Category")); - var featObjsList:XMLList = featXml.descendants("Object") - var objectsAsComponents:ArrayCollection = createComponentsFromXML(featObjsList); - return objectsAsComponents; - - } - //----------------------------------------------------- - // Fetch the XML object for the id that was passed in - // from the Eclipse plug-in so we can navigate to that - // object for display. HS - //----------------------------------------------------- - public function getXMLForObjectId(matchId:String):XML { - var objects:XMLList = XMLList(objectXml..Object); - for each(var objectItem:XML in objects) { - var id:String = objectItem.@id.toLowerCase(); - var name:String = objectItem.@name.toLowerCase(); - var tags:String = objectItem.@tags.toLowerCase(); - var author:String = objectItem.@author.toLowerCase(); - if (id == matchId) { - trace("NAME: " + name + " id " + id); - return objectItem; - } - } - return null; - } - - } +package classes +{ + import flash.desktop.NativeApplication; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.filesystem.File; + import flash.filesystem.FileMode; + import flash.filesystem.FileStream; + import flash.net.URLLoader; + import flash.net.URLRequest; + + import mx.collections.ArrayCollection; + import mx.collections.Sort; + import mx.collections.SortField; + import mx.collections.XMLListCollection; + import mx.controls.Alert; + import mx.managers.CursorManager; + + import plugin.Component; //HS + + public class ObjectData + { + //-------------------------------------------------------------------------- + // Variables + //-------------------------------------------------------------------------- + [Bindable] public var topLevelCategoriesXml:XMLList; + [Bindable] public var listXml:XMLListCollection; + [Bindable] public var treeXml:XMLListCollection; + [Bindable] public var featuredTreeXml:XMLListCollection; + [Bindable] public var searchTags:Array; + private var objectXml:XML; + private var selectedTopLevelCategory:String = ""; + private var previousSortType:String; + + //-------------------------------------------------------------------------- + // Loading/setup + //-------------------------------------------------------------------------- + public function ObjectData() + { + loadData(); + } + + public function loadData():void + { + var objectsUrl:String = Config.OBJECTS_URL; + trace(objectsUrl); + var updatableObjectFile:File = File.applicationStorageDirectory.resolvePath(Config.OBJECTS_FILE); + var staticObjectFile:File = File.applicationDirectory.resolvePath(Config.OBJECTS_URL); + + if(Config.isAppFirstTimeRun() || !updatableObjectFile.exists) + staticObjectFile.copyTo(updatableObjectFile, true); + + var loader:URLLoader = new URLLoader(new URLRequest("file://" + updatableObjectFile.nativePath)); + loader.addEventListener(Event.COMPLETE, objectsXmlLoaded); + } + + private function objectsXmlLoaded(event:Event):void + { + trace("OBJECTS LOADED"); + var loader:URLLoader = URLLoader(event.target); + objectXml = new XML(loader.data); + + loadSettings(); + loadCategoriesAndObjects() + checkForNewObjectXml(); + } + + private function loadCategoriesAndObjects():void + { + Config.OBJECTS_FILE_VERSION = objectXml.@version; + Config.OBJECTS_TOTAL = XMLList(objectXml..Object).length(); + + var searchTagsLabels:Array = String(objectXml.@searchTags).split(","); + var searchTagsTotals:Array = String(objectXml.@searchTagsTotals).split(","); + var searchTagsCombined:Array = new Array(); + + for(var i:int=0; i<searchTagsLabels.length; i++) + searchTagsCombined.push([searchTagsLabels[i], searchTagsTotals[i]]); + + searchTags = searchTagsCombined; + + topLevelCategoriesXml = new XMLList(objectXml.children().@name); + selectedTopLevelCategory = topLevelCategoriesXml[0]; + filterTopLevelCategory(selectedTopLevelCategory); + } + + //-------------------------------------------------------------------------- + // Filtering + //-------------------------------------------------------------------------- + public function filterTopLevelCategory(category:String):void + { + selectedTopLevelCategory = category; + listXml = new XMLListCollection(objectXml.Category.(@name == category)..Object); + //treeXml = new XMLListCollection(XMLList(objectXml.Category.(@name == category))); + treeXml = new XMLListCollection(XMLList(objectXml.Category)); + } + + public function filterList(filterText:String, onlyTags:Boolean = false):XMLList // HS + { + filterText = filterText.toLowerCase(); + var filterTextTerms:Array = filterText.split(" "); + var filteredList:XMLList = new XMLList(); + + //for each(var objectItem:XML in objectXml.Category.(@name == selectedTopLevelCategory)..Object) + //for each(var objectItem:XML in objectXml..Object) + + var objectsToSearch:XML = objectXml.copy(); + delete objectsToSearch.Category.(@name == "Featured").*; + + for each(var objectItem:XML in objectsToSearch..Object) + { + var name:String = objectItem.@name.toLowerCase(); + var tags:String = objectItem.@tags.toLowerCase(); + var author:String = objectItem.@author.toLowerCase(); + + for each(var term:String in filterTextTerms) + { + var found:Boolean = false; + if(onlyTags) + { + if(tags.indexOf(term) != -1) + found = true; + } + else + { + if(name.indexOf(term) != -1 || author.indexOf(term) != -1 || tags.indexOf(term) != -1) + found = true; + } + + if(found) + { + filteredList += objectItem; + break; + } + } + } + + listXml = new XMLListCollection(filteredList); + sort(previousSortType); + return filteredList; //HS + } + + public function sort(sortType:String = ObjectListSortTypes.ALPHABETICAL):void + { + previousSortType = sortType; + var sortField:String = "@name"; + var descending:Boolean = false; + var numeric:Boolean = false; + + switch(sortType) + { + case ObjectListSortTypes.ALPHABETICAL: + sortField = "@name"; + break; + case ObjectListSortTypes.MOST_RECENT: + sortField = "@dateAdded"; + descending = true; + break; + case ObjectListSortTypes.MOST_POPULAR: + sortField = "@viewCount"; + descending = true; + numeric = true; + break; + } + + var sort:Sort = new Sort(); + sort.fields = [new SortField(sortField, true, descending, numeric)]; + listXml.sort = sort; + listXml.refresh(); + } + + //-------------------------------------------------------------------------- + // Settings / localization + //-------------------------------------------------------------------------- + private function loadSettings():void + { + Config.PROGRAM_TITLE = objectXml.Settings.@title; + Config.ABOUT_MENU_LIST = objectXml.Settings.AboutMenu.Item; + Config.ABOUT_MENU_TITLE = objectXml.Settings.AboutMenu.@title; + + var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor; + var ns:Namespace = appXml.namespace(); + Config.APP_VERSION = appXml.ns::version; + } + + //-------------------------------------------------------------------------- + // Checking for new objects.xml and updating it + //-------------------------------------------------------------------------- + private function checkForNewObjectXml():void + { + var loader:URLLoader = new URLLoader(new URLRequest(Config.OBJECTS_UPDATER_URL)); + loader.addEventListener(Event.COMPLETE, objectsUpdaterXmlLoaded); + loader.addEventListener(IOErrorEvent.IO_ERROR, objectsUpdaterXmlLoadedError); + } + + private function objectsUpdaterXmlLoadedError(event:IOErrorEvent):void + { + } + + private function objectsUpdaterXmlLoaded(event:Event):void + { + var loader:URLLoader = URLLoader(event.target); + var objectsUpdaterXml:XML = new XML(loader.data); + + var currentVersion:String = objectXml.@version; + var onlineVersion:String = objectsUpdaterXml.version; + var onlineVersionDescription:String = objectsUpdaterXml.description; + + if(onlineVersion > currentVersion) { + downloadNewObjectXml(objectsUpdaterXml.url); + if(onlineVersionDescription.length > 0) { + // Only show notice if a description was provided, otherwise, silent install + var myPattern:RegExp = /\r\n/g; + onlineVersionDescription = onlineVersionDescription.replace(myPattern,"\n"); + Alert.show(onlineVersionDescription, "Samples Database Updated to Version " + onlineVersion); + } + } + } + + private function downloadNewObjectXml(path:String):void + { + var loader:URLLoader = new URLLoader(new URLRequest(path)); + loader.addEventListener(Event.COMPLETE, updatedObjectsXmlLoaded); + CursorManager.setBusyCursor(); + } + + public function updatedObjectsXmlLoaded(event:Event):void + { + var file:File = File.applicationStorageDirectory; + file = file.resolvePath(Config.OBJECTS_FILE); + if(file.exists) + file.deleteFile(); + + var loader:URLLoader = URLLoader(event.target); + + objectXml = new XML(loader.data); + loadSettings(); + loadCategoriesAndObjects(); + + var fileStream:FileStream = new FileStream(); + fileStream.open(file, FileMode.WRITE); + fileStream.writeUTFBytes(objectXml.toXMLString()); + fileStream.close(); + CursorManager.removeBusyCursor(); + + } + //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + //------------------------------------------------------------------------ + // Convert the XML objects into Component objects so they map to the remote + // java object for easier processing by plug-in. HS + //------------------------------------------------------------------------ + private function createComponentsFromXML(xmlList:XMLList):ArrayCollection + { + var objectsAsComponents:ArrayCollection = new ArrayCollection(); + for each(var object:XML in xmlList) + { + trace("Component name " + object.attribute("name") + " id " + object.attribute("id")); + var c:Component = new Component(); + c.id = object.attribute("id"); + c.name = object.attribute("name"); + c.author = object.attribute("author"); + c.description = object.attribute("description"); + objectsAsComponents.addItem(c); + } + return objectsAsComponents; + } + //----------------------------------------------------- + // Find the matching components based on the search string + // passed from the Eclipse plug-in and add them to an Array + // Collection as component objects for return via Merapi. HS + //----------------------------------------------------- + public function getFilteredComponents(filter:String):ArrayCollection + { + // First setup the XML list based on the search string from the plugin + var resultList:XMLList = filterList(filter); + var objectsAsComponents:ArrayCollection = createComponentsFromXML(resultList); + return objectsAsComponents; + } + //----------------------------------------------------- + // Fetch the list of featured components and convert them + // to component objects and add them to the array collection + // that will be returned to the eclipse plug-in. HS + //----------------------------------------------------- + public function getFeaturedComponents():ArrayCollection + { + // First setup the XML list based on the search string from the plugin + // Featured Components are the first child in the object XML... + + var featXml:XML = objectXml.children()[0]; + trace("Top level categories: " + featXml + objectXml.contains("Category")); + var featObjsList:XMLList = featXml.descendants("Object") + var objectsAsComponents:ArrayCollection = createComponentsFromXML(featObjsList); + return objectsAsComponents; + + } + //----------------------------------------------------- + // Fetch the XML object for the id that was passed in + // from the Eclipse plug-in so we can navigate to that + // object for display. HS + //----------------------------------------------------- + public function getXMLForObjectId(matchId:String):XML { + var objects:XMLList = XMLList(objectXml..Object); + for each(var objectItem:XML in objects) { + var id:String = objectItem.@id.toLowerCase(); + var name:String = objectItem.@name.toLowerCase(); + var tags:String = objectItem.@tags.toLowerCase(); + var author:String = objectItem.@author.toLowerCase(); + if (id == matchId) { + trace("NAME: " + name + " id " + id); + return objectItem; + } + } + return null; + } + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/classes/ObjectListSortTypes.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/classes/ObjectListSortTypes.as b/TourDeFlex/TourDeFlex/src/classes/ObjectListSortTypes.as index 166cbd4..6466fab 100644 --- a/TourDeFlex/TourDeFlex/src/classes/ObjectListSortTypes.as +++ b/TourDeFlex/TourDeFlex/src/classes/ObjectListSortTypes.as @@ -16,23 +16,23 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package classes -{ - import mx.collections.ArrayCollection; - - public final class ObjectListSortTypes - { - - public static const ALPHABETICAL:String = "Alphabetical"; - public static const MOST_RECENT:String = "Most Recent"; - public static const MOST_POPULAR:String = "Most Popular"; - - [Bindable] - public static var ObjectListSortTypeArray:Array = [ALPHABETICAL, MOST_RECENT, MOST_POPULAR]; - - public function ObjectListSortTypes() - { - } - - } +package classes +{ + import mx.collections.ArrayCollection; + + public final class ObjectListSortTypes + { + + public static const ALPHABETICAL:String = "Alphabetical"; + public static const MOST_RECENT:String = "Most Recent"; + public static const MOST_POPULAR:String = "Most Popular"; + + [Bindable] + public static var ObjectListSortTypeArray:Array = [ALPHABETICAL, MOST_RECENT, MOST_POPULAR]; + + public function ObjectListSortTypes() + { + } + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/classes/ObjectTreeDataDescriptor.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/classes/ObjectTreeDataDescriptor.as b/TourDeFlex/TourDeFlex/src/classes/ObjectTreeDataDescriptor.as index 17394f2..7afbafd 100644 --- a/TourDeFlex/TourDeFlex/src/classes/ObjectTreeDataDescriptor.as +++ b/TourDeFlex/TourDeFlex/src/classes/ObjectTreeDataDescriptor.as @@ -16,176 +16,176 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package classes -{ - import mx.collections.ArrayCollection; - import mx.collections.CursorBookmark; - import mx.collections.ICollectionView; - import mx.collections.IViewCursor; - import mx.collections.XMLListCollection; - import mx.controls.treeClasses.ITreeDataDescriptor; - import mx.events.CollectionEvent; - import mx.events.CollectionEventKind; - - public class ObjectTreeDataDescriptor implements ITreeDataDescriptor - { - public function ObjectTreeDataDescriptor() - { - } - - public function getChildren(node:Object, model:Object=null):ICollectionView - { - try - { - return new XMLListCollection(XMLList(node).children()); - } - catch (e:Error) - { - trace("[Descriptor] exception checking for getChildren:" + e.toString()); - } - return null; - } - - // The isBranch method simply returns true if the node is an - // Object with a children field. - // It does not support empty branches, but does support null children - // fields. - public function isBranch(node:Object, model:Object=null):Boolean - { - try - { - if(node is Object) - { - if(node.children != null && XML(node).name().toString() != "Object") - return true; - } - } - catch (e:Error) - { - trace("[Descriptor] exception checking for isBranch"); - } - - return false; - } - - // The hasChildren method Returns true if the - // node actually has children. - public function hasChildren(node:Object, model:Object=null):Boolean - { - if(node == null) - return false; - - var children:ICollectionView = getChildren(node, model); - - try - { - if(children.length > 0) - return true; - } - catch(e:Error) - { - trace("hasChildren: " + e.toString()); - } - - return false; - } - - // The getData method simply returns the node as an Object. - public function getData(node:Object, model:Object=null):Object - { - try - { - return node; - } - catch (e:Error) - { - trace("getData: " + e.toString()); - } - - return null; - } - - // The addChildAt method does the following: - // If the parent parameter is null or undefined, inserts - // the child parameter as the first child of the model parameter. - // If the parent parameter is an Object and has a children field, - // adds the child parameter to it at the index parameter location. - // It does not add a child to a terminal node if it does not have - // a children field. - public function addChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean - { - var event:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); - event.kind = CollectionEventKind.ADD; - event.items = [child]; - event.location = index; - - if (!parent) - { - var iterator:IViewCursor = model.createCursor(); - iterator.seek(CursorBookmark.FIRST, index); - iterator.insert(child); - } - else if (parent is Object) - { - if (parent.children != null) - { - if(parent.children is ArrayCollection) - { - parent.children.addItemAt(child, index); - if (model) - { - model.dispatchEvent(event); - model.itemUpdated(parent); - } - return true; - } - else - { - parent.children.splice(index, 0, child); - if(model) - model.dispatchEvent(event); - return true; - } - } - } - return false; - } - - // The removeChildAt method does the following: - // If the parent parameter is null or undefined, - // removes the child at the specified index - // in the model. - // If the parent parameter is an Object and has a children field, - // removes the child at the index parameter location in the parent. - public function removeChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean - { - var event:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); - event.kind = CollectionEventKind.REMOVE; - event.items = [child]; - event.location = index; - - //handle top level where there is no parent - if (!parent) - { - var iterator:IViewCursor = model.createCursor(); - iterator.seek(CursorBookmark.FIRST, index); - iterator.remove(); - if (model) - model.dispatchEvent(event); - return true; - } - else if (parent is Object) - { - if (parent.children != undefined) - { - parent.children.splice(index, 1); - if(model) - model.dispatchEvent(event); - return true; - } - } - return false; - } - - } +package classes +{ + import mx.collections.ArrayCollection; + import mx.collections.CursorBookmark; + import mx.collections.ICollectionView; + import mx.collections.IViewCursor; + import mx.collections.XMLListCollection; + import mx.controls.treeClasses.ITreeDataDescriptor; + import mx.events.CollectionEvent; + import mx.events.CollectionEventKind; + + public class ObjectTreeDataDescriptor implements ITreeDataDescriptor + { + public function ObjectTreeDataDescriptor() + { + } + + public function getChildren(node:Object, model:Object=null):ICollectionView + { + try + { + return new XMLListCollection(XMLList(node).children()); + } + catch (e:Error) + { + trace("[Descriptor] exception checking for getChildren:" + e.toString()); + } + return null; + } + + // The isBranch method simply returns true if the node is an + // Object with a children field. + // It does not support empty branches, but does support null children + // fields. + public function isBranch(node:Object, model:Object=null):Boolean + { + try + { + if(node is Object) + { + if(node.children != null && XML(node).name().toString() != "Object") + return true; + } + } + catch (e:Error) + { + trace("[Descriptor] exception checking for isBranch"); + } + + return false; + } + + // The hasChildren method Returns true if the + // node actually has children. + public function hasChildren(node:Object, model:Object=null):Boolean + { + if(node == null) + return false; + + var children:ICollectionView = getChildren(node, model); + + try + { + if(children.length > 0) + return true; + } + catch(e:Error) + { + trace("hasChildren: " + e.toString()); + } + + return false; + } + + // The getData method simply returns the node as an Object. + public function getData(node:Object, model:Object=null):Object + { + try + { + return node; + } + catch (e:Error) + { + trace("getData: " + e.toString()); + } + + return null; + } + + // The addChildAt method does the following: + // If the parent parameter is null or undefined, inserts + // the child parameter as the first child of the model parameter. + // If the parent parameter is an Object and has a children field, + // adds the child parameter to it at the index parameter location. + // It does not add a child to a terminal node if it does not have + // a children field. + public function addChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean + { + var event:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); + event.kind = CollectionEventKind.ADD; + event.items = [child]; + event.location = index; + + if (!parent) + { + var iterator:IViewCursor = model.createCursor(); + iterator.seek(CursorBookmark.FIRST, index); + iterator.insert(child); + } + else if (parent is Object) + { + if (parent.children != null) + { + if(parent.children is ArrayCollection) + { + parent.children.addItemAt(child, index); + if (model) + { + model.dispatchEvent(event); + model.itemUpdated(parent); + } + return true; + } + else + { + parent.children.splice(index, 0, child); + if(model) + model.dispatchEvent(event); + return true; + } + } + } + return false; + } + + // The removeChildAt method does the following: + // If the parent parameter is null or undefined, + // removes the child at the specified index + // in the model. + // If the parent parameter is an Object and has a children field, + // removes the child at the index parameter location in the parent. + public function removeChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean + { + var event:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); + event.kind = CollectionEventKind.REMOVE; + event.items = [child]; + event.location = index; + + //handle top level where there is no parent + if (!parent) + { + var iterator:IViewCursor = model.createCursor(); + iterator.seek(CursorBookmark.FIRST, index); + iterator.remove(); + if (model) + model.dispatchEvent(event); + return true; + } + else if (parent is Object) + { + if (parent.children != undefined) + { + parent.children.splice(index, 1); + if(model) + model.dispatchEvent(event); + return true; + } + } + return false; + } + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/classes/ObjectTreeItemRenderer.as ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/classes/ObjectTreeItemRenderer.as b/TourDeFlex/TourDeFlex/src/classes/ObjectTreeItemRenderer.as index 4133b00..e58fc5c 100644 --- a/TourDeFlex/TourDeFlex/src/classes/ObjectTreeItemRenderer.as +++ b/TourDeFlex/TourDeFlex/src/classes/ObjectTreeItemRenderer.as @@ -16,79 +16,79 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package classes -{ - import mx.controls.Image; - import mx.controls.treeClasses.TreeItemRenderer; - import mx.controls.treeClasses.TreeListData; - - public class ObjectTreeItemRenderer extends TreeItemRenderer - { - protected var iconImage:Image; - private var imageWidth:Number = 18; - private var imageHeight:Number = 18; - private var imageToLabelMargin:Number = 2; - - public function ObjectTreeItemRenderer() - { - super(); - } - - override protected function createChildren():void - { - iconImage = new Image(); - iconImage.width = imageWidth; - iconImage.height = imageHeight; - addChild(iconImage); - - super.createChildren(); - } - - override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void - { - super.updateDisplayList(unscaledWidth, unscaledHeight); - if(super.data) - { - if(!TreeListData(super.listData).hasChildren) - { - iconImage.x = super.label.x - imageWidth - imageToLabelMargin; - - var tmp:XMLList = new XMLList(TreeListData(super.listData).item); - var iconPath:String = tmp.@iconPath.toString(); - if(tmp.@localIconPath.toString().length > 0) - iconPath = tmp.@localIconPath; - - if(iconPath.length > 0) - { - if(hasFullPath(iconPath)) { - if (Config.IS_ONLINE) { - iconImage.source = iconPath; - } else { - iconImage.source = Config.TREE_NO_ICON; - } - } - else - iconImage.source = Config.LOCAL_OBJECTS_ROOT_PATH + iconPath; - } - else - { - iconImage.source = Config.TREE_NO_ICON; - } - } - else - { - iconImage.source = null; - } - } - } - - private function hasFullPath(path:String):Boolean - { - if(path.indexOf("//") >= 0 || path.indexOf(":") >= 0) - return true; - else - return false; - } - - } +package classes +{ + import mx.controls.Image; + import mx.controls.treeClasses.TreeItemRenderer; + import mx.controls.treeClasses.TreeListData; + + public class ObjectTreeItemRenderer extends TreeItemRenderer + { + protected var iconImage:Image; + private var imageWidth:Number = 18; + private var imageHeight:Number = 18; + private var imageToLabelMargin:Number = 2; + + public function ObjectTreeItemRenderer() + { + super(); + } + + override protected function createChildren():void + { + iconImage = new Image(); + iconImage.width = imageWidth; + iconImage.height = imageHeight; + addChild(iconImage); + + super.createChildren(); + } + + override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void + { + super.updateDisplayList(unscaledWidth, unscaledHeight); + if(super.data) + { + if(!TreeListData(super.listData).hasChildren) + { + iconImage.x = super.label.x - imageWidth - imageToLabelMargin; + + var tmp:XMLList = new XMLList(TreeListData(super.listData).item); + var iconPath:String = tmp.@iconPath.toString(); + if(tmp.@localIconPath.toString().length > 0) + iconPath = tmp.@localIconPath; + + if(iconPath.length > 0) + { + if(hasFullPath(iconPath)) { + if (Config.IS_ONLINE) { + iconImage.source = iconPath; + } else { + iconImage.source = Config.TREE_NO_ICON; + } + } + else + iconImage.source = Config.LOCAL_OBJECTS_ROOT_PATH + iconPath; + } + else + { + iconImage.source = Config.TREE_NO_ICON; + } + } + else + { + iconImage.source = null; + } + } + } + + private function hasFullPath(path:String):Boolean + { + if(path.indexOf("//") >= 0 || path.indexOf(":") >= 0) + return true; + else + return false; + } + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/components/AboutWindow.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/components/AboutWindow.mxml b/TourDeFlex/TourDeFlex/src/components/AboutWindow.mxml index 02293a2..da94159 100644 --- a/TourDeFlex/TourDeFlex/src/components/AboutWindow.mxml +++ b/TourDeFlex/TourDeFlex/src/components/AboutWindow.mxml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,41 +17,41 @@ limitations under the License. --> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="500" height="430" horizontalScrollPolicy="off" verticalScrollPolicy="off" click="closeAbout()"> - - <mx:Script> - <![CDATA[ - import mx.managers.PopUpManager; - - public var isOpen:Boolean = false; - - public function set url(value:String):void - { - html_view.htmlLoader.navigateInSystemBrowser = true; - html_view.location = value; - } - - public function closeAbout():void { - isOpen = false; - parentApplication.setFocus(); - PopUpManager.removePopUp(this) - } - - ]]> - </mx:Script> - - <mx:Parallel id="aboutEffect"> - <mx:Fade alphaFrom="0" alphaTo="1" duration="300"/> - <mx:Blur blurXFrom="300" blurXTo="0" duration="700"/> - </mx:Parallel> - - <mx:Parallel id="shadowEffect"> - <mx:Fade duration="1000"/> - <mx:Blur blurXFrom="0" blurYFrom="0" blurXTo="20" blurYTo="20" duration="500"/> - <mx:Fade duration="1000"/> - </mx:Parallel> - - <mx:Canvas x="15" y="15" backgroundColor="black" backgroundAlpha="0.5" width="434" height="368" addedEffect="shadowEffect"/> - <mx:HTML x="0" y="0" id="html_view" width="439" height="368" addedEffect="aboutEffect" verticalScrollPolicy="off" horizontalScrollPolicy="off" /> - -</mx:Canvas> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="500" height="430" horizontalScrollPolicy="off" verticalScrollPolicy="off" click="closeAbout()"> + + <mx:Script> + <![CDATA[ + import mx.managers.PopUpManager; + + public var isOpen:Boolean = false; + + public function set url(value:String):void + { + html_view.htmlLoader.navigateInSystemBrowser = true; + html_view.location = value; + } + + public function closeAbout():void { + isOpen = false; + parentApplication.setFocus(); + PopUpManager.removePopUp(this) + } + + ]]> + </mx:Script> + + <mx:Parallel id="aboutEffect"> + <mx:Fade alphaFrom="0" alphaTo="1" duration="300"/> + <mx:Blur blurXFrom="300" blurXTo="0" duration="700"/> + </mx:Parallel> + + <mx:Parallel id="shadowEffect"> + <mx:Fade duration="1000"/> + <mx:Blur blurXFrom="0" blurYFrom="0" blurXTo="20" blurYTo="20" duration="500"/> + <mx:Fade duration="1000"/> + </mx:Parallel> + + <mx:Canvas x="15" y="15" backgroundColor="black" backgroundAlpha="0.5" width="434" height="368" addedEffect="shadowEffect"/> + <mx:HTML x="0" y="0" id="html_view" width="439" height="368" addedEffect="aboutEffect" verticalScrollPolicy="off" horizontalScrollPolicy="off" /> + +</mx:Canvas> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5ed4d983/TourDeFlex/TourDeFlex/src/components/ApplicationFooter.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex/src/components/ApplicationFooter.mxml b/TourDeFlex/TourDeFlex/src/components/ApplicationFooter.mxml index 2524d89..430629d 100644 --- a/TourDeFlex/TourDeFlex/src/components/ApplicationFooter.mxml +++ b/TourDeFlex/TourDeFlex/src/components/ApplicationFooter.mxml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,46 +17,46 @@ limitations under the License. --> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" width="100%" height="30" styleName="applicationFooter"> - - <mx:Script > - <![CDATA[ - import mx.managers.PopUpManager; - - private var popup:AboutWindow; - - private function init():void - { - popup = new AboutWindow(); - } - - private function showAbout():void - { - if(!popup.isOpen) - { - PopUpManager.addPopUp(popup, DisplayObject(this.parentApplication), false); - popup.url = "data/about.html"; - popup.isOpen = true; - PopUpManager.centerPopUp(popup); - popup.move(popup.x + 70, popup.y + 50); - } - else - { - popup.isOpen = false; - PopUpManager.removePopUp(popup); - } - } - - ]]> - </mx:Script> - <mx:Button x="4" y="1" id="aboutBtn" styleName="aboutButton" click="showAbout();" /> - <mx:HBox x="70" width="100%" height="100%" verticalAlign="middle"> - <mx:Label text="©2010 Adobe Inc, All Rights Reserved" width="25%" textAlign="center" /> - <mx:Label id="label_version" text="Version: {Config.APP_VERSION}" width="25%" textAlign="center" /> - <mx:Label id="label_objectsDataVersion" text="List Version: {Config.OBJECTS_FILE_VERSION}" width="25%" textAlign="center" /> - <mx:Label id="label_objectsTotal" text="Samples: {Config.OBJECTS_TOTAL}" width="25%" textAlign="center" /> - </mx:HBox> - - <mx:Image bottom="5" right="4" source="@Embed('/images/button_clear.png')" mouseDown="stage.nativeWindow.startResize()" buttonMode="true" mouseEnabled="true" useHandCursor="true" /> - -</mx:Canvas> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" width="100%" height="30" styleName="applicationFooter"> + + <mx:Script > + <![CDATA[ + import mx.managers.PopUpManager; + + private var popup:AboutWindow; + + private function init():void + { + popup = new AboutWindow(); + } + + private function showAbout():void + { + if(!popup.isOpen) + { + PopUpManager.addPopUp(popup, DisplayObject(this.parentApplication), false); + popup.url = "data/about.html"; + popup.isOpen = true; + PopUpManager.centerPopUp(popup); + popup.move(popup.x + 70, popup.y + 50); + } + else + { + popup.isOpen = false; + PopUpManager.removePopUp(popup); + } + } + + ]]> + </mx:Script> + <mx:Button x="4" y="1" id="aboutBtn" styleName="aboutButton" click="showAbout();" /> + <mx:HBox x="70" width="100%" height="100%" verticalAlign="middle"> + <mx:Label text="©2010 Adobe Inc, All Rights Reserved" width="25%" textAlign="center" /> + <mx:Label id="label_version" text="Version: {Config.APP_VERSION}" width="25%" textAlign="center" /> + <mx:Label id="label_objectsDataVersion" text="List Version: {Config.OBJECTS_FILE_VERSION}" width="25%" textAlign="center" /> + <mx:Label id="label_objectsTotal" text="Samples: {Config.OBJECTS_TOTAL}" width="25%" textAlign="center" /> + </mx:HBox> + + <mx:Image bottom="5" right="4" source="@Embed('/images/button_clear.png')" mouseDown="stage.nativeWindow.startResize()" buttonMode="true" mouseEnabled="true" useHandCursor="true" /> + +</mx:Canvas>