Adobe Systems, Inc.

Startup.as

Go to the documentation of this file.
00001 /**************************************************************************
00002 ** Copyright 2005-2006 Adobe Systems Incorporated
00003 ** Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004 ** or a copy at http://opensource.adobe.com/licenses.html)
00005 **
00006 ** NOTE: This movie relies upon ActionScript 2.0 files located 
00007 ** in the 'AdobeFlashLib' directory and will not compile without them.
00008 ** Gallery.as is the main class for this application and a good place to start
00009 ** when reviewing the source.
00010 *****************************************************************************/
00011 
00012 //import the external interface API for livePreview calls from parent applications
00013 import flash.external.*;
00014 
00015 var xmlGroupChunk = new XML();
00016 xmlGroupChunk.ignoreWhite = true;
00017 var readyToProcessChunk:Boolean = false;
00018 var xmlChunkBuffer:Array = new Array();
00019 
00020 //lock this movies _root ref
00021 this._lockroot = true;
00022 
00023 //used when gallery is embedded in parent swfs (like Breeze Server)
00024 var runAsEmbedded:Boolean = false;      
00025 
00026 //external API variables
00027 var methodName:String = "livePreview";                          
00028 var instance:Object = null;
00029 var method:Function = extLivePreview;
00030 
00031 var methodName2:String = "liveMetadata";
00032 var instance2:Object = null;
00033 var method2:Function = extLiveMetadata;
00034 
00035 var methodName4:String = "loadGroupXMLChunk";
00036 var instance4:Object = null;
00037 var method4:Function = loadGroupXMLChunk;
00038 
00039 
00040 
00041 //this is where we can use a flashvar to get around the security warning
00042 //that external interface causes
00043 if((livePreview == "true") || (livePreview == undefined)){
00044         var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);
00045         ExternalInterface.addCallback(methodName2, instance2, method2);
00046         ExternalInterface.addCallback(methodName4, instance4, method4);
00047 }
00048 
00049 
00050 //add the Gallery object to the stage (see Gallery.as in the source directory)
00051 this.attachMovie("Gallery","gallery",100,{embedEnabled:runAsEmbedded});
00052 
00053 
00054 //Breeze Server funstion and variables
00055 var podWidth:Number = 805;
00056 var podHeight:Number = 596;
00057 if(_parent)
00058         runAsEmbedded = true;
00059 else
00060         runAsEmbedded = false;
00061 function setSize(w, h)
00062 {
00063         podHeight = h;
00064         podWidth = w;
00065         
00066         gallery.setHeightWidth(h,w);
00067 }
00068 
00069 //set a listener, with this movie as its parent, 
00070 //to detect when all the classes and movieclips are loaded
00071 var _oPreloadListener = new Object();
00072 _oPreloadListener._parent = this;
00073 
00074 //set stage properties and a listener for stage resizing
00075 Stage.scaleMode = "noScale"; 
00076 Stage.align = "TL"; 
00077 Stage.addListener(_oPreloadListener);
00078 _oPreloadListener.onResize = resizeStage;
00079 _oPreloadListener.onResize();
00080 
00081 //center the preloader animation clip on the stage
00082 function resizeStage(){
00083         mcWaitBar._y =  Stage.height/2;
00084         mcWaitBar._x = Stage.width/2;
00085 }
00086 
00087 
00088 /*************************************************
00089 ** Live Preview functions
00090 ** used when a parent application needs to 
00091 ** set style attrributes in real time 
00092 *************************************************/
00093 function extLivePreview(styleNode:String):Void{
00094         gallery.livePreview(styleNode);
00095 }
00096 
00097 function extLiveMetadata(p_node:String):Void{
00098         var styleXML:XML = new XML();
00099         styleXML.parseXML(p_node);
00100         var styleNode:XMLNode = styleXML.firstChild;
00101         
00102         switch (styleNode.nodeName) {
00103                 case "groupTitle":
00104                         //styleNode= styleXML.createElement("groupTitleString");
00105                         //styleNode.attributes.value = p_node.attributes.value;
00106                         styleNode.nodeName = "groupTitleString";
00107                         break;
00108                 case "siteTitle":
00109                 case "pageTitle":
00110                         //styleNode= styleXML.createElement("pageTitleString");
00111                         //styleNode.attributes.value = p_node.attributes.value;
00112                         styleNode.nodeName = "pageTitleString";
00113                         break;
00114                 case "contactEmail":
00115                         trace("contactEmail" + styleNode.attributes.value);
00116                         break;
00117                 case "contactName":
00118                         trace("contactName" + styleNode.attributes.value);
00119                         break;
00120                 case "contactInfo":
00121                         if(styleNode.attributes.link.indexOf("http:") == -1){
00122                                 styleNode.attributes.link = "mailto:"+styleNode.attributes.link;
00123                         }
00124                         styleNode.nodeName = "contactInfoString";
00125                         break;
00126                 case "galleryInfo":
00127                         if(styleNode.attributes.link.indexOf("http:") == -1){
00128                                 styleNode.attributes.link = "mailto:"+styleNode.attributes.link;
00129                         }
00130                         styleNode.nodeName = "contactInfoString";
00131                         break;
00132         }
00133         
00134         gallery.livePreview(styleNode);
00135 }
00136 
00137 /************************************************************************
00138 ** loadGroupXMLChunk
00139 ** Function that allows authoring applications to send the media group xml
00140 ** file in sections, allowing users to see their gallery before
00141 ** the authoring app has completed creating the entire group file
00142 ***********************************************************************/
00143 function loadGroupXMLChunk(p_path:String){
00144         
00145         //xml file load callback function
00146         _root.xmlGroupChunk.onLoad = function(success:Boolean) {
00147                 if (success){ 
00148                         _root.gallery.loadGroupXMLChunk(_root.xmlGroupChunk);
00149                         trace("z0");
00150                 }
00151                 else
00152                         trace("fail load");
00153         };
00154         
00155         //determine if the gallery is ready to process a set of images
00156         if(_root.readyToProcessChunk){
00157                 //set the ready-to-load flag
00158                 _root.readyToProcessChunk = false;
00159                 
00160                 //see if any aml paths are quesed up for processing
00161                 if(_root.xmlChunkBuffer.length > 0)
00162                         _root.xmlGroupChunk.load(_root.xmlChunkBuffer.shift());
00163                 else
00164                         _root.xmlGroupChunk.load(p_path);
00165         }
00166         else {
00167                 //start loading the images in this chunk
00168                 _root.xmlChunkBuffer.push(p_path)
00169         }
00170         
00171         
00172 
00173 }
00174 
00175 
00176 function UIElementClick(p_name:String,p_x:Number,p_y:Number,p_height:Number,p_width:Number,p_fontName:String,p_fontSize:Number,p_textAlign:String){
00177         ExternalInterface.call( 'UIElementClick', p_name, p_x, p_y, p_width, p_height, p_fontName, p_fontSize, p_textAlign );
00178 }
00179 
00180 stop();

Copyright © 2006 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.