home *** CD-ROM | disk | FTP | other *** search
- class com.argosy.ui.LabelViewer extends com.argosy.ui.baseUI
- {
- var xml_loader;
- var base_url;
- var soundPlayer;
- var image_array;
- var current_image;
- var image_holder;
- var image_loader;
- var mask;
- var caption_tf;
- var instructions_tf;
- var location_tf;
- var view_labels_button;
- var hide_labels_button;
- var bg;
- var uiPanel;
- var button_holder;
- var back_button;
- var next_button;
- var load_bar;
- static var label_style;
- var isComplete = true;
- var uiPanelWidth = 220;
- var showAllOutlines = false;
- var showAllLabels = false;
- var showRollOvers = true;
- function LabelViewer()
- {
- super();
- }
- function loadContent(url)
- {
- trace("loadContent:" + url);
- this.xml_loader.load(url);
- }
- function sound_press(evt)
- {
- trace("sound_press");
- this.soundPlayer.loadSound(this.base_url + evt.target.audio,true);
- this.soundPlayer.setVolume(_global.user_volume * 2);
- }
- function sound_load(success)
- {
- trace("sound_loaded: " + success);
- }
- function xml_loaded(success)
- {
- if(success)
- {
- trace("success");
- if(this.xml_loader.status == 0)
- {
- this.base_url = this.xml_loader.firstChild.attributes.base_url != undefined ? this.xml_loader.firstChild.attributes.base_url : "";
- trace("XML Loaded");
- this.image_array = [];
- var _loc5_ = 0;
- while(_loc5_ < this.xml_loader.firstChild.childNodes.length)
- {
- if(this.xml_loader.firstChild.childNodes[_loc5_].nodeName == "image")
- {
- var _loc4_ = {};
- _loc4_.index = this.image_array.length;
- _loc4_.image_url = this.xml_loader.firstChild.childNodes[_loc5_].attributes.image_url;
- _loc4_.image_id = this.xml_loader.firstChild.childNodes[_loc5_].attributes.image_id;
- _loc4_.hotspot_array = [];
- var _loc6_ = 0;
- while(_loc6_ < this.xml_loader.firstChild.childNodes[_loc5_].childNodes.length)
- {
- var _loc2_ = this.xml_loader.firstChild.childNodes[_loc5_].childNodes[_loc6_];
- switch(_loc2_.nodeName)
- {
- case "instructions":
- _loc4_.instructions = _loc2_.firstChild.nodeValue;
- break;
- case "caption":
- _loc4_.caption = _loc2_.firstChild.nodeValue;
- break;
- case "hotspot":
- var _loc3_ = new com.argosy.ui.LabelHotSpot();
- _loc3_.id = _loc2_.attributes.id;
- _loc3_.color = _loc2_.attributes.color;
- _loc3_.audio = _loc2_.attributes.audio;
- _loc3_.type = _loc2_.attributes.type;
- _loc3_.label = _loc2_.firstChild.nodeValue;
- _loc3_.addEventListener("press",this,"sound_press");
- _loc4_.hotspot_array.push(_loc3_);
- }
- _loc6_ = _loc6_ + 1;
- }
- this.image_array.push(_loc4_);
- }
- _loc5_ = _loc5_ + 1;
- }
- }
- else
- {
- trace("XML Parse Error: " + this.xml_loader.status);
- }
- }
- else
- {
- trace("XML Can\'t Load");
- }
- this.loadImage(this.image_array[0]);
- }
- function loadNextNumber()
- {
- this.loadImageNumber(this.current_image.index + 1);
- }
- function loadLastNumber()
- {
- this.loadImageNumber(this.current_image.index - 1);
- }
- function loadImageNumber(image_num)
- {
- trace("loadImageNumber: " + image_num);
- if(image_num < 0)
- {
- image_num = this.image_array.length - 1;
- }
- else if(image_num >= this.image_array.length)
- {
- image_num = 0;
- }
- trace("loadImageNumber_2: " + image_num);
- this.loadImage(this.image_array[image_num]);
- }
- function loadImage(image_obj)
- {
- trace("labelViewer: loadImage - " + image_obj.index);
- this.current_image = image_obj;
- this.image_holder = this.createEmptyMovieClip("image_holder",100);
- this.image_holder._x = 225;
- this.image_holder._y = 5;
- this.image_loader.loadClip(this.base_url + this.current_image.image_url,this.image_holder);
- this.image_holder.setMask(this.mask);
- this.image_holder._visible = false;
- this.caption_tf.htmlText = "<p><caption>" + this.current_image.caption + "</caption></p>";
- this.instructions_tf.htmlText = "<p><instruction>" + this.current_image.instructions + "</instruction></p>";
- this.location_tf.htmlText = "<p><location>Image " + (image_obj.index + 1) + " out of " + this.image_array.length + "</location></p>";
- this.layout();
- this.setLabelButton(false);
- }
- function setLabelButton(b)
- {
- this.showAllLabels = b;
- if(this.showAllLabels)
- {
- this.view_labels_button._visible = false;
- this.hide_labels_button._visible = true;
- }
- else
- {
- this.view_labels_button._visible = true;
- this.hide_labels_button._visible = false;
- }
- for(var _loc2_ in this.current_image.hotspot_array)
- {
- this.current_image.hotspot_array[_loc2_].showLabels = this.showAllLabels;
- }
- }
- function findHotSpots(mc)
- {
- trace("findHotSpots");
- for(var _loc3_ in mc)
- {
- mc[_loc3_]._visible = false;
- }
- for(_loc3_ in this.current_image.hotspot_array)
- {
- this.current_image.hotspot_array[_loc3_].graphic = this.image_holder["hs_" + this.current_image.hotspot_array[_loc3_].id];
- this.current_image.hotspot_array[_loc3_].graphic._visible = true;
- }
- this.image_holder._visible = true;
- }
- function init()
- {
- trace("Label Viewer");
- this.image_loader = new MovieClipLoader();
- this.image_loader.addListener(this);
- this.xml_loader = new XML();
- this.xml_loader.ignoreWhite = true;
- this.xml_loader.onLoad = ascb.util.Proxy.create(this,this.xml_loaded);
- this.soundPlayer = new Sound();
- this.soundPlayer.onLoad = ascb.util.Proxy.create(this,this.sound_load);
- if(com.argosy.ui.LabelViewer.label_style == undefined)
- {
- com.argosy.ui.LabelViewer.label_style = new TextField.StyleSheet();
- com.argosy.ui.LabelViewer.label_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#999999",textAlign:"left",textDecoration:"none",kerning:"true",letterSpacing:"0"});
- com.argosy.ui.LabelViewer.label_style.setStyle("caption",{fontSize:"14",color:"#999999",textAlign:"right"});
- com.argosy.ui.LabelViewer.label_style.setStyle("instruction",{fontFamily:"Frutiger",fontSize:"12",color:"#000000",textAlign:"left",marginLeft:"10",marginRight:"10"});
- com.argosy.ui.LabelViewer.label_style.setStyle("location",{fontSize:"9",color:"#000000",textAlign:"center"});
- }
- super.init();
- }
- function createChildren()
- {
- this.bg = this.createEmptyMovieClip("bg",1);
- this.mask = this.createEmptyMovieClip("mask",2000);
- this.caption_tf = this._createTextField(this,"caption_tf",300,this.uiPanelWidth,0,this.width - this.uiPanelWidth - 10,20,com.argosy.ui.LabelViewer.label_style,"");
- this.uiPanel = this.createEmptyMovieClip("uiPanel",2);
- this.button_holder = this.uiPanel.createEmptyMovieClip("button_holder",1);
- this.back_button = this.button_holder.attachMovie("back_button","back_button",1);
- this.next_button = this.button_holder.attachMovie("next_button","next_button",2);
- this.next_button.onRelease = ascb.util.Proxy.create(this,this.loadNextNumber);
- this.back_button.onRelease = ascb.util.Proxy.create(this,this.loadLastNumber);
- this.location_tf = this._createTextField(this.button_holder,"location_tf",3,0,10,this.uiPanelWidth,20,com.argosy.ui.LabelViewer.label_style,"");
- this.instructions_tf = this._createTextField(this.uiPanel,"instructions_tf",3,0,10,this.uiPanelWidth,10,com.argosy.ui.LabelViewer.label_style,"");
- this.instructions_tf.multiline = true;
- this.instructions_tf.wordWrap = true;
- this.instructions_tf.autoSize = true;
- this.view_labels_button = this.uiPanel.attachMovie("view_labels","view_labels_button",4);
- this.hide_labels_button = this.uiPanel.attachMovie("hide_labels","hide_labels_button",5);
- this.view_labels_button.onRelease = ascb.util.Proxy.create(this,this.setLabelButton,true);
- this.hide_labels_button.onRelease = ascb.util.Proxy.create(this,this.setLabelButton,false);
- this.load_bar = this.attachMovie("LoadBar","load_bar",200);
- this.layout();
- this.setLabelButton(false);
- }
- function layout()
- {
- this.bg.clear();
- this.bg.beginFill(16777215,100);
- this.bg.lineTo(this.width,0);
- this.bg.lineTo(this.width,this.height);
- this.bg.lineTo(0,this.height);
- this.bg.lineTo(0,0);
- this.bg.endFill();
- this.mask.clear();
- this.mask.lineStyle(0,16711680,0);
- this.mask.beginFill(16711680,0);
- this.mask.moveTo(this.uiPanelWidth,0);
- this.mask.lineTo(this.width - 1,0);
- this.mask.lineTo(this.width - 1,this.height - 1);
- this.mask.lineTo(this.uiPanelWidth,this.height - 1);
- this.mask.lineTo(this.uiPanelWidth,0);
- this.mask.endFill();
- this.uiPanel.clear();
- var _loc2_ = new flash.geom.Matrix();
- _loc2_.createGradientBox(this.uiPanelWidth,this.height,1.5707963267948966,0,0);
- this.uiPanel.beginGradientFill("linear",[14409183,10856103],[100,100],[0,255],_loc2_,"pad");
- this.uiPanel.lineTo(this.uiPanelWidth,0);
- this.uiPanel.lineTo(this.uiPanelWidth,this.height);
- this.uiPanel.lineTo(0,this.height);
- this.uiPanel.lineTo(0,0);
- this.uiPanel.endFill();
- this.uiPanel.lineStyle(0,6710886,100);
- this.uiPanel.moveTo(0,0);
- this.uiPanel.lineTo(this.uiPanelWidth,0);
- this.uiPanel.lineTo(this.uiPanelWidth,this.height);
- this.uiPanel.lineTo(0,this.height);
- this.uiPanel.lineTo(0,0);
- this.view_labels_button._x = this.uiPanelWidth / 2;
- this.view_labels_button._y = this.instructions_tf._y + this.instructions_tf._height + this.view_labels_button._height / 2 + 20;
- this.hide_labels_button._x = this.uiPanelWidth / 2;
- this.hide_labels_button._y = this.instructions_tf._y + this.instructions_tf._height + this.hide_labels_button._height / 2 + 20;
- this.back_button._x = this.back_button._width;
- this.next_button._x = this.back_button._x + this.back_button._width + 20;
- this.location_tf._y = this.next_button._y + this.next_button._height + 10;
- this.location_tf._width = this.next_button._x + this.next_button._width;
- this.button_holder._y = this.height - this.button_holder._height - 10;
- this.button_holder._x = this.uiPanelWidth / 2 - this.button_holder._width / 2;
- this.load_bar._x = this.uiPanelWidth + (this.width - this.uiPanelWidth) / 2 - this.load_bar.width / 2;
- this.load_bar._y = this.height / 2 - this.load_bar.height / 2;
- }
- function onLoadInit(target_mc)
- {
- trace("onLoadInit");
- this.image_holder.setMask(this.mask);
- this.findHotSpots(target_mc);
- }
- function onLoadStart(target_mc)
- {
- }
- function onLoadError(target_mc, errorCode)
- {
- trace("onLoadError: " + errorCode);
- }
- function onLoadProgress(target_mc, loadedBytes, totalBytes)
- {
- this.load_bar.text = "Loading Image";
- this.load_bar.percent = loadedBytes / totalBytes;
- }
- function onLoadComplete(target_mc)
- {
- }
- }
-