tengo una seccion de una pagina donde yo puedo agregar texto a unos cuadros tipo...customizar articulos...agregar texto, imagenes etc.
Pero mi problema radica qe cuando seleccion una opcion, hasta que doy el segundo click sobre una opcion.esta se me refleja...me podria alguien ayudar.
Código :
import mx.controls.*;
Selection.setFocus("1");
// strict type our component instances on the Stage.
var font_cb:ComboBox;
var size_cb:ComboBox;
var bold_button:Button;
var italic_button:Button;
var color_cb:ComboBox;
var viewStyle_button:Button;
Selection.setFocus("1");
font_cb.dataProvider = TextField.getFontList().sort();
// add a few standard font sizes to the size_cb ComboBox instance.
Selection.setFocus("1");
size_cb.dataProvider = [10, 11, 12, 13, 14, 15, 16];
// add a handful of common colors manually.
Selection.setFocus("1");
color_cb.addItem({data:0x000000, label:'Black'});
color_cb.addItem({data:0xFF0000, label:'Red'});
color_cb.addItem({data:0x00FF00, label:'Green'});
color_cb.addItem({data:0x0000FF, label:'Blue'});
color_cb.addItem({data:0xFFFFFF, label:'White'});
Selection.setFocus("1");
var mouseListener:Object = new Object();
mouseListener.onMouseUp = function() {
if (getProperty(Selection.getFocus(), _name) =="1" ) {
_global.beginIndex = Selection.getBeginIndex();
_global.endIndex = Selection.getEndIndex();
}
};
Mouse.addListener(mouseListener);
Selection.setFocus("1");
var styleListener:Object = new Object();
styleListener.change = function(eventObj:Object) {
Selection.setFocus(null);
applyStyle(eventObj);
};
styleListener.click = function(eventObj:Object) {
applyStyle(eventObj);
Selection.setFocus("1");
Selection.setSelection(_global.beginIndex, _global.endIndex);
};
Selection.setFocus("1");
font_cb.addEventListener("change", styleListener);
size_cb.addEventListener("change", styleListener);
bold_button.addEventListener("click", styleListener);
italic_button.addEventListener("click", styleListener);
color_cb.addEventListener("change", styleListener);
function applyStyle(eventObj:Object) {
Selection.setFocus("1");
var my_fmt:TextFormat = text1.getTextFormat(_global.beginIndex);
var my_fmt:TextFormat = text2.getTextFormat(_global.beginIndex);
var my_fmt:TextFormat = text3.getTextFormat(_global.beginIndex);
var my_fmt:TextFormat = text4.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.selectedItem;
break;
case 'bold_button' :
my_fmt.bold = !my_fmt.bold;
break;
case 'italic_button' :
my_fmt.italic = !my_fmt.italic;
break;
case 'color_cb' :
my_fmt.color = eventObj.target.selectedItem.data;
break;
}
// reapply the text format.
text1.setTextFormat(_global.beginIndex, _global.endIndex, my_fmt);
text2.setTextFormat(_global.beginIndex, _global.endIndex, my_fmt);
text3.setTextFormat(_global.beginIndex, _global.endIndex, my_fmt);
text4.setTextFormat(_global.beginIndex, _global.endIndex, my_fmt);
}
// this function displays the current style at the beginning of the text selection.
viewStyle_button.addEventListener("click", clickListener);
function clickListener(eventObj:Object):Void {
var curr_fmt:TextFormat = text1.getTextFormat(_global.beginIndex);
var curr_fmt:TextFormat = text2.getTextFormat(_global.beginIndex);
var curr_fmt:TextFormat = text3.getTextFormat(_global.beginIndex);
var curr_fmt:TextFormat = text4.getTextFormat(_global.beginIndex);
}
