Zurück   Flashforum > Flash > ActionScript > ActionScript 2

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 25-10-2011, 19:00   #1 (permalink)
Balkan Boris
 
Benutzerbild von marconi
 
Registriert seit: Mar 2007
Beiträge: 283
Dynamisches Textfeld mit XML und CSS

Ciao zusammen,

ich möchte zwei dynamische Textfelder über eine XML-Datei befüllen und den Text mit einer CSS-Datei formatieren.
Nach mehreren Tutorials will es leider immer noch nicht funktionieren. Es scheint Probleme mit den eingebetteten Fonts zu geben und
und jeweils die beiden Einträge "<headline>This will be the headline.</headline>" und "<copytext>Here could be copytext.</copytext>"
aus der XML-Datei in jeweils ein Textfeld zu laden.

as2
PHP-Code:
//load XML
xmlData = new XML();
xmlData.ignoreWhite true;
xmlData.onLoad loadXML;
xmlData.load("txt.xml");

//load css
import TextField.StyleSheet;
cssTxtField = new TextField.StyleSheet();
cssTxtField.load("txt.css");
txt_field_1.styleSheet cssTxtField;
txt_field_2.styleSheet cssTxtField;

//init TextArea component
txt_field_1.html true;
txt_field_1.wordWrap true;
txt_field_1.multiline true;
txt_field_1.condenseWhite true;
txt_field_1.autoSize true;
txt_field_1.embedFonts true;

txt_field_2.html true;
txt_field_2.wordWrap true;
txt_field_2.multiline true;
txt_field_2.condenseWhite true;
txt_field_2.autoSize true;
txt_field_2.embedFonts true;

function 
loadXML(loaded) {
    if (
loaded) {
        
txt_field_1.htmlText this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
        
txt_field_2.htmlText this.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue;
    } else {
        
content "file not loaded!";
    }

xml
PHP-Code:
<?xml version="1.0" encoding="UTF-8"?>

<data>
    <txt_field_1>
        <headline>This will be the headline.</headline>
        <copytext>Here could be copytext.</copytext>
    </txt_field_1>
    <txt_field_2>
        <headline>This will be the headline.</headline>
        <copytext>Here could be copytext.</copytext>
    </txt_field_2>
</data>
css
PHP-Code:
headline {
  
color#ffffff;
  
font-familyGotham;
  
font-size13px;
}
copytext {
  
color#000000;
  
font-familyMenlo;
  
font-size11px;

Die Fonts liegen in der Bibliothek mit folgenden Eigenschaften:
Angehängte Grafiken
Dateityp: png font.png (77,6 KB, 2x aufgerufen)
__________________
Unbekannt verzogen (Heute um 03:44 Uhr)

Geändert von marconi (25-10-2011 um 19:36 Uhr)
marconi ist offline   Mit Zitat antworten
Alt 25-10-2011, 19:55   #2 (permalink)
+ Zimt & Zucker
 
Registriert seit: Mar 2006
Ort: hinterm Mond gleich links
Beiträge: 2.041
Direkt nach dem load() Befehl muss der style noch nicht geladen sein. -> onLoad
Flash CS4 Professional ActionScript 2.0

Was lässt dich vermuten, das es an den fonts liegt?
__________________
anbei Grüße vom milchreis: Viva la [Silb]
"Selbst wenn uns nur noch der Zynismus treibt, wir werden trotzdem einfach immer weiter gehen!"

[Von null auf Flash in einem Klick.] <<< klick

Geändert von milchreis (25-10-2011 um 19:57 Uhr)
milchreis ist offline   Mit Zitat antworten
Alt 25-10-2011, 20:08   #3 (permalink)
Balkan Boris
 
Benutzerbild von marconi
 
Registriert seit: Mar 2007
Beiträge: 283
Ciao milchreis,

tut mir leid, dass du dich jetzt bemüht hast: Ich hab es gerade doch hinbekommen!

Danke

Es lag erstens daran, dass ich das mit dem "child" doch nicht ganz verstanden hatte und mein XML-Aufbau falsch war:

as2
PHP-Code:
function loadXML(loaded) {
    if (
loaded) {
        
txt_field_1.htmlText this.firstChild.childNodes[0].firstChild.nodeValue;
        
txt_field_2.htmlText this.firstChild.childNodes[1].firstChild.nodeValue;
    } else {
        
content "file not loaded!";
    }

xml
PHP-Code:
<?xml version="1.0" encoding="UTF-8"?>

<data>
    <txt_field_1>
        <![CDATA[<headline>This will be the headline.</headline>
        <copytext>Here could be copytext.</copytext>]]>
    </txt_field_1>
    <txt_field_2>
        <![CDATA[<headline>This will be the headline.</headline>
        <copytext>Here could be copytext.</copytext>]]>
    </txt_field_2>
</data>
__________________
Unbekannt verzogen (Heute um 03:44 Uhr)
marconi ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
eingabe textfeld und dynamisches textfeld kollidieren bzgl html-format modul47 ActionScript 1 4 10-04-2008 15:59
dynamisches Textfeld difi ActionScript 1 0 27-08-2007 22:27
dynamisches Textfeld PsychoFlasher ActionScript 1 4 12-10-2005 15:09
2. dynamisches Textfeld nach Mouseover beim 1. Dynam. Textfeld Brinkybill ActionScript 1 1 09-06-2003 20:39
dynamisches Menü, loadMovieNum, dynamisches textfeld sweetpain ActionScript 1 3 24-02-2003 11:15


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:48 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele