/* This is the FlAniS -- Flash version of the AnimationS applet. This code is Copyright(C) 2008-2009 by Tom Whittaker. You may use this for any lawful purpose, and we are not responsible for what you do with it. It was developed as an outcome of the VISIT Project and uses many classes from the VISITview collaborative training / distance learning tool. */ // this is compiled with the mxmlc using the flanis.mxml template... // package { import mx.controls.Button; import mx.controls.CheckBox; import mx.controls.ComboBox; import mx.controls.Label; import mx.controls.HSlider; import mx.controls.RadioButton; import mx.controls.RadioButtonGroup; import mx.controls.ProgressBar; import mx.controls.Alert; import mx.controls.TextArea; import mx.core.*; import mx.containers.HBox; import mx.containers.VBox; import mx.containers.Canvas; import mx.containers.Panel; import mx.containers.TitleWindow; import mx.core.UIComponent; import mx.events.SliderEvent; import mx.events.ListEvent; import mx.events.CloseEvent; import mx.utils.StringUtil; import flash.display.Loader; import flash.display.Bitmap; import flash.display.Sprite; import flash.display.BitmapData; import flash.display.Graphics; import flash.display.SimpleButton; import flash.events.Event; import flash.events.MouseEvent; import flash.events.KeyboardEvent; import flash.events.IOErrorEvent; import flash.events.SecurityErrorEvent; import flash.events.HTTPStatusEvent; import flash.external.ExternalInterface; import flash.net.URLRequest; import flash.geom.Point; import flash.geom.Rectangle; import flash.geom.Matrix; import flash.geom.ColorTransform; import flash.printing.PrintJob; import flash.printing.PrintJobOptions; import flash.utils.Timer; import flash.events.TimerEvent; import flash.system.System; import flash.system.Capabilities; import flash.net.*; import flash.text.*; import mx.managers.PopUpManager; public class FlAniS { private var version:String; private var isDebug:Boolean; private var debugTextArea:TextArea; private var debugText:String; private var background:int; private var foreground:int; private var usingIP:Boolean; private var onlyShowFirstImage:Boolean; private var quietReload:Boolean; private var quietLoadem:Boolean; private var noControls:Boolean; private var useProgressBar:Boolean; private var isLoading:Boolean; private var countFrames:int; private var doExcludeCaching:Boolean; private var excludeCaching:String; private var useCaching:Boolean; private var useAntiCaching:Boolean; private var antiCacheIndex:int; private var baseStatic:Boolean; private var imageBase:String; private var s:Array; private var its:int; private var showButt:Button; private var printButt:Button; private var zoom:Button; private var zoomLabelTrue:String; private var zoomLabelFalse:String; private var keepZoom:Boolean; private var activeZoom:Boolean; private var zoomScale:Number; private var zoomXFactor:Number; private var zoomYFactor:Number; private var zoomXBase:Number; private var zoomYBase:Number; private var isZooming:Boolean; private var enableZooming:Boolean; private var frameLabelWidth:int; private var frameLabelField:Label; private var hasFrameLabel:Boolean; private var frameLabels:Array; private var doLayoutControls:Boolean; private var useBottomControls:Boolean; private var looprock:Button; private var looprockLabelTrue:String; private var looprockLabelFalse:String; private var isLoopRock:Boolean; private var loopDirection:int; private var isRocking:Boolean; private var autoOnOff:Button; private var autoOnOffLabelTrue:String; private var autoOnOffLabelFalse:String; private var refreshRate:int; private var refreshTimer:Timer; private var autoState:Boolean; private var refresh:Button; private var isAutoRefresh:Boolean; private var showAllOnOff:Boolean; private var onOffWidth:int; private var onOffHeight:int; private var onOffSpacing:int; private var onOffState:Array; private var onOffBM:Bitmap; private var onOffRect:Rectangle; private var onOffBMD:BitmapData; private var onOffUI:UIComponent; private var onOffSprite:Sprite; private var onOffBackground:uint; private var isOnOff:Boolean; private var incFrame:int; private var stepBack:Button; private var stepForward:Button; private var isStepping:Boolean; private var stepFirst:Button; private var stepLast:Button; private var setFrameScrollbar:HSlider; private var setFrameText:String; private var isSetFrameScrollbar:Boolean; private var setFaderScrollbar:HSlider; private var faderToggle:Button; private var setFaderText:String; private var isFader:Boolean; private var faderFrame:int; private var faderImages:Array; private var isShowingFrames:Boolean; private var faderLabel:String; private var startFrame:int; private var basename:String; private var baseNumber:int; private var numFrames:int; private var currentFrame:int; private var deadFrames:int; private var firstFrame:int; private var lastFrame:int; private var enh:Array; private var enhNames:Array; private var enhanceChoice:ComboBox; private var madeEnhBitmaps:Boolean; private var enhBitmaps:Array; private var enhOverlay:int; private var location:Array; private var lat:Number; private var lon:Number; private var isLoc:Boolean; private var doingLoc:Boolean; private var locLabel:Label; private var locLabelDigits:int; private var locLabelFirst:String; private var locLabelSecond:String; private var xMouse:int; private var yMouse:int; private var locOffset:int; private var locButt:Button; private var locLabelOff:String; private var locLabelOn:String; private var locLabels:Array; private var vb:VBox; private var vbc:VBox; private var hb:HBox; private var controlBox:HBox; private var overlayControlBox:HBox; private var overlayControlContainer:VBox; private var speed:HSlider; private var dwell:int; private var minSpeed:int; private var maxSpeed:int; private var mySpeed:int; private var addDwell:int; private var pauseOnLast:int; private var pausePercent:int; private var startstop:Button; private var startstopLabelTrue:String; private var startstopLabelFalse:String; private var bm:Bitmap; private var grandma:Application; private var mom:Canvas; private var sp:Sprite; private var timer:Timer; private var isLooping:Boolean; private var wasLooping:Boolean; private var isOverlay:Boolean; private var overlay:Array; private var overlayLinks:Array; private var overlayOrder:Array; private var overlayHidden:Array; private var overlayStatic:Array; private var overlayZoom:Array; private var overlayTransparentAmount:Array; private var ct:ColorTransform; private var transparency:int; private var numOverlayLabels:int; private var doneOverlayMask:Array; private var overlayMask:Array; private var probeValues:Array; private var probe:CheckBox; private var isProbe:Boolean; private var probeEnabled:Boolean; private var fnList:Array; private var biList:Array; private var olList:Array; private var hiresFnList:Array; private var fnDwell:Array; private var useDwell:Boolean; private var minDwell:int; private var canResetDwell:Boolean; private var hsButton:Array; private var hsUI:UIComponent; private var hsType:Array; private var hsValue:Array; private var hsPoint:Array; private var hsPan:Array; private var hsBitmaps:Array; private var hsColor:int; private var hsImageNames:Array; private var hsLoaders:Array; private var hsLoaderInfo:Array; private var hsCan:Canvas; private var doingHotspots:Boolean; private var loadingHotspot:Boolean; private var backhsButton:Array; private var backhsType:Array; private var backhsValue:Array; private var doingBackHotspots:Boolean; private var loadingBackHotspot:Boolean; private var drawingPaper:UIComponent; private var probePaper:UIComponent; private var pbar:ProgressBar; private var totalFrames:int; private var initialLoad:Boolean; private var imgList:Array; private var hiresImgList:Array; private var singleImage:Array; private var imgSmoothList:Array; private var imgUIBack:UIComponent; private var imgLoaderList:Array; private var hiresImgLoaderList:Array; private var imgLoaderInfoList:Array; private var hiresImgLoaderInfoList:Array; private var imgZoomableList:Array; private var preserve:Array; private var preRect:Rectangle; private var prePoint:Point; private var xImage:int; private var yImage:int; private var xLineEnd:int; private var yLineEnd:int; private var xScreen:int; private var yScreen:int; private var xMove:int; private var yMove:int; private var bmBack:Bitmap; private var bmBackground:BitmapData; private var bmBackCreated:Boolean private var bmBackLoaded:Array private var bmWidth:int; private var bmHeight:int; private var userWindowSize:Boolean; private var imgWidth:int; private var imgHeight:int; private var biComp:UIComponent; private var biSprite:Sprite; private var usingBI:Boolean; private var activeKey:int; private var backSprite:Sprite; private var upperLeft:Point; private var lowerRight:Point; private var imgRect:Rectangle; private var bmRect:Rectangle; private var isDragging:Boolean; private var isDrawingLine:Boolean; private var paramNames:Array; private var paramValues:Array; private var pLabels:Array private var verLab:Label; // Application point of entry public static function main(defConfig:int):void { var ec:FlAniS = new FlAniS(); ec.letterroll(defConfig); } /** letterroll() * * Why did we call it this? * */ public function letterroll(defConfig:int):void { grandma = Application(Application.application); grandma.layout="absolute"; grandma.frameRate = 1; //grandma.addEventListener(KeyboardEvent.KEY_DOWN, kclick); mom = new Canvas(); mom.height = grandma.height; mom.width = grandma.width; mom.setStyle("backgroundColor", grandma.getStyle("backgroundColor")); mom.setFocus(); mom.addEventListener(KeyboardEvent.KEY_DOWN, kclick); mom.addEventListener(KeyboardEvent.KEY_UP, kclick); grandma.addChild(mom); initialLoad = true; canResetDwell = false; currentFrame = 0; bmBackCreated = false; zoomXFactor = 1.0; zoomYFactor = 1.0; isZooming = false; enableZooming = false; isDragging = false; isDrawingLine = false; isOverlay = false; incFrame = 1; isFader = false; preRect = new Rectangle(); prePoint = new Point(); madeEnhBitmaps = false; locOffset = 20; upperLeft = new Point(0,0); lowerRight = new Point(mom.width,mom.height); // until image defined ct = new ColorTransform(1.0,1.0,1.0,1.0); version = "FlAniS version 1.4"; trace(version); debugText = version+"\n"; // all set up must be serialized, since there is no // other way to do it...hmmmm.... paramNames = new Array(); paramValues = new Array(); // see if name supplied in Flashvars var cfname:String = grandma.parameters.configFilename; if (defConfig == 1) cfname = "flanis.cfg"; if (cfname == null) { debugText = debugText + "\n NO config filename!"; configParams(); } else { trace ("config filename = "+cfname); debugText = debugText +"\nConfig filename = "+cfname; if (cfname.indexOf("?") > 0) { var bar:RegExp = /\|/g; cfname = cfname.replace(bar,"&"); debugText = debugText + "\nPHP config = "+cfname; } isLoading = false; try { var configLoader:URLLoader = new URLLoader(); configLoader.dataFormat = URLLoaderDataFormat.TEXT; configLoader.addEventListener(Event.COMPLETE, configLoaded); configLoader.addEventListener(IOErrorEvent.IO_ERROR, errorLoadingConfigFile); var request:URLRequest = new URLRequest(cfname); // turn off caching ? request.requestHeaders.push(new URLRequestHeader("Cache-Control","no-store,max-age=0,no-cache,must-revalidate")); request.requestHeaders.push(new URLRequestHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT")); request.requestHeaders.push(new URLRequestHeader("Pragma","no-cache")); configLoader.load(request); } catch (ibce:Error) { Alert.show("Unable to load config file: "+cfname+" Error="+ibce); } } } /** configLoaded(Event) * * after getting the "configFile", parse it and create lists for * getParameter() calls... * */ private function configLoaded(event:Event) : void { trace("into configLoaded........."); var cfl:URLLoader = URLLoader(event.target); var lines:Array = cfl.data.split("\n"); var eqinx:int = 0; // first, parse the basic requests for (var i:int=0; i "+ probeValues[p][pa][0]+" : "+probeValues[p][pa][1]); } } } } // minimum dwell minDwell = 10000/100; //set to 10 fps s = getParameter("minimum_dwell"); if (s != null) minDwell = parseInt(s[0]); if (minDwell < 20) minDwell = 20; // 50 fps // now pick up params with no associated widget.... minSpeed = 2; maxSpeed = 10000/minDwell; mySpeed = (maxSpeed + minSpeed)/2 s = getParameter("rate"); if (s != null) { mySpeed = parseInt(s[0]); if (mySpeed > 500 || mySpeed < 1) { debug("******** Invalid value for 'rate' parameter, = "+mySpeed); mySpeed = (maxSpeed + minSpeed)/2; } if (s.length > 1) { minSpeed = parseInt(s[1]); maxSpeed = parseInt(s[2]); if (maxSpeed > 500 || maxSpeed < mySpeed) { maxSpeed = 300; debug("******** Invalid value for 'rate' maxSpeed parameter...."); } if (minSpeed < 0 || minSpeed > mySpeed) { maxSpeed = 2; debug("******** Invalid value for 'rate' minSpeed parameter...."); } } else { // compute minSpeed = mySpeed - (maxSpeed - mySpeed); if (mySpeed >= maxSpeed) { maxSpeed = mySpeed + 50; minDwell = 10000/maxSpeed; } if (maxSpeed - mySpeed > 10) minSpeed = 2*mySpeed - maxSpeed; if (minSpeed < 2) minSpeed = 2; } } dwell = 10000/mySpeed; s = getParameter("rocking"); if (s != null) { if (startsWith(s[0],"t") || startsWith(s[0],"T")) isRocking=true; } else { isRocking = false; } s = getParameter("loop"); s = getParameter("pause"); pauseOnLast = 0; if (s != null) { pauseOnLast = parseInt(s[0]); if (pauseOnLast < 0 || pauseOnLast > 20000) { pauseOnLast = 0; debug("******** Bad value for 'pause' parameter = "+pauseOnLast); } } s = getParameter("pause_percent"); pausePercent = 0; if (s != null) { pausePercent = parseInt(s[0]); if (pausePercent < 0 || pausePercent > 20000) { pausePercent = 0; debug("******** Bad value for 'pause' parameter = "+pausePercent); } } s = getParameter("transparency"); transparency = 0x00000000; if (s != null) { transparency = parseHex(s[0]); } s = getParameter("image_preserve"); if (s != null) { if (s.length % 4 != 0) { debug("******** image_preserve -- incorrect number of parameters!"); preserve = null; } else { preserve = new Array(s.length); for (i = 0; i -1) doEnh = true; sc = getParameter("bottom_controls"); if (sc != null && sc.indexOf("enhance") > -1) doEnh = true; s = getParameter("no_enh"); if (s != null || !doEnh) { getImageFilenames(); } else { var enhLoader:URLLoader = new URLLoader(); enhLoader.dataFormat = URLLoaderDataFormat.TEXT; enhLoader.addEventListener(Event.COMPLETE, doneGettingEnhTab); enhLoader.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void { debug("IOErrorEvent for enh.tab file"); getImageFilenames(); } ); var enhName:String = "enh.tab"; s = getParameter("enhance_filename"); if (s != null) enhName = s[0]; try { if (useAntiCaching) { antiCacheIndex = Math.random()*1677216.0; enhName = "enh.tab?"+antiCacheIndex; } if (imageBase != null) enhName = imageBase+enhName; var request:URLRequest = new URLRequest(enhName); // turn off caching ? request.requestHeaders.push(new URLRequestHeader("Cache-Control","no-store,max-age=0,no-cache,must-revalidate")); request.requestHeaders.push(new URLRequestHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT")); request.requestHeaders.push(new URLRequestHeader("Pragma","no-cache")); enhLoader.load( request); } catch (ioe:Error) { debug("Other Error for enh.tab file"); Alert.show("Unable to load enhancement file: "+enhName+" Error: "+ioe); } } } /** getImageFilenames() * * come here to get the filenames (initially and/or on "refresh") * * if file_of_filenames, initiate read of that * * otherwise, just continue on.... * */ private function getImageFilenames():void { var s:Array = getParameter("file_of_filenames"); if (s != null) { fnList = new Array(); var fnLoader:URLLoader = new URLLoader(); fnLoader.dataFormat = URLLoaderDataFormat.TEXT; fnLoader.addEventListener(Event.COMPLETE, doneGettingFilenames); fnLoader.addEventListener(IOErrorEvent.IO_ERROR, errorLoadingFilenames); var fofName:String = s[0]; try { if (fofName.indexOf("?") > 0) { var bar:RegExp = /\|/g; fofName = fofName.replace(bar,"&"); debugText = debugText + "\nPHP file-of-filenames = "+fofName; } else if (useAntiCaching) { antiCacheIndex = Math.random()*1677216.0; fofName = StringUtil.trim(s[0])+"?"+antiCacheIndex; } if (imageBase != null) fofName = imageBase+fofName; var request:URLRequest = new URLRequest(fofName); // turn off caching ? request.requestHeaders.push(new URLRequestHeader("Cache-Control","no-store,max-age=0,no-cache,must-revalidate")); request.requestHeaders.push(new URLRequestHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT")); request.requestHeaders.push(new URLRequestHeader("Pragma","no-cache")); fnLoader.load( request); } catch (ioe:Error) { Alert.show("Unable to load configuration file: "+s[0]+" Error: "+ioe); } } else { doneGettingFilenames(null); } } /** doneGettingFilenames(Event) * * handler for file_of_filenames * * if called from elsewhere, just continue on to getImages() * */ private function doneGettingFilenames(event:Event) : void { frameLabels = getParameter("frame_label"); if (event != null) { if (frameLabels == null) frameLabels = new Array(); var fnl:URLLoader = URLLoader(event.target); var lines:Array = fnl.data.split("\n"); var firstTime:Boolean = true; var firstHotspot:Boolean = true; // first push for background ([0]) fnList.push(new Array()); for (var i:int=0; i 2) { frameLabelField.setStyle("fontSize",parseInt(fls[2])); } if (fls.length > 3) { frameLabelField.height = parseInt(fls[3]); } } else { frameLabelField.opaqueBackground = background; frameLabelField.setStyle("color",foreground); } frameLabelField.graphics.lineStyle(1,foreground); frameLabelField.graphics.drawRect(0,0,frameLabelWidth,frameLabelField.height); frameLabelField.text = " "; hasFrameLabel = true; if (tips != null) frameLabelField.toolTip = tips[cn]; controlBox.addChild(frameLabelField); gotControls = true; } else if (s[cn] == "looprock") { looprock = new Button(); pLabels = getParameter("looprock_labels"); if (pLabels == null) { looprockLabelTrue = "Loop"; looprockLabelFalse = "Rock"; } else { looprockLabelTrue = pLabels[0]; looprockLabelFalse = pLabels[1]; if (pLabels.length == 3) { looprock.width = parseInt(pLabels[2]); } } if (isRocking) { looprock.label = looprockLabelTrue; } else { looprock.label = looprockLabelFalse; } looprock.addEventListener(MouseEvent.CLICK, bclick); isLoopRock = true; if (tips != null) looprock.toolTip = tips[cn]; controlBox.addChild(looprock); gotControls = true; } else if ( (s[cn].indexOf("autotoggle") == 0) || (s[cn].indexOf("autorefresh") == 0) ) { autoOnOff = new Button(); pLabels = getParameter("autotoggle_labels"); if (pLabels == null) pLabels = getParameter("autorefresh_labels"); if (pLabels == null) { autoOnOffLabelTrue = "Auto On "; autoOnOffLabelFalse = "Auto Off"; } else { autoOnOffLabelTrue = pLabels[0]; autoOnOffLabelFalse = pLabels[1]; if (pLabels.length == 3) { autoOnOff.width = parseInt(pLabels[2]); } } if (!isAutoRefresh) { refreshRate = 1; refreshTimer = new Timer(refreshRate*60*1000); refreshTimer.addEventListener(TimerEvent.TIMER, refreshImages, false, 0, true); isAutoRefresh = true; } if (s[cn].indexOf("/off") > 0) { autoOnOff.label = autoOnOffLabelTrue; autoState = false; refreshTimer.stop(); } else { autoOnOff.label = autoOnOffLabelFalse; autoState = true; } if (tips != null) autoOnOff.toolTip = tips[cn]; autoOnOff.addEventListener(MouseEvent.CLICK, bclick); controlBox.addChild(autoOnOff); gotControls = true; } else if (s[cn] == "refresh") { refresh = new Button(); pLabels = getParameter("refresh_label"); if (pLabels == null) { refresh.label = "Refresh"; } else { refresh.label = pLabels[0]; if (pLabels.length == 2) { refresh.width = parseInt(pLabels[1]); } } refresh.addEventListener(MouseEvent.CLICK, bclick); if (tips != null) refresh.toolTip = tips[cn]; controlBox.addChild(refresh); gotControls = true; } else if (s[cn] == "location") { locButt = new Button(); locLabels = getParameter("location_labels"); if (locLabels == null) { locLabelOff = "Show Location"; locLabelOn = "Hide Location"; locButt.width = 100; } else { locLabelOff = locLabels[0]; locLabelOn = locLabels[1]; if (locLabels.length == 3) { locButt.width = parseInt(locLabels[2]); } } locButt.label = locLabelOff; isLoc = false; locButt.addEventListener(MouseEvent.CLICK, bclick); if (tips != null) locButt.toolTip = tips[cn]; locLabel.visible = false; controlBox.addChild(locButt); gotControls = true; } else if (s[cn] == "probe") { probe = new CheckBox(); pLabels = getParameter("probe_label"); if (pLabels == null) { probe.label = "Probe"; } else { probe.label = pLabels[0]; if (pLabels.length == 2) { probe.width = parseInt(pLabels[1]); } } probe.addEventListener(MouseEvent.CLICK, bclick); if (tips != null) probe.toolTip = tips[cn]; controlBox.addChild(probe); isProbe = true; probeEnabled = false; gotControls = true; } else if (s[cn] == "show") { debug("Making show button...."); if (ExternalInterface.available) { debug("External interface available..."); showButt = new Button(); showButt.label = "Show"; var sbl:Array = getParameter("show_label"); if (sbl != null) showButt.label = sbl[0]; showButt.addEventListener(MouseEvent.CLICK, bclick); if (tips != null) showButt.toolTip = tips[cn]; if (isLooping) { showButt.enabled = false; } else { showButt.enabled = true; } controlBox.addChild(showButt); gotControls = true; } else { debug("External Interface is NOT availble - so no Show Button!") } } else if (s[cn] == "print") { printButt = new Button(); printButt.label = "Print"; var pbl:Array = getParameter("print_label"); //if (pbl == null) pbl = getParameter("show_label"); if (pbl != null) printButt.label = pbl[0]; printButt.addEventListener(MouseEvent.CLICK, bclick); if (tips != null) printButt.toolTip = tips[cn]; if (isLooping) { printButt.enabled = false; } else { printButt.enabled = true; } controlBox.addChild(printButt); gotControls = true; } else if (s[cn] == "step") { stepBack = new Button(); stepBack.label="<"; stepBack.width=20; stepBack.addEventListener(MouseEvent.CLICK, bclick); stepForward = new Button(); stepForward.label=">"; stepForward.width=20; stepForward.addEventListener(MouseEvent.CLICK, bclick); isStepping = true; if (tips != null) stepBack.toolTip = tips[cn]; if (tips != null) stepForward.toolTip = tips[cn]; controlBox.addChild(stepBack); controlBox.addChild(stepForward); gotControls = true; } else if (s[cn] == "firstlast") { stepFirst = new Button(); stepFirst.label = "<|"; stepFirst.width = 30; stepFirst.addEventListener(MouseEvent.CLICK, bclick); stepLast = new Button(); stepLast.label = "|>"; stepLast.width = 30; stepLast.addEventListener(MouseEvent.CLICK, bclick); if (tips != null) stepFirst.toolTip = tips[cn]; if (tips != null) stepLast.toolTip = tips[cn]; controlBox.addChild(stepFirst); controlBox.addChild(stepLast); gotControls = true; } else if (s[cn] == "setframe") { setFrameScrollbar = new HSlider(); var sft:Array = getParameter("setframe_label"); setFrameText = "Set Frame *"; if (sft != null) setFrameText = StringUtil.trim(sft[0]); setFrameScrollbar.setStyle("labelOffset",0); //setFrameScrollbar.height=40; setFrameScrollbar.showDataTip = false; setFrameScrollbar.maximum = numFrames - 1; setFrameScrollbar.minimum = startFrame; setFrameScrollbar.liveDragging = true; setFrameScrollbar.addEventListener(SliderEvent.CHANGE,changeFrame); if (tips != null) setFrameScrollbar.toolTip = tips[cn]; //setFrameScrollbar.labels = [" ",setFrameText," "]; changeFrame(null); controlBox.addChild(setFrameScrollbar); gotControls = true; } else if (s[cn].indexOf("toggle") == 0) { var toggles:Array = getParameter("toggle_size"); if (s[cn].toLowerCase().indexOf("/showall") != -1) { showAllOnOff = true; } else { showAllOnOff = false; } onOffWidth = 10; onOffHeight = 10; onOffSpacing = 3; if (toggles != null) { onOffWidth = parseInt(toggles[0]); onOffHeight = parseInt(toggles[1]); if (toggles.length > 2) onOffSpacing = parseInt(toggles[2]); } onOffBMD = new BitmapData(numFrames*(onOffSpacing+onOffWidth), onOffHeight+3, true, onOffBackground); onOffBM = new Bitmap(onOffBMD); onOffSprite = new Sprite(); onOffSprite.addChild(onOffBM); onOffRect = new Rectangle(0,0,onOffWidth, onOffHeight); onOffUI = new UIComponent(); onOffUI.addChild(onOffSprite); onOffUI.height = onOffHeight+3; onOffUI.width = (onOffSpacing+onOffWidth)*numFrames; onOffState =new Array(); for (var nof:int = 0; nof