Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:12:45+00:00 2026-05-30T07:12:45+00:00

I am trying to create a Combo Box (from the components list in flash

  • 0

I am trying to create a Combo Box (from the components list in flash cs4). I have gotten it to work with

import fl.accessibility.ComboBoxAccImpl; 
import fl.data.DataProvider; 
import fl.events.ComponentEvent; 

ComboBoxAccImpl.enableAccessibility();
var weapons:Array = [ 
    {label:"Sword", data:"SwordSelected"}, 
    {label:"Bow", data:"BowSelected"}, 
    {label:"Knife", data:"KnifeSelected"}];
testtxt.text = String("sword");

weaponselector.dataProvider = new DataProvider(weapons); 

weaponselector.addEventListener(ComponentEvent.ENTER, weaponsadd); 
weaponselector.addEventListener(Event.CHANGE, weaponboxselecter);


function weaponboxselecter(event:Event):void
{
    if (ComboBox(event.target).selectedItem.data != "SwordSelected")
    {
        selectSword();
        testtxt.text = String(ComboBox(event.target).selectedItem.label);
    }
    else if (ComboBox(event.target).selectedItem.data != "BowSelected")
    {
        selectBow();
        testtxt.text = String(ComboBox(event.target).selectedItem.label);
    }
    else if (ComboBox(event.target).selectedItem.data != "KnifeSelected")
    {
        selectKnife();
        testtxt.text = String(ComboBox(event.target).selectedItem.label);
    }
}

but then i tryed to create a history if what is being clicked(selectKnife/selectBow/selectSword in the weaponboxselecter function)

var weaponsHistory:Array = ["Sword"];
trace(weaponsHistory);
function selectBow()
{
    var Bowadds:Bowadd = new Bowadd();
    Bowadds.x = 300
    Bowadds.y = 300
    stage.addChild(Bowadds);
    trace(weaponsHistory);
    weaponsHistory.splice(1, "Bow");
}

function selectKnife()
{
    var Knifeadds:Bowadd = new Bowadd();
    Knifeadds.x = 300
    Knifeadds.y = 300
    stage.addChild(Knifeadds);
    weaponsHistory.splice(1, "Knife");
    trace(weaponsHistory);
}

function selectSword()
{
    var Swordadds:Bowadd = new Bowadd();
    Swordadds.x = 300
    Swordadds.y = 300
    stage.addChild(Swordadds);
    weaponsHistory.splice(1, "Sword");
    trace(weaponsHistory);
}

but it always traces sword

any suggestions

thanks

[New Code]

var weaponsHistory:Array = ["Sword"];
function weaponboxselecter(event:Event):void{
if(ComboBox(event.target).selectedItem.data != "SwordSelected"){
    selectSword();
    testtxt.text = String(ComboBox(event.target).selectedItem.label);
    weaponsHistory.splice(0,0,"Sword");

}else if(ComboBox(event.target).selectedItem.data != "BowSelected"){
    selectBow();
    testtxt.text = String(ComboBox(event.target).selectedItem.label);
    weaponsHistory.splice(0,0,"Bow");


}else if(ComboBox(event.target).selectedItem.data != "KnifeSelected"){
    selectKnife();
    testtxt.text = String(ComboBox(event.target).selectedItem.label);
    weaponsHistory.splice(0,0,"Knife");



}
[new code]
trace(weaponsHistory);// just less code
[end new code]
    }

this still doesn’t work. I will explain it a bit better:

The Sword is first selected. Then when i click on the Bow/Knife the Sword is replaced with Bow/Knife. That way i can add and remove objects based on what was last clicked(if you have another way of doing this i am up for other options.)

What is happening is that the Sword is being traced than if i click on knife, sword is traced and if i click on bow, Sword is traced but if the click on sword or knife again than bow is traced.

thanks

[new Code]

function selectBow(){
    var Bowadds:Bowadd = new Bowadd();
    Bowadds.x = 300
    Bowadds.y = 300
    stage.addChild(Bowadds);
    trace(weaponsHistory);





}


function selectKnife(){
    var Knifeadds:Bowadd = new Bowadd();
    Knifeadds.x = 300
    Knifeadds.y = 300
    stage.addChild(Knifeadds);
    trace(weaponsHistory);




}

function selectSword(){
    var Swordadds:Bowadd = new Bowadd();
    Swordadds.x = 300
    Swordadds.y = 300
    stage.addChild(Swordadds);
    trace(weaponsHistory);

}


function weaponsadd(event:ComponentEvent):void { 
    var newRow:int = 0; 
    if (event.target.text == "Add") { 
        newRow = event.target.length + 1; 
            event.target.addItemAt({label:"screen" + newRow, data:"screenData" + newRow},  
            event.target.length);  
    } 
}

function weaponboxselecter(event:Event):void{
if(ComboBox(event.target).selectedItem.data != "SwordSelected"){
    selectSword();
    testtxt.text = String(ComboBox(event.target).selectedItem.label);
    weaponsHistory.push("Sword");

}else if(ComboBox(event.target).selectedItem.data != "BowSelected"){
    selectBow();
    testtxt.text = String(ComboBox(event.target).selectedItem.label);
    weaponsHistory.push("Bow");


}else if(ComboBox(event.target).selectedItem.data != "KnifeSelected"){
    selectKnife();
    testtxt.text = String(ComboBox(event.target).selectedItem.label);
    weaponsHistory.push("Knife");



}
}

It all works except for the knife. It only traces sword…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:12:46+00:00Added an answer on May 30, 2026 at 7:12 am

    You’re using splice(…) incorrectly. I’m not entirely certain what is occuring, but the proper use of splice includes a start index, a delete count and and the optional additions. Try ...splice(1,0,"...");.

    Alternatively, if you want the addition to come first in the array, ...splice(0,0,"..."); may be a better choice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to create a custom combo box component but I've been having
I am trying to create a Extjs combo box containing states where the user
I'm trying to use the method found here to create a custom combo box
I am trying to create a program whereby i import data from an excel
I was trying to create a custom combobox that inherited from ComboBox, but I've
I have a combo box and a datagrid in my page. when the user
Here is the set up, (all testing code) I have a combo box on
I have a Crystal Report I'm trying to recreate from scratch after an update
I am trying to create a simple dialog box to allow my user to
I am trying to create a combobox style widget (jquery-ui compatible) andcurrently I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.