3 Replies Latest reply on Mar 31, 2009 6:22 AM by Roxie_

    Loading External Stylesheet

    Roxie_
      First off, i wasnt sure where to post this cause im not sure if its ActionScript 1 or 2 or 3 even. Im not even sure if im qualified to call myself beginner in Actionscript...
      So, I found this tutorial online to load a external stylesheet to then load some text content in your box.
      http://flash-forum.flashdevils.com/showthread.php?threadid=189981

      I applied it to my site but its not working! My settings are as follows
      stylesheet = saved under styles/flashStyles.css
      text = saved under text/aboutus.txt
      Dynamic box = named aboutUs_text
      Here is my code, i have no clue what im doing wrong. The only thing i keep seeing is 'Could not load CSS stylesheet' when i preview my .swf or when i upload it to my server.

      function getNewsStyles() {
      aboutUs_text.text = "Getting news...";
      // load stylesheet first, then get content (separate function)
      var flash_css = new TextField.StyleSheet();
      flash_css.onLoad = function(success:Boolean) {
      if (success) {
      aboutUs_text.styleSheet = flash_css;
      getNewsContent();
      } else {
      aboutUs_text.htmlText = "Could not load CSS stylesheet.";
      }
      };
      flash_css.load("styles/flashStyles.css");
      };
      function getNewsContent() {
      aboutUs_text.htmlText = "Gathering news...";
      // stylesheet loaded and applied, get content
      var aboutUs_lv:LoadVars = new LoadVars();
      aboutUs_lv.onLoad = function(src:String):Void {
      if (src != undefined) {
      aboutUs_text.scroll = 1;
      aboutUs_text.htmlText = aboutUs_lv.currData;
      } else {
      aboutUs_text.htmlText = "Unable to gather news.";
      }
      };
      aboutUs_lv.load("text/aboutus.txt");
      }
      getNewsStyles();
        • 1. Re: Loading External Stylesheet
          Level 7
          The code works fine for me... so I'd guess it has to be the formatting of
          your stylesheet. Did you use Dreameaver to make a new CSS doc - and does
          that doc start with '@ charset "utf-8"' ? Remove that line...

          --
          Dave -
          www.offroadfire.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: Loading External Stylesheet
            Level 7
            PS - that's AS2

            --
            Dave -
            www.offroadfire.com
            Adobe Community Expert
            http://www.adobe.com/communities/experts/


            • 3. Re: Loading External Stylesheet
              Roxie_ Level 1
              Nope! i have nothing in my styleesheet besides styles!
              Ok i was playing around with my styles and i deleted my link styles and it seemed to work on my other pages. So now im gonna go back and get my original coding and applying it to my aboutUs page since now, my stylesheet seems to load but my text file doesnt....

              Just wondering and since i useless in actionscript, is it bad or can it cause problems to use different versions of actionscript in the same file?

              Here is the orignal code i was using, which seems to be working. To load my text file:
              myData = new LoadVars();
              myData.onLoad = function() {
              home_text.html=true;
              home_text.htmlText = this.Content;
              };
              myData.load("text/home.txt");

              To load my stylesheet:
              var style_sheet = new TextField.StyleSheet();
              var css_url = "styles/flashStyles.css";
              style_sheet.load(css_url);
              home_news_text.styleSheet = style_sheet;
              home_text.styleSheet = style_sheet;