Flash und CSS

  • geschlossen

  • blizzard.3
  • 969 Aufrufe 3 Antworten

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Flash und CSS

    Hi Leute,

    ich hab ein Problem undzwar...

    wie kann ich in ein Textfeld den Text aus einer Datei dort reinladen und gleichzeitig mit einem CSS Style versehen ?

    Also das reinladen hab ich jetzt schonmal hinbekommen. Und was zu dem CSS hab ich auch gefunden, aber es funktioniert noch nicht beides auf einmal.

    Diesen Code hab ich für den CSS Style gefunden....

    Quellcode

    1. //Create a new style sheet object
    2. var myCSS = new TextField.StyleSheet();
    3. //Specify the location of the CSS file that you created earlier
    4. var cssURL = "example.css";
    5. //Hard code some HTML text to display (for example purposes)
    6. exampleText = "<p class='headline'>Tutorial Takes Forever To Write</p>";
    7. exampleText += "<p><span class='byline'>Bath, UK</span>";
    8. exampleText += "--Flash developer NWebb seemed to take ";
    9. exampleText += "forever to finish his CSS-Flash tutorial, ";
    10. exampleText += "but it is finished now and you can find it ";
    11. exampleText += "<a href='http://www.nwebb.co.uk'>here</a> ";
    12. exampleText += "along with a few others.</p>";
    13. //Load CSS file
    14. myCSS.load(cssURL);
    15. //define onLoad handler
    16. myCSS.onLoad = function(success) {
    17. if (success) {
    18. /* If the style sheet loaded without error,
    19. assign it to the text object, and assign the HTML text to the
    20. text field*/
    21. myText.styleSheet = myCSS;
    22. myText.text = exampleText; //this should be ".htmlText",
    23. // but Flash seems to recognise that the textbox needs to display html anyway
    24. }
    25. };
    Alles anzeigen

    Aber wie man sieht, steht der Text in dem Code und nicht in einer Datei.

    Und den Code hab ich für die externe Textdatei gefunden ...

    Quellcode

    1. var loader:LoadVars = new LoadVars();
    2. loader.onLoad = function(test){
    3. if(test){
    4. myText.text = this.text1;
    5. }else{
    6. myText.text = 'Datei nicht gefunden';
    7. }
    8. };
    9. loader.load('exampleText.html');

    Ich hab jetzt schon versucht den Code irgendwie zusammen zu bekommen hat aber bis jetzt nicht geklappt.
    Vielleicht habt ihr ne Idee wie ich das machen kann ?!

    Danke schon mal !
    UP#1 UP#2 UP#3 UP#4
    UP#5
    rot = DOWN | [COLOR="Blue"]blau = ONLINE[/color]
  • Kann geschlossen werden !

    Hier die Lösung, falls es jemanden interessiert ....

    Quellcode

    1. //init TextArea component
    2. myText.html = true;
    3. myText.wordWrap = true;
    4. myText.multiline = true;
    5. myText.label.condenseWhite=true;
    6. //load css
    7. textStyle = new TextField.StyleSheet();
    8. textStyle.load("textstyle.css");
    9. myText.styleSheet = textStyle;
    10. textStyle = new TextField.StyleSheet();
    11. textStyle.load("textstyle.css");
    12. myText.styleSheet = textStyle;
    13. //load in XML
    14. textContent = new XML();
    15. textContent.ignoreWhite = true;
    16. textContent.load("text.xml");
    17. textContent.onLoad = function(success)
    18. {
    19. if(success)
    20. {
    21. myText.text = textContent;
    22. }
    23. }
    Alles anzeigen
    UP#1 UP#2 UP#3 UP#4
    UP#5
    rot = DOWN | [COLOR="Blue"]blau = ONLINE[/color]