
13-09-08, 14:43
|
|
Junior Member
|
|
Join Date: Jan 2008
Posts: 16
Rep Power: 0
|
|
|
Re: import html and css
|
|
Hi Guy
I found this which works perfectly
//************************************************** **************************
// Copyright (C) 2005-2007 Adobe Systems Incorporated. All Rights Reserved.
// The following is Sample Code and is subject to all restrictions on such code
// as contained in the End User License Agreement accompanying this product.
//************************************************** **************************
import fl.controls.UIScrollBar;
var my_txt:TextField = new TextField();
my_txt.x = 16;
my_txt.y = 50;
my_txt.wordWrap = true;
my_txt.multiline = true;
my_txt.width = 280;
my_txt.height = 178;
my_txt.background = true;
my_txt.backgroundColor = 0xFFFFFF;
addChild(my_txt);
var my_sb:UIScrollBar = new UIScrollBar();
my_sb.x = my_txt.x + my_txt.width;
my_sb.y = my_txt.y;
my_sb.height = my_txt.height;
my_sb.scrollTarget = my_txt;
addChild(my_sb);
//Note: Download the TXT and CSS files to look at their structure. Use the URLs below.
//load text
function loadMyText():void {
var url:String = "http://www.helpexamples.com/flash/text/sampletext.txt";
var loadIt:URLLoader = new URLLoader();
loadIt.addEventListener(Event.COMPLETE, textCompleteHandler);
loadIt.load(new URLRequest(url));
}
function textCompleteHandler(event:Event):void {
var urlV:URLVariables = new URLVariables(event.currentTarget.data);
my_txt.condenseWhite = true;
my_txt.htmlText = urlV.content as String;
my_txt.styleSheet = myStyleSheet;
}
//apply stylesheet
var flash_css:URLLoader = new URLLoader();
flash_css.addEventListener(Event.COMPLETE, cssCompleteHandler);
flash_css.load(new URLRequest("http://www.helpexamples.com/flash/text/styles.css"));
var myStyleSheet:StyleSheet;
function cssCompleteHandler(event:Event):void {
myStyleSheet = new StyleSheet();
myStyleSheet.parseCSS(event.currentTarget.data);
my_txt.styleSheet = myStyleSheet;
loadMyText();
} |
|