AS3 Methods
- Started
- Last post
- 5 Responses
- StratusGD0
Thanks Max, Kult - I knew about extending Classes - not sure why that didn't click in my head. I guess I was looking for a way to do that without having to create a new Class.
Anyway, good to know the answer. Thanks.
- kult0
Yeah, create a custom class for yourself. Here, I'll get ya started.. create a file called, for example, MyText.as..
package {
public class MyText extends TextField {
var theText = this;
public function trimText() {
//your code here... affecting theText
}
}
}Wrote this inside the QBN textbox so it's obviously not the best.
- bulletfactory0
www.gotoandlearn.com may have something on classes and methods
- maximillion_0
extend the textfield class and you will be able to do this. search "extending classes actionscript" and you will find the answer
- StratusGD
Apologies in advance - if I knew what to Google, I would.
So, I have a function that truncates text if it's too long to fit within a TextField, and adds an ellipsis to the end. Right now, it is used like:
trimText(myTextField);It works fine for my purposes, but I'm trying to figure out how to change the code so I can use it like:
myTextField.trimText();Maybe even be able to use it either way. Is that possible? Is one way the right/wrong way? You can see the existing code here: http://pastebin.org/28546
Thanks.