|
-
CS3: Trouble with an if/else if conditional...
This script comes from an external .as file that is being referenced by a template flash file. I have an array set up for a dropdown list of pages and I have a movieclip and dynamic text field that I want to change dependent upon the page range being dynamically loaded into a movieclip. The script I am having difficulty with is highlighted in the actionscript below:
// Enter the Course Title and Course # text here:
var title1 = "The Name of the Course";
var title2 = "Secondary Title";
var courseid = "555_302";
//Use this to define page sections:
//section 1:
if (dropdown_cb.value >= 1 && dropdown_cb.value <= 2) {
var section_txt = "Prepare";
var colorful = new Color("_root.section_clr.section2");
colorful.setRGB(0xFF9900);
}
//section 2:
else if (dropdown_cb.value >= 3 && dropdown_cb.value <= 5) {
var section_txt = "Arghhh";
var colorful = new Color("_root.section_clr.section2");
colorful.setRGB(0xFF99CC);
}
//Enter the Page Titles here. Add or delete rows as needed
dropdown_cb.dataProvider = [
{value:0, label:"[01] Yarrr"}
,{value:1, label:"[02] Blech"}
,{value:2, label:"[03] Woot"}
,{value:3, label:"[04] Shoo"}
,{value:4, label:"[05] Meh"}
];
dropshadow(controlbar, .5, .5, .5)
//dropshadow2(dropdown_cb.dropdown, 1, 1, 2)
dropdown_cb.rowCount = 5;
var cbListener:Object = new Object();
cbListener.change = function(evt_obj:Object) {
var item_obj:Object = dropdown_cb.selectedItem;
var i:Number;
for (i in item_obj) {
var swf = _root.playlist[dropdown_cb.selectedItem.value];
trace("SWF :"+swf);
_root.mcLoader.loadClip(swf,_root.mc);
// trace(i + ":\t" + item_obj[i]);
trace("MC OBJ"+item_obj[i]);
var er:Number = dropdown_cb.selectedItem.value;
controlbar.jumper.stepper.value = er;
trace("NUMERIC STEPPER "+ er);
}
};
dropdown_cb.addEventListener("change", cbListener);
The first if part works but will not change when i advance the pages. Can anyone help me with this?
-
I don't think you should be using the '&&' operator. From what I understand you're checking if dropdown_cb's value is >= 1 and <= 2. You can't have two values for one variable. It's either or. Maybe you'll like to try using the '||' operator.
-
Flashmatics
funkage the logic is fine...he is checking if the value falls within certain ranges...
ddiguy07 you said you are having difficulties but you never actually said what the problem was..can you be more specific ..cheers
-
the problem...
The problem is that the part of the script "//section 1:" that will check if a value falls within certain ranges reads but the "else if" of //section 2: doesn't read, so when I go to a page within the 3 to 5 page range the movieclip doesn't change color and the new text isn't updated (the 'Arghhh' text).
Basically section 1 works but will not change when i advance the pages for section 2. Perhaps it just reads the first script but their is something wrong with these line:
if (dropdown_cb.value >= 1 && dropdown_cb.value <= 2) {
else if (dropdown_cb.value >= 3 && dropdown_cb.value <= 5) {
Thanks for the suggestion funkage but that also didn't seem to work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|