Adobe Systems, Inc.

MetadataView.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 ** ScrollingField Class 
00007 ********************************************************************/
00008 
00009 import mx.xpath.XPathAPI;
00010 import amg.*;
00011 
00012 //implements ISmartLoader interface insuring that the smartLoader callback method is present
00013 class amg.MetadataView extends MovieClip {
00014         //member properties
00015         private var _iControlWidth:Number;
00016         private var _iControlHeight:Number;
00017         private var Background:MovieClip;
00018         private var ScrollingField:MovieClip;
00019         public var iCurrentItem:Number;
00020         public var iBorderColor:Number;
00021         public var iBorderAlpha:Number;
00022         public var iBgColor:Number;
00023         public var iBgAlpha:Number;
00024         private var txtTitle:TextField;
00025         private var txtTitleStyle:TextField.StyleSheet;
00026         private var txtFont:String;
00027         private var txtColor:String;
00028         private var txtLinkColor:String;
00029         private var txtSize:String;
00030         private var txtAlign:String;
00031         private var _iMarginSpacer:Number = 6;
00032         private var _aMediaItems:Array;
00033         private var _bSlideshowMetadataTitles = true;
00034         private var _bSlideshowMetadataCaptions = true;
00035         
00036         
00037         //class constructor
00038         public function MetadataView() {
00039                 
00040                 this.Background = this.attachMovie("ScrollingFieldBg", "Background", this.getNextHighestDepth());
00041                 this.ScrollingField = this.attachMovie("ScrollingField","ScrollingField",this.getNextHighestDepth(),{_visible:true});
00042                 this.ScrollingField.tabEnabled = false;
00043                 this.ScrollingField.setFieldName("MetadataView");
00044                 this.createTextField("txtTitle",this.getNextHighestDepth(),_iMarginSpacer,18,100,20);
00045                 this.txtTitle.html = true;
00046                 this.txtTitle.multiline = true;
00047                 this.txtTitle.wordWrap = true;
00048                 this.txtTitle.embedFonts = true;
00049                 this.txtTitle.antiAliasType = "advanced";
00050                 this.txtTitle.border = false;
00051                 
00052         }
00053         
00054 
00055         
00056         public function selectItem(whichItem:Number):Void {
00057                 this.iCurrentItem = whichItem;
00058                 if(this._bSlideshowMetadataTitles)
00059                         this.txtTitle.htmlText = _aMediaItems[whichItem].itemTitle;
00060                 else
00061                         this.txtTitle.htmlText = "";
00062                         
00063                 if(this._bSlideshowMetadataCaptions)
00064                         this.ScrollingField.txtField.htmlText = _aMediaItems[whichItem].itemDesc;
00065                 else
00066                         this.ScrollingField.txtField.htmlText = "";
00067                 this. setHeightWidth(this._iControlHeight,this._iControlWidth);
00068         }
00069 
00070         
00071         public function setHeightWidth(h:Number, w:Number):Void {
00072                 this._iControlWidth = w;
00073                 this._iControlHeight = h;
00074                 
00075                 this.txtTitle._x = _iMarginSpacer;
00076                 this.txtTitle._height = this.txtTitle.textHeight+5;
00077                 this.txtTitle._width = w - this.txtTitle._x-_iMarginSpacer;
00078                 
00079                 this.ScrollingField._x = this._iMarginSpacer;
00080                 this.ScrollingField._y = this.txtTitle._x + this.txtTitle._height+this._iMarginSpacer;
00081                 
00082                 this.ScrollingField.setHeightWidth(h-this.ScrollingField._y-this._iMarginSpacer,w-10);
00083                 
00084                 this.Background._x = 0;
00085                 this.Background._y = 0;
00086                 this.Background.drawRectangle(w,h,7);
00087                 
00088 
00089         }
00090         
00091         
00092         
00093         public function parseStyleXML(styleNode:XMLNode):Void {
00094                 
00095                 //Metadata View
00096                 var xmlMetadataViewBgFill:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewBgColor");
00097                 var xmlMetadataViewBorder:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewBorder");
00098                 var xmlMetadataViewTitle:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewTitle");
00099                 var xmlMetadataViewText:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewText");
00100                 var xmlMetadataViewWidth:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewWidth");
00101                 var xmlMetadataViewBtnBorder:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewBtnBorder");
00102                 var xmlMetadataViewBtnBackground:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewBtnBackground");
00103                 var xmlMetadataViewBtnFore:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewBtnFore");
00104                 var xmlMetadataViewField:XMLNode = XPathAPI.selectSingleNode(styleNode,"/metadataView/metadataViewField");
00105                 
00106                 
00107                 this.iBorderColor = parseInt("0x"+xmlMetadataViewBorder.attributes.color);
00108                 this.iBorderAlpha =parseInt(xmlMetadataViewBorder.attributes.alpha);
00109                 this.iBgColor = parseInt("0x"+xmlMetadataViewBgFill.attributes.color);
00110                 this.iBgAlpha =parseInt(xmlMetadataViewBgFill.attributes.alpha);
00111                 
00112                 this.Background.setColors(0,this.iBorderColor,this.iBorderAlpha,this.iBgColor,this.iBgAlpha);           
00113                 
00114                 this.txtFont = xmlMetadataViewTitle.attributes.fontFamily;
00115                 this.txtColor = "#"+xmlMetadataViewTitle.attributes.color;
00116                 this.txtLinkColor = "#"+xmlMetadataViewTitle.attributes.linkColor;
00117                 this.txtSize = xmlMetadataViewTitle.attributes.size;
00118                 this.txtAlign = xmlMetadataViewTitle.attributes.align;
00119                 
00120                 if(this.txtFont == "Myriad Web Pro")
00121                         this.txtTitle.embedFonts = true;
00122                 else
00123                         this.txtTitle.embedFonts = false;
00124                 
00125                 this.txtTitleStyle = new TextField.StyleSheet();
00126                 this.txtTitleStyle.setStyle("title", {
00127                         fontFamily:txtFont,
00128                         fontWeight:'bold',
00129                         color:txtColor,
00130                         fontSize:txtSize, 
00131                         textAlign:txtAlign
00132                 });
00133                 this.txtTitleStyle.setStyle("a:link", {
00134                         color:txtLinkColor
00135                 });
00136                 this.txtTitleStyle.setStyle("a:hover", {
00137                         textDecoration:'underline'
00138                 });
00139                 
00140                 this.txtTitle.styleSheet = txtTitleStyle;
00141                 
00142                 if(xmlMetadataViewField.attributes.titles == "true")
00143                         this._bSlideshowMetadataTitles = true;
00144                 else
00145                         this._bSlideshowMetadataTitles = false;
00146                         
00147                 if(xmlMetadataViewField.attributes.captions == "true")
00148                         this._bSlideshowMetadataCaptions = true;
00149                 else
00150                         this._bSlideshowMetadataCaptions = false;
00151 
00152                 var btnBorder:String = xmlMetadataViewBtnBorder.attributes.color;
00153                 var btnBorderAlpha:String = xmlMetadataViewBtnBorder.attributes.alpha;
00154                 var btnBackground:String = xmlMetadataViewBtnBackground.attributes.color;
00155                 var btnBackgroundAlpha:String = xmlMetadataViewBtnBackground.attributes.alpha;
00156                 var btnFore:String = xmlMetadataViewBtnFore.attributes.color;
00157                 var btnForeAlpha:String = xmlMetadataViewBtnFore.attributes.alpha;
00158 
00159                 //Right Scroll Button
00160                 this.setTint(this.ScrollingField.ScrollBtnUp.BtnFore,btnFore,btnForeAlpha);
00161                 this.setTint(this.ScrollingField.ScrollBtnUp.BtnBorder,btnBorder,btnBorderAlpha);
00162                 this.setTint(this.ScrollingField.ScrollBtnUp.BtnBg,btnBackground,btnBackgroundAlpha); 
00163                 //Left Scroll Button
00164                 this.setTint(this.ScrollingField.ScrollBtnDown.BtnFore,btnFore,btnForeAlpha);
00165                 this.setTint(this.ScrollingField.ScrollBtnDown.BtnBorder,btnBorder,btnBorderAlpha);
00166                 this.setTint(this.ScrollingField.ScrollBtnDown.BtnBg,btnBackground,btnBackgroundAlpha);
00167                 //ScrollLine
00168                 this.setTint(this.ScrollingField.ScrollLine.ScrollLineBottom,btnBorder,btnBorderAlpha);
00169                 this.setTint(this.ScrollingField.ScrollLine.ScrollLineTop,btnBackground,btnBackgroundAlpha);
00170                 //ScrollThumb
00171                 this.setTint(this.ScrollingField.ScrollThumb.ScrollThumbBg.ScrollThumbBgFill,btnBackground,btnBackgroundAlpha);
00172                 this.setTint(this.ScrollingField.ScrollThumb.ScrollThumbBorder,btnBorder,btnBorderAlpha);
00173                 
00174                 this.ScrollingField.setStyle(xmlMetadataViewText);
00175                 
00176         }
00177         
00178         public function parseMediaGroup(xmlMediaGroup:XMLNode):Void {
00179                 this._aMediaItems = new Array();
00180                 
00181                 //get media item nodes
00182                 var xmlItems:Array = XPathAPI.selectNodeList(xmlMediaGroup, "/mediaGroup/media/item");
00183                 var desc:String;
00184                 var titl:String;
00185                 //parse out all photo nodes and create mediaClip objects
00186                 for (var i:Number = 0; i<xmlItems.length; i++) {
00187                                 desc = XPathAPI.selectSingleNode(xmlItems[i], "/item/description");
00188                                 titl = XPathAPI.selectSingleNode(xmlItems[i], "/item/title");
00189                                 _aMediaItems.push({itemTitle:titl,itemDesc:desc});
00190                 }
00191         }
00192         
00193         public function livePreview(whichPart:String, styleNode:XMLNode):Void {
00194                 switch(whichPart) {
00195                         case "metadataViewField" :
00196                                 if(styleNode.attributes.titles == "true")
00197                                         this._bSlideshowMetadataTitles = true;
00198                                 else
00199                                         this._bSlideshowMetadataTitles = false;
00200                                 if(styleNode.attributes.captions == "true")
00201                                         this._bSlideshowMetadataCaptions = true;
00202                                 else
00203                                         this._bSlideshowMetadataCaptions = false;
00204                                 this.selectItem(this.iCurrentItem);
00205                                 break;
00206                         case "metadataViewBgColor" :
00207                                 this.iBgColor = parseInt("0x"+styleNode.attributes.color);
00208                                 this.iBgAlpha = parseInt(styleNode.attributes.alpha);
00209                                 this.Background.setColors(0,this.iBorderColor,this.iBorderAlpha,this.iBgColor,this.iBgAlpha);
00210                                 break;
00211                         case "metadataViewBorder" :
00212                                 this.iBorderColor = parseInt("0x"+styleNode.attributes.color);
00213                                 this.iBorderAlpha =parseInt(styleNode.attributes.alpha);
00214                                 this.Background.setColors(0,this.iBorderColor,this.iBorderAlpha,this.iBgColor,this.iBgAlpha);
00215                                 break;
00216                         case "metadataViewTitle" :
00217                                 this.txtFont = styleNode.attributes.fontFamily;
00218                                 this.txtColor = "#"+styleNode.attributes.color;
00219                                 this.txtLinkColor = "#"+styleNode.attributes.linkColor;
00220                                 this.txtSize = styleNode.attributes.size;
00221                                 this.txtAlign = styleNode.attributes.align;
00222                                 
00223                                 if(this.txtFont == "Myriad Web Pro")
00224                                         this.txtTitle.embedFonts = true;
00225                                 else
00226                                         this.txtTitle.embedFonts = false;
00227                                 
00228                                 this.txtTitleStyle = new TextField.StyleSheet();
00229                                 this.txtTitleStyle.setStyle("title", {
00230                                         fontFamily:txtFont,
00231                                         fontWeight:'bold',
00232                                         color:txtColor,
00233                                         fontSize:txtSize, 
00234                                         textAlign:txtAlign
00235                                 });
00236                                 this.txtTitleStyle.setStyle("a:link", {
00237                                         color:txtLinkColor
00238                                 });
00239                                 this.txtTitleStyle.setStyle("a:hover", {
00240                                         textDecoration:'underline'
00241                                 });
00242                                 
00243                                 this.txtTitle.styleSheet = txtTitleStyle;
00244                                 break;
00245                         case "metadataViewText" :
00246                                 this.ScrollingField.setStyle(styleNode);
00247                                 break;
00248                         case "metadataViewBtnBorder" :
00249                                 //Right Scroll Button
00250                                 
00251                                 this.setTint(this.ScrollingField.ScrollBtnUp.BtnBorder,styleNode.attributes.color,styleNode.attributes.alpha);
00252                                 this.setTint(this.ScrollingField.ScrollBtnDown.BtnBorder,styleNode.attributes.color,styleNode.attributes.alpha);
00253                                 this.setTint(this.ScrollingField.ScrollLine.ScrollLineBottom,styleNode.attributes.color,styleNode.attributes.alpha);
00254                                 this.setTint(this.ScrollingField.ScrollThumb.ScrollThumbBorder,styleNode.attributes.color,styleNode.attributes.alpha);
00255                                 break;
00256                         case "metadataViewBtnBackground" :
00257                                 this.setTint(this.ScrollingField.ScrollBtnUp.BtnBg,styleNode.attributes.color,styleNode.attributes.alpha);
00258                                 this.setTint(this.ScrollingField.ScrollBtnDown.BtnBg,styleNode.attributes.color,styleNode.attributes.alpha);
00259                                 this.setTint(this.ScrollingField.ScrollLine.ScrollLineTop,styleNode.attributes.color,styleNode.attributes.alpha);
00260                                 this.setTint(this.ScrollingField.ScrollThumb.ScrollThumbBg.ScrollThumbBgFill,styleNode.attributes.color,styleNode.attributes.alpha);
00261                                 break;
00262                         case "metadataViewBtnFore" :
00263                                 this.setTint(this.ScrollingField.ScrollBtnUp.BtnFore,styleNode.attributes.color,styleNode.attributes.alpha);
00264                                 this.setTint(this.ScrollingField.ScrollBtnDown.BtnFore,styleNode.attributes.color,styleNode.attributes.alpha);
00265                                 break;
00266                 }
00267         }
00268         
00269         /**************************************************************
00270         ** setTint
00271         ** Sets a color object for a movieclip and then sets its tint
00272         ** allowing for ActionScript control of display colors
00273         ****************************************************************/
00274         function setTint(clip:MovieClip,hexval:String,alpha:String):Void {
00275                 hexval = "0x" + hexval;
00276                 var colorVal = parseInt(hexval);
00277                 var alphaVal = parseInt(alpha);
00278                 var color:Color = new Color(clip);
00279                 var oColorTransform:Object = new Object();
00280                 oColorTransform.ra = oColorTransform.ga = oColorTransform.ba   = 0;
00281                 oColorTransform.rb = (colorVal >> 16) & 0xFF;
00282                 oColorTransform.gb = (colorVal >> 8) & 0xFF;
00283                 oColorTransform.bb = colorVal & 0xFF;
00284                 oColorTransform.ab = ((alphaVal/100)*255)-255;
00285                 color.setTransform(oColorTransform);
00286         }
00287 
00288 }

Copyright © 2006 Adobe Systems Incorporated.

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