Hi everybody !
First of all this project is great ! Good job done here :)
I'm kind of struggling here to do something.
I'm working in flash CS3 and I'd like to replace the
TextField.htmlText + CSS1 stylesheet combination offered by Flash CS3
which is so poor :'(
So I'd like to be able to render full html/css in flash.
First let's desribe my setup :
*********************************
I have a directory with :
- MankSans.swf
- style.css
- swfaddress.js
- test.html
- test1.fla
- test1.swf
- wrapper.js
Where test.html contains :
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>aa</title>
<link rel="stylesheet" href="style.css" type="text/css"/>
</head>
<body>
<p>blabla dans la catégorie CV</p>
</body>
</html>
and style.css contains :
html { height: 100%; }
body {
margin: 0; padding: 0; height: 100%;
font-size: 12px;
color:#FFOOOO;
}
p {
font-file: url("MankSans.swf");
font-family: "MankSans";
}
a {
color:#999999;
}
.redText {
color:#FF0000;
}
.blueText {
color:#0000FF;
}
.greenText {
color:#00FF00;
}
.boldText {
font-weight:bold;
}
.smallText {
font-size:8px;
}
.mediumText {
font-size:12px;
}
.largeText {
font-size:16px;
}
what I could get to work :
******************************
1) First test
In the first frame of my main timeline in my FLA movie, i added this :
import com.base.parse.Html;
var _Html:Html = new Html(this ,"test.html");
And I could get it to work by modifying the '-1' on the first line of
loadStyles() in com.base.parse.Html
And it worked , great !
2) Loading a string instead of a file.
var _str:String = "<html>\n"
+"<head>\n"
+"<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" />\n"
+"</head>\n"
+"<body>\n"
+"<p>blabla dans la catégorie CV</p>\n"
+"</body>\n"
+"</html>\n";
trace (_str);
var _Html:Html = new Html(this);
_Html.loadHTMLString(_str);
And I could get it too work too (I had to remove the xmlns in the
html tag ...?)
And I had to modify com.base.parse.Html at two places :
Firstly I changed the constructor so that if the url is null it doesnt
actually load it.
public function Html( tar:DisplayObjectContainer, urlStr:String =
null ) {
target = tar;
location = urlStr;
if (urlStr != null) {
loadHTML( location, onCompleteHTML );
}
}
Secondly, I added the function "loadHTMLString" Based on
"onCompleteHTML" :
public function loadHTMLString(htmlString:String) {
try {
var hd:String = htmlString;
hd = cleanLinks( hd );
//hd = hd.split( hd.substring(0, hd.indexOf("<head>") ) ).join
("<html>");
hd = cleanHTML( hd );
org_html = html;
html = new XML( hd );
trace(html);
loadStyles();
} catch( err:Error ) {
fixHtml( err );
return;
}
}
And that worked too (I had to remove xmlns in the html tag because for
some reason when it's there The stylesheet tag is not found ..)
Now what I could'nt get to work is to actually render this in a
movieclip instead of the maintimeline ...
I always get that error :
TypeError: Error #1010: A term is undefined and has no properties.
at com.base.draw::Element/com.base.draw::percent()
at com.base.draw::Element/com.base.draw::cleanTextValues()
at com.base.draw::Element/com.base.draw::cleanStyleObj()
at com.base.draw::Element/com.base.draw::cleanStyle()
at com.base.draw::Element/com.base.draw::makeStyle()
at com.base.draw::Element/make()
at com.base.draw::Element$iinit()
at com.base.parse::Html/render()
at flash.events::EventDispatcher/
flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.base.parse::Css/com.base.parse::loadFonts()
at com.base.parse::Css/com.base.parse::fontLoaded()
Which happen on line :
parentW = t["STYLE"].base.w - t["STYLE"].padding.l - t
["STYLE"].padding.r;
In the percent function from com.base.draw.Element ....
Any Help would be appreciated !!!
Also I'd like to formumate another request here.
I think it would be really GREAT to do an example about how to use
this library as HTML rendering engine for inside flash / flex !!
OR (and I could help on this) have a simplified version of this lib
that would only render for the usage I mentionned first ...
Cheers
Mathieu