Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Textfield – Flash 8, html text rendering fix
cybernetix
post Jan 1 2006, 01:42 PM
Post #1


ReloadeD
Group Icon
Group: Honored
Posts: 562
Joined: 20-May 04
From: Belgrade, Serbia
Member No.: 17





I was wondering what could be the reason for strange behavior of html rendereed text in predefined textField exported to flash 8. So, I decided to take a look into what happen to textField object while swf is playing.


I used this to examine properties of predefined textField.
CODE
dumpObj=function(_obj) {    
        ASSetPropFlags(_obj, null, 6, 1);
        _root.inf="";
        for (z in _obj) {
            _root.infoText+=z+" = "+_obj[z]+"\n";
        }
    };
    dumpObj(myTextField);
// This assumes that you have predefined textField myTextField and infoText.


And I found that property _text.multiline mysteriously becomes FALSE no matter what is set within swishmax IDE. Well, this is the reason why line break
tag is not rendered properly. Why ?

Actually on initialising textField flash renders
by inputing text within paragraf

tag. Let’s see this practically. Suppose that we have this text:

A
B

Flash will render it to

A

B

, actually it will be like this:

htmlText=

A

B



But predefined dynamic textField created with swishmax will render it like this:
htmlText =

AB



Knowing that swishmax keeps original text in property textField.text I tried this:
myTextField._text.multiline = true;
myTextField._text.htmlText = myTextField.text;

CODE
MovieClip.prototype.cbxDumpText=function(_c) {
        if (this._text.text && this._text.variable) {
            _t=this._text;
            for (z in _c) _t[z] = _c[z];
            if (_t.html) _t.htmlText = this.text;
        }        
    };

Works fine with text, but position of externally lodaed image is incorrect so, this solution was just half a way to success.

Idea was to dynamically create another textFiled that will have all predefined values of original myTextField but with some corrections, like multiline = true.



And here it is:


This should be added into _root of main swf:
CODE
onload() {
    MovieClip.prototype.cbxDumpText=function(_c) {
        if (this._text.text && this._text.variable) {
            var _t, _o = new Object(), tx = this.text, tFormat = this._text.getNewTextFormat();
            if (this._text.stylesheet) this._text.styleSheet=this._text.stylesheet;
            for (z in this._text) _o[z] = this._text[z];
            _t = this._parent.createTextField(this._name, this.getDepth(), this._x, this._y, this._width, this._height);
            _t.setNewTextFormat(tFormat);
            for (z in _t) _t[z] = _o[z];
            for (z in _c) _t[z] = _c[z];
            if (_t.html) _t.htmlText = tx;
        }    
    };
}



In myTextFiled add actionscript code:
CODE
onload() {
    var cbx = { multiline:true, condenseWhite:true, variable:"content" };
    this.cbxDumpText(cbx);
}


var cbx explanation:

this is obj which will pass new values of certain properties.
1. multiline = true; // set this to true if your textField is multiline, smax fails to set this property.
2. condenseWhite = true; // set this only if you need it
3. variable – this is tricky, name of variable should be passed as stringName, that is why it is “content”, whatever you set (or you don't have to) as variable for myTexField in swishmax IDE will be overwritten with this new variable name. (this example assumes that variable name is “content”, buit it can be whatever you want).
You can predefine some other properties as well, but it does not concern this bug, so it is up to you.

When swishzone fix this bug, you can simply change this prototype to:
CODE
MovieClip.prototype.cbxDumpText=function(_c) {
    return null;
}


Another solution would be to create new swi/swf file with this prototype only and to load it to _root, after swishzone fix this bug, just remove that swf file.

Please NOTE: this will work only with predefined dynamic textField objects created in swishmax IDE, but not with statics! There are some tricks for static textField objects, but more about that maybe next time.


As we all know, example is better than 1000 words, so take a look into attached file.


Happy New Year and Swishing!
Attached File(s)
Attached File  dynTextFieldFix_cbx.zip ( 7.01K ) Number of downloads: 1633
 
 
+Quote Post  Go to the top of the page
*D*
post Jan 4 2006, 01:11 AM
Post #2


Merry KissMoose
Group Icon
Group: Main Team
Posts: 15,990
Joined: 18-May 04
From: North Pole
Member No.: 2





thumbsup.gif Many thankyou's
 
+Quote Post  Go to the top of the page
the_iceman
post Jan 4 2006, 10:43 AM
Post #3


Good Ol' Dot
Group Icon
Group: *Premier*
Posts: 219
Joined: 27-October 05
From: Seattle, WA
Member No.: 7,814





Thank you for all your great work cybernix. Great Job!
 
+Quote Post  Go to the top of the page
RedDragon
post Jan 4 2006, 12:34 PM
Post #4


insert coin
Group Icon
Group: Main Team
Posts: 5,344
Joined: 24-May 04
From: Maastricht
Member No.: 35





Will have to look into this using the example (thx for adding, very useful), because your level of expertise goes way above my head...!

thanks a lot for the tut nenad thumbsup.gif
 
+Quote Post  Go to the top of the page
jpaulodesigns
post Jan 11 2006, 09:46 AM
Post #5


New Member
*
Group: Validating
Posts: 18
Joined: 2-March 05
From: The year 3000 in New New York.
Member No.: 2,345





very nice! helps out tons.. smile.gif
 
+Quote Post  Go to the top of the page
vicohn
post Apr 8 2006, 11:33 AM
Post #6


New Member
Group Icon
Group: Member
Posts: 1
Joined: 8-April 06
Member No.: 10,668





Please, how to add scroll?

Thank You!
 
+Quote Post  Go to the top of the page
ostaz
post Mar 6 2008, 06:30 PM
Post #7


Getting Used To The Dots
Group Icon
Group: Member
Posts: 31
Joined: 5-March 08
Member No.: 19,677





So Many thanks
 
+Quote Post  Go to the top of the page
axivelet
post Mar 19 2008, 06:14 PM
Post #8


Getting Used To The Dots
Group Icon
Group: Member
Posts: 45
Joined: 19-March 08
Member No.: 19,875





thank you

 
+Quote Post  Go to the top of the page
axivelet
post Mar 23 2008, 06:38 PM
Post #9


Getting Used To The Dots
Group Icon
Group: Member
Posts: 45
Joined: 19-March 08
Member No.: 19,875





thank you
 
+Quote Post  Go to the top of the page

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 29th July 2010 - 11:05 PM
Free Animated Greetings | Find jobs | Cheap Travel Insurance | Life Insurance | Watch Anime