View Full Version : [AS3] Combo box and mc visibility

02-09-2011, 12:06 AM
Again I have a problem

I looked about and found nothing on my particular issue :(

I have text boxes below a combobox which contains numbers

1 2 3 4

the visibility of my text boxes are all set to false. ie

answerBox1.visible = false;
answerBox2.visible = false;
answerBox3.visible = false;
answerBox4.visible = false;

If 1 is selected in the combobox, the visiblity of answerbox 2 - 4 is false and one is true

therefore 2 selected means 1 and 2 true , 3 and 4 false.

Declaring them all as false outwith the functions works , however it throws this error

TypeError: Error #1009: Cannot access a property or method of a null object

I have a version in AS2.0 dealing with visiblity of mcs (not with comboboxes data) which I could refer to if I dig it out, be I fear it may be a different approach in 3.0

ps. I'm using a varaible to track the comboxes data

Amount = Question.selectedItem.data;

I need the visiblity of the textboxes working as soon as the combobox value has been clicked


02-09-2011, 02:53 AM
This error could be any object that is called by your code that is not labeled with the right instance name.

So the first thing to check, based on what you shared, is that all of the textboxes have the right instance names. If they do, check all other objects to make sure they have the right instance names and that those instances are present in whatever frame contains your actions calling those instances.

02-13-2011, 01:53 PM
I went through them all but no luck

I think i'm closer to what is wrong however. I made a new flash program to test if I was doing it correctly

Having a combobox and a checkbox

if the combobox data == 1
checkbox would be visible
if the combobox data == 2
checkbox would be invisible

Tick.visible = false;

if(Combo.selectedItem.data == 1)
Tick.visible = true;

if(Combo.selectedItem.data == 2)
Tick.visible = false;

this throught the exact same error

What am I doing wrong ??

the mc's have the same instance names as they are in the actionscript

02-13-2011, 02:12 PM
I'm struggling with my combobox which keeps giving me this error
TypeError: Error #1009: Cannot access a property or method of a null object

How would I code this in AS3.0

if combobox data = 1 then checkbox.visible = false;
if combobox data = 2 then checkbox.visible = true;