A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 39

Thread: HTML in flash 8

  1. #1
    182
    Join Date
    Dec 2005
    Location
    Manchester
    Posts
    60

    HTML in flash 8

    Hey,

    I have some HTML code for a mailing list, i want to be able to have this in my flash site rather than linking to another page. Does anybody know how i can put the html code i have into flash or if it is possible? I'm using Flash 8 Professional.

    Thanks
    Scott

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Flash supports limited html tags. Make a dynamic text box, set its "render as html" (in properties panel the button between selectable and show border buttons) and put html code in it.

    There are also some examples with Flash. Look into folder \Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\TextFields

  3. #3
    182
    Join Date
    Dec 2005
    Location
    Manchester
    Posts
    60
    Thanks

  4. #4
    182
    Join Date
    Dec 2005
    Location
    Manchester
    Posts
    60
    Where do i type my HTML code? In the text area or in the script area?

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    In the text area.

  6. #6
    182
    Join Date
    Dec 2005
    Location
    Manchester
    Posts
    60
    Hi,

    I tried this and it just displays it as normal text? As if the html code is normal text. Do you know what i'm doing wrong? Thanks for all your help by the way

  7. #7
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Dont forget to set "render as html" option.

  8. #8
    182
    Join Date
    Dec 2005
    Location
    Manchester
    Posts
    60
    I'm sorry for being dumb but i still can't get it to work. Could you point me in the way of an example please if you know of any.

  9. #9
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Just go into your Flash examples folder, for example this:

    \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\Text\TextEnhancements

    And open the fla from there. It includes html file to load, css file and fla.

  10. #10
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    You want to put the HTML code in Actionscript and then set that as the value of the textbox, like:

    Code:
    myText.htmlText="This is my <b>bold</b> text."

  11. #11
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    Quote Originally Posted by rdoyle720
    You want to put the HTML code in Actionscript and then set that as the value of the textbox, like:

    Code:
    myText.htmlText="This is my <b>bold</b> text."
    and as mentioned

    Code:
    myText.html=true;
    peace.

  12. #12
    182
    Join Date
    Dec 2005
    Location
    Manchester
    Posts
    60
    Sorry i don't get you, where do i put: myText.htmlText="This is my <b>bold</b> text."

    Also when i make a text box and click on the actionscript area it says: "current selection cannot have actions applied to it"

    If somebody could make me a quick example to have a look at i would be so so grateful.

    Thanks Guys
    Scott
    Last edited by scott182; 01-04-2006 at 12:59 PM.

  13. #13
    Member
    Join Date
    Oct 2005
    Posts
    31
    Hey,

    I have a similar problem, I've tried using the examples files etc. I have a text field rendered as HTML loaded from a .txt file then formatted with CSS. The .txt loads as does the .css file. But the CSS is never applied to the text field (or if it is it makes no difference).

    submenuvar = "home";
    this[submenuvar+'btn'].enabled = false;
    //load text
    function loadMyText(evt) {
    var loadit_lv:LoadVars = new LoadVars();
    loadit_lv.load("text/"+[submenuvar]+".txt");
    loadit_lv.onLoad = function(success:Boolean) {
    if (success) {
    my_txt.text = this.content;
    } else {
    trace("Could not load text file.");
    }
    };
    }
    loadMyText();

    //apply stylesheet
    var flash_css = new TextField.StyleSheet();
    flash_css.load("text/styles.css");
    flash_css.onLoad = function(success:Boolean) {
    if (success) {
    my_txt.StyleSheet = flash_css;
    } else {
    trace("Could not load CSS file.");
    }
    };

    Any help would be greatly appreciated. Thanks in advnce

  14. #14
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    - The right of the People to create Flash movies shall not be infringed. -

  15. #15
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    Quote Originally Posted by MagicBez
    Code:
    submenuvar = "home";
    this[submenuvar+'btn'].enabled = false;
    //load text
    function loadMyText(evt) {
    	var loadit_lv:LoadVars = new LoadVars();
    	loadit_lv.load("text/"+[submenuvar]+".txt");
    	loadit_lv.onLoad = function(success:Boolean) {
    		if (success) {
    			my_txt.text = this.content;
    		} else {
    			trace("Could not load text file.");
    		}
    	};
    }
    loadMyText();
    
    //apply stylesheet
    var flash_css = new TextField.StyleSheet();
    flash_css.load("text/styles.css");
    flash_css.onLoad = function(success:Boolean) {
    	if (success) {
    		my_txt.StyleSheet = flash_css;
    	} else {
    		trace("Could not load CSS file.");
    	}
    };
    Actually,,, why not use .html instead of .txt files,, then u could use the following code which i made into a funciton so that u can simply call any html page and run it through...

    eg... selectPage("myPage.html")

    Code:
    function selectPage(address:String) {
    	_root.textHolder.condenseWhite = true;
    	var myVars_lv:LoadVars = new LoadVars();
    	var styles:TextField.StyleSheet = new TextField.StyleSheet();
    	var txt_url:String = address;
    	var css_url:String = "html_styles.css";
    	styles.onLoad = function(success:Boolean):Void  {
    		if (success) {
    			textHolder.styleSheet = styles;
    		} else {
    			//what ever you want,,, either  a trace,, or an action etc...
    		}
    	};
    	styles.load(css_url);
    	myVars_lv.onData = function(src:String):Void  {
    	if (src != undefined) {
    	textHolder.htmlText = src;
    	} else {
    	//what ever you want,,, either  a trace,, or an action etc...
    	}
    	};
    	myVars_lv.load(txt_url);
    }
    Hope that helps

  16. #16
    Member
    Join Date
    Oct 2005
    Posts
    31
    Awesome code there, worked perfectly with very little effort. Still don't know what was wrong with my code...but this is even better!!

    Thanks a lot

  17. #17
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    No problem, please get back to me if u come up with any improvements...

  18. #18
    Member
    Join Date
    Oct 2005
    Posts
    31
    Hey,

    I did notice one thing after putting the idea to test live on my server, sometimes when the swf has been loaded once before (it is all in the cache, i presume the html and css too) the CSS does not load. I presume this has something to do with the speed at which the CSS is applied to the HTML. This was found using safari 2.something.

    If it's not too clear what i mean the test site is live at www.infinitydesigns.co.uk and i can post .fla's if need be.

  19. #19
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    i noticed this too,,, im looking into it myself,,,, it would be interesting to load that function in the preloader maybe,, so when its called later on to be actually used for the site,,, the css is already cached,,,,

    im looking into it anyway and will get back to u ,,,

  20. #20
    Member
    Join Date
    Oct 2005
    Posts
    31
    Ok cool, that would be good because I really like the way this function works its exactly what i was looking for.

    In my movie i've put the function on the first frame, and then called it immediately, so maybe i should just try doing a load of the css before the function you've written in order to cache it or something. It must be that the html gets cached and the css doesn't?

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