Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

ComboBox with text wrapping

 
Jump to:  
 
SylviaMcc
PostPosted: Fri Jul 18, 2008 9:50 pm    Post subject: ComboBox with text wrapping
       
Hi folks,

I have working on this all day. I finally figured out how to make text wrap in
a combobox but now my links aren't working and I can't figure out what to do
next. I know the problem is in my eventlistener.


Here is the link to the code I used for the whole thing.

LINK
p.htm?context=Flash_MX_2004&file=00002101.html

Thanks for the help.
Sylvia

//my code for the combobox page starts here
import mx.transitions.*;
import mx.transitions.easing.*;
import mx.controls.*;


//style combo box
import mx.styles.CSSStyleDeclaration;
var new_style:Object = new CSSStyleDeclaration();
_global.styles.myStyle = new_style;
_global.style.setStyle("RollOverColor", 0xB3E6DC);


new_style.setStyle("textAlign", "left");
new_style.setStyle("selectionColor", 0xB3E6DC);
new_style.setStyle("useRollOver", true);
// borderStyle from RectBorder class
new_style.setStyle("borderStyle", "none");
new_style.setStyle("openDuration", 600);
new_style.setStyle("openEasing", Back.easeOut);
myCombobox.setStyle("styleName", "myStyle");

//fill combo box
var myCombobox:ComboBox;
var dataArr:Array = new Array({data:"1", label:"Click Here to Select Lesson"},
{data:"2", label:"Lesson 0 About This Course"}, {data:"3", label:"Lesson 1
Introduction to EAs"}, {data:"4", label:"Lesson 2 Legislation Governing EAs"},
{data:"5", label:"Lesson 3 EA Process"}, {data:"6", label:"Lesson 4 Describe
Project & Define Environment"}, {data:"6", label:"Lesson 5 Predict
Environmental Effects"}, {data:"8", label:"Lesson 6 Determine Environmental
Effects & Make Decisions"}, {data:"9", label:"Lesson 7 Implement & Follow Up"},
{data:"10", label:"Lesson 8 Roles & Responsibilities"}, {data:"11",
label:"Lesson 9 Course Summary"});
myCombobox.removeAll();
myCombobox.dropdown.rowHeight = 40;
//For DropDown Font Change
myCombobox.dropdown.cellRenderer = "MultiLineCell";
myCombobox.dataProvider = dataArr;



myComboBoxListener.change = function(eventObj) {
var eventSource = eventObj.target;
var theSelectedItem = eventSource.selectedItem;

var theSelectedItemLabel = theSelectedItem.label;
msg = "You selected "+theSelectedItemLabel+".";
statusMessage.text = msg;
if (theSelectedItemLabel == "Click Here to Select Lesson") {
trace("click here");
}
if (theSelectedItemLabel == "Lesson 0 About This Course") {
this.gotoAndPlay("A1_expanded");
trace("hit");
}
if (theSelectedItemLabel == "Lesson 1 Introduction to EAs") {
this.gotoAndPlay("L1_expanded");
}
if (theSelectedItemLabel == "Lesson 2 Legislation Governing EAs") {
this.gotoAndPlay("L2_expanded");
}
if (theSelectedItemLabel == "Lesson 3 EA Process") {
this.gotoAndPlay("L3_expanded");
}
if (theSelectedItemLabel == "Lesson 4 Describe Project & Define Environment") {
this.gotoAndPlay("L4_expanded");
}
if (theSelectedItemLabel == "Lesson 5 Predict Environmental Effects") {

trace("5 hit finally");
this.gotoAndPlay("L5_expanded");

}
if (theSelectedItemLabel == "Lesson 6 Determine Environmental Effects & Make
Decisions") {
this.gotoAndPlay("L6_expanded");
}
if (theSelectedItemLabel == "Lesson 7 Implement & Follow Up") {
this.gotoAndPlay("L7_expanded");
}
if (theSelectedItemLabel == "Lesson 8 Roles & Responsibilities") {
this.gotoAndPlay("L8_expanded");

}
if (theSelectedItemLabel == "Lesson 9 Course Summary") {
this.gotoAndPlay("L9_expanded");
trace("hit");
}
};
myComboBox.addEventListener("change", myComboBoxListener);
this.stop();

//code ends here
 

 
Heroina
PostPosted: Fri Jul 18, 2008 10:34 pm    Post subject: Re: ComboBox with text wrapping
       
Hi, change your listener to this:

myCombobox.addEventListener("change", myComboBoxListener);
function myComboBoxListener(eventObj) {
trace("change");
var eventSource = eventObj.target;
var theSelectedItem = eventSource.selectedItem;

var theSelectedItemLabel = theSelectedItem.label;
msg = "You selected "+theSelectedItemLabel+".";
statusMessage.text = msg;
if (theSelectedItemLabel == "Click Here to Select Lesson") {
trace("click here");
}
if (theSelectedItemLabel == "Lesson 0 About This Course") {
this.gotoAndPlay("A1_expanded");
trace("hit");
}
if (theSelectedItemLabel == "Lesson 1 Introduction to EAs") {
this.gotoAndPlay("L1_expanded");
}
if (theSelectedItemLabel == "Lesson 2 Legislation Governing EAs") {
this.gotoAndPlay("L2_expanded");
}
if (theSelectedItemLabel == "Lesson 3 EA Process") {
this.gotoAndPlay("L3_expanded");
}
if (theSelectedItemLabel == "Lesson 4 Describe Project & Define
Environment") {
this.gotoAndPlay("L4_expanded");
}
if (theSelectedItemLabel == "Lesson 5 Predict Environmental
Effects") {

trace("5 hit finally");
this.gotoAndPlay("L5_expanded");

}
if (theSelectedItemLabel == "Lesson 6 Determine Environmental
Effects & Make Decisions") {
this.gotoAndPlay("L6_expanded");
}
if (theSelectedItemLabel == "Lesson 7 Implement & Follow Up") {
this.gotoAndPlay("L7_expanded");
}
if (theSelectedItemLabel == "Lesson 8 Roles & Responsibilities") {
this.gotoAndPlay("L8_expanded");

}
if (theSelectedItemLabel == "Lesson 9 Course Summary") {
this.gotoAndPlay("L9_expanded");
trace("hit");
}
};

By the way, I think it is more easy to do the if statements with the
data property:

var eventSource = eventObj.target;
var theSelectedItem = eventSource.selectedItem;

var theSelectedItemLabel = theSelectedItem.label;
var theSelectedItemData = theSelectedItem.data;
msg = "You selected "+theSelectedItemLabel+".";
statusMessage.text = msg;
if (theSelectedItemData == 1) {
trace("click here");
}
if (theSelectedItemData == 2) {
this.gotoAndPlay("A1_expanded");
trace("hit");
}
if (theSelectedItemData == 3) {
this.gotoAndPlay("L1_expanded");
}
...

Cheers.

Carla Macías
LINK
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

certyfikat teksty piosenek park Kochanowski Jan wiersze mieszkanie wrocław