The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Flash
  • ActionScript
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Flash
 ActionScript

  • rlayte Author 
    • 890 
    • 0 
    • 1 
    Problems with external css
    delizade

    Last reply Oct 22 2008, 07:51 AM

    by delizade

    Posted: Apr 06 2008, 07:34 AM

    by rlayte

     

Hi,

I’m trying to style a textfield using an external css file. All of the tutorials and previous forum posts I’ve found seem to suggest the same method, which I think I have followed correctly. However, it doesn’t seem to work for some reason.

Actioscript code:

package {

  import flash
.display.Sprite;
  
import flash.text.TextField;
  
import flash.events.Event;
  
import flash.text.TextFieldAutoSize;
  
import flash.text.StyleSheet;
  
import flash.net.URLLoader;
  
import flash.net.URLRequest;

  public class 
cssText extends Sprite {
      
    
private var loader:URLLoader = new URLLoader(  );
    private var 
field:TextField = new TextField(  );
      
    public function 
cssText():void {
         loader
.addEventListener(Event.COMPLETE, onLoadCSS);
         var 
cssFile:URLRequest = new URLRequest("test.css");
         
loader.load(cssFile);
    
}
    
    
private function onLoadCSS(event:Event):void {
      
var css:StyleSheet = new StyleSheet();
      
css.parseCSS(URLLoader(event.target).data);
      
         
field.autoSize = TextFieldAutoSize.LEFT;
         
field.wordWrap = true;
         
field.width = 200;
         
addChild(field);
         
field.styleSheet = css;
         
field.htmlText ="<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec pretium mauris nec justo. Vestibulum tellus. Nulla euismod nibh vitae lorem. Ut ut sapien. Maecenas viverra urna non tellus. Curabitur ultricies lorem quis diam. Sed est lectus, gravida sed, placerat non, sagittis id, leo. Nullam ligula dolor, interdum sit amet, sodales ut, condimentum eu, dui.</p>";
   
}
  }
} 

CSS:

@charset “utf-8”;
/* CSS Document */

p
{
      font-size: 24px;
font-family: Arial, Helvetica, sans-serif;
color: #ff0000;
text-align:left;
}

I really hope it’s something simple I’ve overlooked, but I just can’t seem to figure it out. Any help would be greatly appreciated.

  1 REPLY
 
delizade
1  
delizade

first of all, i didnt look at your code but strngly I can tel that DO NOT use
@charset “utf-8”;
/* CSS Document */

in your CSS file. it is a problem in As3 parser.

  • 22 October 2008 07:51 AM
  •  
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 779  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,728  Assets
  • Profiles 282,755  Members
  • Topics 93,776  Topics
  • Blog 4  Blog
  • Facebook 1,679  Facebook
  • Twitter 1,163  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Sun, February 12, 2012 - 1:56:27