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

    Loading External Stylesheet

      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.

      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;
      } else {
      aboutUs_text.htmlText = "Could not load CSS stylesheet.";
      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.";
        • 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 -
          Adobe Community Expert

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

            Dave -
            Adobe Community Expert

            • 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.htmlText = this.Content;

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