Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-21-2006, 01:41 AM   #1
cutey_kira
Registered User
 
Join Date: Sep 2005
Posts: 22
Red face Combo box

Hey ppl,

i have a little thing in flash with 2 input txt boxes, 1 dynamic txt box and a button and when u enter 2 numbers and press the button it will add the numbers together and display in the dinamic txt box .

i have that all working now i have added a combo box with the lables "+-*/" and i want to be able to click oner of the lables so it will be able to - * / as well as + the 2 numbers together i have written my code up but i dont know how to target my combo box as i cant assight a varible name and i cant get an instance name to work.

here is my code


on (release) {

if (Combobox = ("+")) {
answer = Number(num1) + Number(num2);
}
else if (Combobox = ("-")) {
answer = Number(num1) - Number(num2);
}
else if (Combobox = ("*")) {
answer = Number(num1) * Number(num2);
}
else if (Combobox = ("/")) {
answer = Number(num1) / Number(num2);
}

}

i have used Combobox as the combo boxes instance name but no luck.

Any suggestions???

Do i have to use something like "on (Change)"

Last edited by cutey_kira; 10-21-2006 at 01:43 AM.
cutey_kira is offline   Reply With Quote
Old 10-21-2006, 02:16 AM   #2
cutey_kira
Registered User
 
Join Date: Sep 2005
Posts: 22
Red face Combo box

Hey ppl,

i have a little thing in flash with 2 input txt boxes, 1 dynamic txt box and a button and when u enter 2 numbers and press the button it will add the numbers together and display in the dinamic txt box .

i have that all working now i have added a combo box with the lables "+-*/" and i want to be able to click oner of the lables so it will be able to - * / as well as + the 2 numbers together i have written my code up but i dont know how to target my combo box as i cant assight a varible name and i cant get an instance name to work.

here is my code


on (release) {

if (Combobox = ("+")) {
answer = Number(num1) + Number(num2);
}
else if (Combobox = ("-")) {
answer = Number(num1) - Number(num2);
}
else if (Combobox = ("*")) {
answer = Number(num1) * Number(num2);
}
else if (Combobox = ("/")) {
answer = Number(num1) / Number(num2);
}

}

i have used Combobox as the combo boxes instance name but no luck.

Any suggestions???
cutey_kira is offline   Reply With Quote
Old 10-23-2006, 03:19 AM   #3
adrian_brooks
Registered User
 
Join Date: Oct 2006
Posts: 2
Default

Hi,

Is this in Flash 8 or 4 MX?

If this is Flash 8, you will not be able to address the selection of the combo box just by calling out it's instance name as you have done. 'Combobox' is an object and objects have events, methods and properties.

A comparative analogy would be your car. It would be like you standing outside of your car and holding your keys out to it and wondering why it's not starting (remote starting is not permitted here).
This is because the car is an 'object', its color is a 'property', if it backfires when running, that is an 'event', and your ignition is the 'method' used for starting it. So, for your car to start, you have to get inside of the car 'object' and access the ignition 'method' to cause the engine running 'event' to be activated. The same applies to flash objects. You need to get inside of them to use their methods, properties or events.

Flash is extremely dedicated to object oriented programming. This is no exception.

I don't know how you populated your combo box's data and label values. If you used a key/value array to do it, then all you need to do is ask for the value by its respective key name. I'm not sure what the default key names are though if you just used the data & label editors that are built into flash.

So, in order to do what you are attempting to do, try this instead;

on (release) {
// this line creates an object reference to the selected item of your combobox object
var item_obj:Object = _root.Combobox.selectedItem;
if (item_object['keyname'] == "+") {
answer = Number(num1) + Number(num2);
}
else if (item_object['keyname'] == "-") {
answer = Number(num1) - Number(num2);
}
else if (item_object['keyname'] == "*") {
answer = Number(num1) * Number(num2);
}
else if (item_object['keyname'] == "/") {
answer = Number(num1) / Number(num2);
}

}

I know this will work if you can replace the 'keyname' strings with the actual key names that are making up your data array and your label array.

Hope this helped

Last edited by adrian_brooks; 10-23-2006 at 03:22 AM.
adrian_brooks is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Boxes - some work, some don't mrbirtch Components 1 09-12-2006 12:12 PM
Dynamic Combo Box not remembering selected mattd Components 1 05-29-2006 10:00 PM
Reset Button for Combo Boxes and more WillisTi Components 3 11-20-2005 09:46 AM
combo box dcullinane Components 9 06-21-2004 11:08 AM


All times are GMT. The time now is 03:29 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.