PDA

View Full Version : Math.Round w/ Pixel Fonts



wyclef
April 20th, 2004, 12:38 PM
Hi,

Is there a way to use Math.Round to ensure that ALL text boxes are on whole number, X,Y coordinates?

andr.in
April 20th, 2004, 12:44 PM
yes..


onClipEvent(enterFrame) {
this._x = Math.round(this._x);
this._y = Math.round(this._y);
}


the tex thas to be a movieclip in this case and the actions should be put on them...

wyclef
April 21st, 2004, 01:15 PM
So how could I make this a global function that targeted multiple MC instances...(8 to be exact)

pom
April 21st, 2004, 01:35 PM
Why set the _x and _y positions onEnterFrame ???

No, I don't know if you can manipulate the _x and _y properties of a textField, but if you can, you can try something like this: you check all the objects on the scene, align the textfields, and if it's a clip, you check everything in that clip, and so on...
TextField.prototype.alignMe = function () {
this._x = Math.round (this._x) ;
this._y = Math.round (this._y) ;
}

function exploreTimeline (pTimeline) {
for (var o in pTimeline) {
if (pTimeline[o] instanceof TextField) {pTimeline[o].alignMe () ;
else if (pTimeline[o] instanceof MovieClip) exploreTimeline (pTimeline[o]) ;
}
}

exploreTimeline (_root) ;I don't have Flash so it might be bugged :beam: