A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] CDATA and flash

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    11

    resolved [RESOLVED] CDATA and flash

    Hi there.

    i use a swf file to load html text through xml.
    The load text function at the .swf is this:
    Actionscript Code:
    function loadContentText () {
        var cont:XML = new XML ();
        cont.ignoreWhite = true;
        cont.onLoad = function (success) {
            if (success) {
                var root:XMLNode = this.firstChild;
                fullText = root.childNodes[0].childNodes[0].childNodes[0].nodeValue;

                contentTextBox._visible = true;
                ZigoEngine.doTween (contentTextBox,'_alpha',100,2,"easeOutExpo",0);
                contentTextBox.contentText.txt.htmlText = fullText;
                contentTextBox.contentText.txt.autoSize = true;

                if (contentTextBox._height > contentTextArea.back._height) {
                    startFloat ();
                }
            }
        };
        cont.load ("html_content_page_xml-el/contents.xml");
    }

    and the xml file is this:
    Code:
    <?xml version="1.0" encoding="utf-8"?><xml>
    	<content>
    		<description><![CDATA[<font color="#FFFFFF" size="20" style="font-family:Calibri">PROFIL</font><br><br><p align="justify"><font color="#FFFFFF" size="20">my text</font</p></font><br><br>]]></description>
    	</content>
    </xml>
    When i change the size or the color, then i get the result i want, but when i try to write something in italics or bold i fail.
    I tried <i></i> and <b></b> tags or style="font-style:italics" with no success.
    Any ideas??

    Thank you in advance

  2. #2
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    35
    If you're embedding your font, have you embedded the bold, italic and bold-italic weights of the font too?

    Cheers,
    Rob

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    11
    Can you give me a quick guide of how to embed for i.e. Calibri font and Calibri italics font?

    (I only see Character embeding where i choose all. Then at textbox i can choose font and style

  4. #4
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    35
    Hi,

    Check out the attachment. Look in the mc_embedded_fonts movieclip in the library, you'll see the 4 weights as separate textfields. If you select one then click the 'Embed...' button in the properties panel you'll see what characters I've included. I've set that movieclip to 'Export for Actionscript' (right-click the movieclip in the library and select properties. That way it doesn't have to be on the main timeline cluttering things up.

    On the main timeline I've added a dynamic textfield called _display, and stuck in this code:
    Actionscript Code:
    _display.embedFonts = true;
    _display.htmlText = "<font face=\"calibri\" size=\"20\">here <b>is</b> <i>some</i> <b><i>text<i><b></font>";

    That's about it really. I should point out this is authored in CS3, it should be vaguely equivalent in CS4/5 but I can't guarantee that.

    Cheers,
    Rob
    Attached Files Attached Files

  5. #5
    Junior Member
    Join Date
    Jul 2010
    Posts
    11
    Thank you very much!
    That really worked on CS4 too!

  6. #6
    Junior Member
    Join Date
    Jul 2010
    Posts
    11
    Hi there. The solution you gave me worked but i have another problem.

    A few days ago i uploaded the website and i saw that the xml external html content page in which i load the embedded fonts is loading very slowly (4-5 seconds) and its only a text. I saw the bandwidth usage from .fla and saw that the file is almost 500 kB! and when i delete the mc_embed_fonts from fla library then the file is 120 kB. How can i resolve this?A solution to reduce my .swf file?

    Thanks in advance

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center