-
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
-
Senior Member
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
-
-
Where do i type my HTML code? In the text area or in the script area?
-
Senior Member
-
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
-
Senior Member
Dont forget to set "render as html" option.
-
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.
-
Senior Member
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.
-
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."
-
go blues !
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
-
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.
-
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
-
Senior Member
- The right of the People to create Flash movies shall not be infringed. -
-
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
-
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
-
No problem, please get back to me if u come up with any improvements...
-
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.
-
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 ,,,
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|