l'Audiophile
Threadersteller
Dabei seit: 16.09.2004
Ort: Berlin
Alter: 43
Geschlecht:
|
Verfasst Di 13.06.2006 14:05
Titel [Flash How To] HTMLText aus externer XML per CSS formatieren |
|
|
Kurz und schmerzlos ne kleine Linkliste, deren Daten aus einer XML geliefert werden und totz Embed Fonts beliebig per CSS formatiert werden können. Ausnahmsweise gehts heute mal nicht um Actionscript.
ANSCHAUEN
Die einzelnen Schritte:
I. Das Herzstück – die Schrift einbinden
Wichtig: Wenn man verschiedene Schriftschnitte (bold, italic …) darstellen will, muss man natürlich auch sämtliche Schnitte einbinden.
optionaler Kram (XML und AS sind nur da um das ganze zu testen):
II. XML
Code: |
<text>
<![CDATA[<h1>LINKLISTE</h1><br></br><br></br><a href="http://www.designerinaction.de" target="_blank">www.designerinaction.de</a><br></br><p>das deutsche designportal</p><br></br><a href="http://www.dasauge.de" target="_blank">www.dasauge.de</a><br></br><p>jobportal für kreative</p><br></br><a href="http://www.distinctstyles.com/" target="_blank">www.distinctstyles.com</a><br></br><p>sehr gut sortiertes, deutsches design-link-portal</p><br></br><a href="http://www.designerstoolbox.com" target="_blank">www.designerstoolbox.com</a><br></br><p>the american designers resource</p><br></br><a href="http://www.surfstation.lu/" target="_blank">www.surfstation.lu</a><br></br><p>design-portal aus luxembourg</p><br></br><a href="http://www.resrc.de" target="_blank">www.resrc.de</a><br></br><p>deutsches designportal mit sehr umfangreichen linkverzeichnis</p><br></br><a href="http://www.net-folio.de/" target="_blank">www.net-folio.de</a><br></br><p>Die Design Liga. Ein deutsches Portfolio-Portal.</p><br></br><a href="http://www.augensound.de/" target="_blank">www.augensound.de</a><br></br><p>Künstlerportal</p><br></br><a href="http://www.cidoc.net/" target="_blank">www.cidoc.net</a><br></br><p>a coorperate identity documentation</p><br></br><a href="http://www.pixelmaniax.de/" target="_blank">www.pixelmaniax.de</a><br></br><p>insperation.link.pool</p><br></br><br></br><br></br><br></br><br></br><br></br><br></br><br></br><br></br>
]]>
</text>
|
II. AS (wie immer in AS 1, der Kompatibilität halber )
Code: |
System.useCodePage = true;
/*############################################ TEXTBUILDER KLASSE ##################################################*/
function Textbuilder() {
// Methode "createText"
Textbuilder.prototype.createText = function(pFn, pD, pX, pY, pH, pW, pType, pSelect, pEF, pF, pFs, pHTML, pAs, pMl, pWw, pL, pAAT, pGFT, pT, pS, pA, pRot, pBg, pBgC, pB, pBC, pMC, pR, pTE, pTI, pVar, pCont) {
textfield = createTextField(pFn, Number(pD), pX, pY, pW, pH);
var infoTextFormat = new TextFormat();
infoTextFormat.font = pF;
infoTextFormat.size = pFs;
infoTextFormat.leading = pL;
textfield.setNewTextFormat(infoTextFormat);
// CSS Kram
var xml_style = new TextField.StyleSheet();
with (xml_style) {
setStyle("a:link", {color:'#3399CC'});
setStyle("p", {color:'#FFFF00'});
setStyle("H1", {color:'#FFFFFF'});
}
textfield.styleSheet = xml_style;
// Ende CSS Kram
with (textfield) {
html = pHTML;
type = pType;
selectable = pSelect;
antiAliasType = pAAT;
gridFitType = pGFT;
thickness = pT;
sharpness = pS;
multiline = pMl;
border = Number(pB);
borderColor = pBC;
background = Number(pBg);
backgroundColor = pBgC;
autoSize = pAs;
htmlText = pCont;
_alpha = pA;
_rotation = pRot;
maxChars = pMC;
restrict = pR;
tabEnabled = pTE;
tabIndex = pTI;
embedFonts = pEF;
wordWrap = pWw;
variable = pVar;
}
};
}
/*############################################ XML LADEN ##################################################*/
xml_text = new XML();
xml_text.ignoreWhite = true;
xml_text.load("xml/text.xml");
xml_text.onLoad = function(status) {
if (status) {
xmltext = xml_text.firstChild.childNodes[0].nodeValue;
this.textbuilder = new Textbuilder();
this.textbuilder.createText("XMLtext", 0, 50, 50, 400, 400, "dynamic", false, true, "pixelfont", 8, true, "left", true, true, 2, advanced, pixel, -200, +400, 100, 0, 0, 0x000000, 0, 0x000000, 0, "", false, 0, loaderfield, xmltext);
} else {
trace("xml-daten konnten nicht geladen werden.");
}
};
stop();
|
Das wars auch schon.
|
|