home *** CD-ROM | disk | FTP | other *** search
- class TextPage extends mx.core.UIObject
- {
- var __title;
- var __body;
- var dispatchEvent;
- static var symbolName = "TextPage";
- static var symbolOwner = TextPage;
- var className = "TextPage";
- static var version = "0.0.0.1";
- static var __maxPageHeight = 376;
- static var __pageBorder = 5;
- static var __vSpacing = 5;
- static var __hSpacing = 5;
- var __nextDepth = 1;
- function TextPage()
- {
- super();
- mx.events.EventDispatcher.initialize(this);
- }
- function set enabled(activeStatus)
- {
- if(activeStatus == true)
- {
- var _loc2_ = new TextFormat();
- _loc2_.color = 0;
- var _loc3_ = "<headline>" + this.__title.htmlText.slice(18,this.__title.htmlText.length - 19) + "</headline>";
- this.__title.setTextFormat(_loc2_);
- this.__title.setNewTextFormat(_loc2_);
- this.__title.htmlText = _loc3_;
- }
- else
- {
- _loc2_ = new TextFormat();
- _loc2_.color = 8421504;
- _loc3_ = "<headlinedisabled>" + this.__title.htmlText.slice(10,this.__title.htmlText.length - 11) + "</headlinedisabled>";
- this.__title.setTextFormat(_loc2_);
- this.__title.setNewTextFormat(_loc2_);
- this.__title.htmlText = _loc3_;
- }
- this.__body.enabled = activeStatus;
- this.__body.label.selectable = false;
- }
- function init(Void)
- {
- super.init();
- }
- function size(Void)
- {
- super.size();
- }
- function doneSetting()
- {
- this.sendMessage("pageReady");
- }
- function set title(newTitle)
- {
- function workingLayout(bodyText, width, targetObject)
- {
- trace("targetObject: " + targetObject);
- var titleFormat = _level0.styleSheetToTextFormat(_global.textStyles.getStyle("headline"));
- targetObject.html = true;
- with(targetObject)
- {
- embedFonts = true;
- setTextFormat(titleFormat);
- setNewTextFormat(titleFormat);
- styleSheet = _global.textStyles;
- border = false;
- selectable = false;
- autoSize = true;
- borderColor = 13421772;
- multiline = true;
- wordWrap = true;
- }
- var oneRowMetrics = titleFormat.getTextExtent("a",width);
- var twoRowMetrics = titleFormat.getTextExtent("a\na",width);
- var tfhIncrement = twoRowMetrics.textFieldHeight - oneRowMetrics.textFieldHeight;
- var metrics = titleFormat.getTextExtent(bodyText,width);
- var finalHtmlText = "<headline><textformat leading=\'" + myLeading + "\'>" + bodyText + "</textformat></headline>";
- targetObject.htmlText = finalHtmlText;
- var positiveLeading = myLeading >= 0 ? myLeading : - myLeading;
- var calculatedHeight = targetObject._height;
- targetObject.autoSize = false;
- targetObject._height = metrics.textFieldHeight + 1;
- targetObject.htmlText = "<headline><textformat leading=\'0\'>" + bodyText + "</textformat></headline>";
- var unleadedTextHeight1 = targetObject.textHeight;
- var unleadedFieldHeight = targetObject._height;
- targetObject.htmlText = "<headline><textformat leading=\'-1\'>" + bodyText + "</textformat></headline>";
- var unleadedTextHeight2 = targetObject.textHeight;
- var numRows = unleadedTextHeight2 - unleadedTextHeight1;
- numRows = numRows >= 0 ? numRows : - numRows;
- trace("numRows of text: " + numRows);
- targetObject.htmlText = finalHtmlText;
- trace("FINAL TEXTPAGE TITLE: " + finalHtmlText);
- targetObject._height = 38;
- }
- this.createTextField("__title",this.__nextDepth,TextPage.__pageBorder,TextPage.__pageBorder,540,50);
- this.__nextDepth = this.__nextDepth + 1;
- var myLeading = -5;
- var titleFormat = _level0.styleSheetToTextFormat(_global.textStyles.getStyle("headline"));
- workingLayout(newTitle,365,this.__title);
- }
- function set body(bodyText)
- {
- trace("----- TextPage.body -----");
- if(this.__body == undefined)
- {
- this.__body = this.createClassObject(mx.controls.TextArea,"primaryDesc",this.__nextDepth);
- this.__body.editable = false;
- this.__body.label.selectable = false;
- this.__body.wordWrap = true;
- this.__body.borderStyle = "none";
- this.__body.html = true;
- this.__body.embedFonts = true;
- this.__body.styleSheet = _global.textStyles;
- this.__body.setStyle("styleName","scrollTextAreaStyle");
- this.__body.vSB.setStyle("themeColor","0x990000");
- this.__nextDepth = this.__nextDepth + 1;
- }
- if(this.__body.text != bodyText)
- {
- this.__body.text = "<pagebody>" + bodyText + "</pagebody>";
- this.__body._x = TextPage.__pageBorder;
- this.__body._y = this.__title._y + this.__title._height + 2 * TextPage.__vSpacing - 12;
- this.__body.setSize(550,TextPage.__maxPageHeight);
- }
- trace("----- end of TextPage.body -----");
- }
- function removeHTMLTags(htmlText)
- {
- var _loc6_ = function(txt, index)
- {
- return txt.indexOf("<",index);
- };
- var _loc8_ = function(txt, index)
- {
- return txt.indexOf(">",index);
- };
- var _loc2_ = new Array();
- var _loc7_ = 0;
- var _loc9_ = undefined;
- var _loc10_ = undefined;
- while(_loc7_ < htmlText.length)
- {
- _loc9_ = _loc6_(htmlText,_loc7_);
- if(_loc9_ == -1)
- {
- break;
- }
- _loc10_ = _loc8_(htmlText,_loc9_);
- var _loc3_ = _loc6_(htmlText,_loc10_);
- while(_loc3_ == _loc10_ + 1)
- {
- _loc10_ = _loc8_(htmlText,_loc3_);
- _loc3_ = _loc6_(htmlText,_loc10_);
- }
- _loc2_.push({start:_loc9_,end:_loc10_});
- _loc7_ = _loc10_ + 1;
- }
- var _loc5_ = 0;
- while(_loc5_ < _loc2_.length)
- {
- _loc9_ = _loc2_[_loc5_].start;
- var _loc11_ = htmlText.charAt(_loc2_[_loc5_].start);
- _loc10_ = _loc2_[_loc5_].end;
- var _loc12_ = htmlText.charAt(_loc2_[_loc5_].end);
- var _loc16_ = htmlText.substring(_loc9_ + 1,_loc10_);
- _loc5_ = _loc5_ + 1;
- }
- if(_loc2_.length != 0)
- {
- var _loc18_ = "";
- if(_loc2_[0].start > 0)
- {
- _loc18_ += htmlText.substring(0,_loc2_[0].start);
- }
- var _loc4_ = 0;
- while(_loc4_ < _loc2_.length - 1)
- {
- var _loc13_ = _loc2_[_loc4_].end + 1;
- var _loc15_ = _loc2_[_loc4_ + 1].start;
- _loc18_ += htmlText.substring(_loc2_[_loc4_].end + 1,_loc2_[_loc4_ + 1].start);
- _loc4_ = _loc4_ + 1;
- }
- if(_loc2_[_loc2_.length - 1].end < htmlText.length - 1)
- {
- _loc18_ += htmlText.substring(_loc2_[_loc2_.length - 1].end + 1);
- }
- return _loc18_;
- }
- return htmlText;
- }
- function sendMessage(p_msgtxt)
- {
- var _loc2_ = {target:this,type:"pageReady"};
- _loc2_.msgtxt = p_msgtxt;
- _loc2_.pageType = "TextPage";
- this.dispatchEvent(_loc2_);
- }
- }
-