This error only appears on one var! It didn’t happen earlier. Why is this occuring?
size_ns is a Numeric Stepper.
the error:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 52: There is no method with the name 'addEventListener'.
size_ns.addEventListener("change", styleListener);
Total ActionScript Errors: 1 Reported Errors: 1
the code:
import mx.controls.*;
var font_cb:ComboBox;
var size_ns:NumericStepper;
var bold_button:Button;
var italic_button:Button;
var underline_button:Button;
var color_button:Button;
var pic_button:Button;
var link_button:Button;
var code_button:Button;
this.createTextField("input_txt", this.getNextHighestDepth(), 0, 84, 300, 80);
input_txt.border = true;
input_txt.wordWrap = true;
input_txt.multiline = true;
input_txt.background = 0xFFFFFF;
input_txt.type = "input";
input_txt.html = true;
this.createTextField("html_txt", this.getNextHighestDepth(), 0, 165, 300, 58);
html_txt.border = true;
html_txt.wordWrap = true;
html_txt.multiline = true;
html_txt.background = 0xFFFFFF;
html_txt.type = "input";
font_cb.dataProvider = TextField.getFontList().sort();
input_txt.text = "Leave me a comment!";
html_txt.text = input_txt.htmlText;
input_txt.onChanged = function() {
html_txt.text = input.htmlText;
};
html_txt.onChanged = function() {
input_txt.htmlText = html_txt.text;
};
var mouseListener:Object = new Object();
mouseListener.onMouseUp = function() {
if (getProperty(Selection.getFocus(), _name) == "input_txt") {
_global.beginIndex = Selection.getBeginIndex();
_global.endIndex = Selection.getEndIndex();
}
};
Mouse.addListener(mouseListener);
var styleListener:Object = new Object();
styleListener.change = function(eventObj:Object) {
Selection.setFocus(null);
applyStyle(eventObj);
};
styleListener.click = function(eventObj:Object) {
applyStyle(eventObj);
Selection.setFocus(input_txt);
Selection.setSelection(_global.beginIndex, _global.endIndex);
};
font_cb.addEventListener("change", styleListener);
size_ns.addEventListener("change", styleListener);
bold_button.addEventListener("click", styleListener);
italic_button.addEventListener("click", styleListener);
underline_button.addEventListener("click", styleListener);
color_button.addEventListener("click", styleListener);
link_button.addEventListener("click", styleListener);
pic_button.addEventListener("click", styleListener);
code_button.addEventListener("click", styleListener);
function applyStyle(eventObj:Object) {
var my_fmt:TextFormat = input_txt.getTextFormat(_global.beginIndex);
switch (eventObj.target._name) {
case 'font_cb' :
my_fmt.font = eventObj.target.selectedItem;
break;
case 'size_cb' :
my_fmt.size = eventObj.target.value;
break;
case 'bold_button' :
my_fmt.bold = !my_fmt.bold;
break;
case 'italic_button' :
my_fmt.italic = !my_fmt.italic;
break;
case 'underline_button' :
my_fmt.underline = !my_fmt.underline;
break;
case 'color_button' :
my_fmt.color = hexout.text;
break;
case 'link_button' :
input_txt.htmlText += '<a href="'+url_form.text+'"target="_self">click me</a>';
break;
case 'pic_button' :
input_txt.htmlText += '<img src="'+url_form.text+'">';
break;
case 'code_button' :
html_txt.text = '<object type="application/x-shockwave-flash" width="300" height="222"><param name="wmode" value="transparent" /><embed src="'+input_txt._url+'" wmode="transparent" width="300" height="222" /></object>';
input_txt.text = "Place the html code into your page.";
break;
}
input_txt.setTextFormat(_global.beginIndex, _global.endIndex, my_fmt);
}
stagerColor = new Color(stager);
hexout.text = "0x000000";
function colorPicked() {
stagerColor.setRGB(newval);
rVal = (newval >> 16) & 0xFF;
gVal = (newval >> 8) & 0xFF;
bVal = newval & 0xFF;
if ((rVal+gVal+bVal)/3>128) {
_level0.hexout.textColor = 0x000000;
} else {
_level0.hexout.textColor = 0xFFFFFF;
}
}
cpicker.watch('rgbVal', asPick);
function asPick(id, oldval, newval) {
var rVal, r, gVal, g, bVal, b;
rVal = (newval >> 16) & 0xFF;
gVal = (newval >> 8) & 0xFF;
bVal = newval & 0xFF;
r = rVal.toString(16);
g = gVal.toString(16);
b = bVal.toString(16);
if (rVal<16) {
r = '0'+r;
}
if (gVal<16) {
g = '0'+g;
}
if (bVal<16) {
b = '0'+b;
}
_level0.hexout.text = "0x"+r+g+b;
if ((rVal+gVal+bVal)/3>128) {
_level0.hexout.textColor = 0x000000;
} else {
_level0.hexout.textColor = 0xFFFFFF;
}
stagerColor.setRGB(newval);
return newval;
}