Skip to main content
Known Participant
May 2, 2013
Answered

connect 3 combobox

  • May 2, 2013
  • 1 reply
  • 3537 views

Greetings experts,

I'm beginner in AS3 and I want to make a JOB Classification Application by changing from frame to another in one and same scene using combobox. every frame has a data.

I made 3 comboboxes and success to connect combobox1 to combobox2 by write actions of moving from frame to frame as writed below, but I failed to continue in connecting the combobox2 to combobox3. Can anyone help please?

I used simple actions here as a rookie prograammer:

import flash.events.Event;
import flash.events.MouseEvent;
import fl.controls.ComboBox;

combobox1.addEventListener(Event.CHANGE, changeFrame);

function changeFrame (event:Event):void
{
    if (combobox1.selectedItem.label == "General Employee")
    gotoAndStop (2);
    else if (combobox1.selectedItem.label == "Education Employee")
    gotoAndStop (3);
    else if (combobox1.selectedItem.label == "Health Employee")
    gotoAndStop (4);
}


combobox2.addEventListener(Event.CHANGE, changeFrame1);

function changeFrame1 (event:Event):void
{
    if (combobox2.selectedItem.label == "Employee")
    gotoAndStop (5);
    else if (combobox2.selectedItem.label == "Semi-Employee")
    gotoAndStop (6);
    else if (combobox2.selectedItem.label == "Contracted")
    gotoAndStop (7);
    if (combobox2.selectedItem.label == "Teacher")
    gotoAndStop (8);

    else if (combobox2.selectedItem.label == "Adminstrator")

    gotoAndStop (9);

}

combobox3.addEventListener(Event.CHANGE, changeFrame2); 

function changeFrame2 (event:Event):void
{
    if (combobox3.selectedItem.label == "1st Level degree 1")
    gotoAndStop (10);
    else if (combobox3.selectedItem.label == "1st Level degree 2")
    gotoAndStop (11);
    else if (combobox3.selectedItem.label == "1st Level degree 3")
    gotoAndStop (12);
}

and so on like this,

The problem is: the second combobox didn't work and go to the 3rd combobox in choosed frame, why?

Also this error appears:

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

at prog2_Scene2_fla::MainTimeline/frame1()[prog2_Scene2_fla.MainTimeline::frame1:49]

*Second Part:

In the end of choices the is a number appear (Num1), I want to put this Num1 in Math actions, e.g: Num1 * 30% + Num2 = output field (RESULT), How can I make this?

Thanx in advanced

Ritchy GH

This topic has been closed for replies.
Correct answer moccamaximum

respected moccamaximum,

please can you change the data so I can easly understand the codes?

e.g:

Combobox1: Education, Health

Combobox2: Teacher, Doctor

Education --> Teacher

Health --> Doctor

where I can put the data to make changes?

treat me like a rookie


var dp1:DataProvider = new DataProvider();

var dp2A:DataProvider = new DataProvider();

var dp2B:DataProvider = new DataProvider();

dp1.addItem({ label: "Education"});

dp1.addItem({ label: "Health"});

dp2A.addItem({ label: "Teacher"});

dp2B.addItem({ label: "Doctor"});

function changeHandler(e:Event):void{

    switch(e.currentTarget.selectedItem.label){

        case "Education": combobox2.dataProvider = dp2A;break;

        case "Health": combobox2.dataProvider = dp2B;break;

        //do this for all possible changes

        default:break;

    }

}

1 reply

Inspiring
May 2, 2013

at prog2_Scene2_fla::MainTimeline/frame1()[prog2_Scene2_fla.MainTimeline ::frame1:49]

Look into line 49 of your code and report back what it says there

Ritchy GHAuthor
Known Participant
May 2, 2013

Thank you for quick response

line 49 is:

    if (combobox2.selectedItem.label == "Employee")

Inspiring
May 2, 2013

make sure you named the second box "combobox2" (click on it/properties/ name must be "combobox2") and that it is present at stage when this code executes.

meaning: if you put this code on frame 1 of the timeline but combobox2 first appearance is in frame 2. Flash won`t find the combobox.