-
help with if and else statements
How would I code this?
If the user is frame number is on frame number 7, then a certain code (see code box 1 ) is sent to a combobox on frame 7 (just say arm_cb is the combobox).
But if the user then moves on to frame 9, then a different code (see code box 2) is sent to another combobox on frame 9 (arm_cb1 is the second combobox).
This is the same with another frame, a different code is sent to the combobox on that frame.
Is this possible? Is there a way with if/else?
Code 1 (for arm_cb)
Code:
var myListener = new Object();
arm_cb.addEventListener("change", myListener);
myListener.change = function ()
{
your_picture.text = arm_cb.value;
};
Code 2 (for arm_cb1)
Code:
var myListener = new Object();
arm_cb.addEventListener("change", myListener);
myListener.change = function ()
{
your_picture.text = arm_cb1.value;
};
Wolf Flare 123
P.S give me a code that you would use, please. Thanks
-
I would NOT use an if else. If you're talking about _currentframe :
By "If the user is frame number is on frame number 7", i'm assuming you mean "if the playhead in on keyframe #7"
You rarely need if/else statements. You can use variables instead. For example, integrate the 'special' keyframes number, 7, 9 or else, in the name:
arm_cb7, arm_cb9, etc. That or equivalent.
then one code only:
your_picture.text = _root["arm_cb"+_currentframe].value;
Not saying this will work as is, i don't know much about your structure; the example is more for you to understand the method.
When possible, that's always better than if/else.
gparis
-
Similarly to what gparis suggested, I wouldn't use an 'if' statement either. If I was going to use a conditional statement, the 'switch' statement would be better suited to your needs.
However, I personally would probably store the text strings in an 'Array' and index that using '_currentframe'.
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
|