www.webdeveloper.com
Results 1 to 5 of 5

Thread: How do you style xml with css in Flash AS3

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    8

    How do you style xml with css in Flash AS3

    Hey everybody,
    I wanted to know how to link an external css file in your actionscript to style xml data that is being loaded into flash.
    I couldn't find anything on this online. Any help would be greatly appreciated.

    Thank you!

  2. #2
    Join Date
    Nov 2006
    Location
    Springfield, MO
    Posts
    1,541
    In Flash 8 with AS2, one could take this approach:

    Code:
    //load css
    var ss=new TextField.StyleSheet();
    ss.onLoad=function(){
    	businessmarketing.businessmarketingText_txt.styleSheet=ss;
    }
    ss.load("tour.css");
    You essentially create a style sheet object.

    Code:
    //load XML
    var data_xml=new XML();
    data_xml.ignoreWhite=true;
    data_xml.onLoad=function(){
    		businessmarketing.businessmarketingText_txt.htmlText=this.firstChild.firstChild.nodeValue;
    businessmarketing.businessmarketingText_txt._height=businessmarketing.businessmarketingText_txt.textHeight;
    }
    data_xml.load("businessmarketing/businessmarketingText.xml");
    You create an XML object. Though it looks odd to load the xml file after the onload call, it's because action script is asynchronous and events don't always happen sequentially, therefore, you load the xml file outside the onLoad call to ensure there's some data to show in the text box.

    Path's can get tricky when targeting the XML file for the text boxes, but the code is solid. Whew, it's been awhile for Action script coding.
    Ryan Butler

    Ryan Butler.org

  3. #3
    Join Date
    Apr 2008
    Posts
    8
    Hey Ryan,
    Thanks for the reply. However I am working with AS3. Could you point me in the right direction with this?
    Thanks

  4. #4
    Join Date
    Nov 2006
    Location
    Springfield, MO
    Posts
    1,541
    Are there huge syntactical differences b/w AS 2 & 3? The whole reason I posted that was I thought the differences would be minimal and it would work. Have you tried it to see if it even works?
    Ryan Butler

    Ryan Butler.org

  5. #5
    Join Date
    May 2008
    Posts
    1

    need a help from ryan

    Quote Originally Posted by ryanbutler
    Are there huge syntactical differences b/w AS 2 & 3? The whole reason I posted that was I thought the differences would be minimal and it would work. Have you tried it to see if it even works?
    i would like to know if i have more than 3 dynamic text field how can i attached CSS Style sheet

    thanx ryan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles