Skip to main content
Participant
Sep 14, 2018 12:39 PM UTC
Answered

HTML 5 Canvas Combo Box

Hi,

I need to create a simple drop down menu that when a certain option is selected it takes you to a certain frame.

So for example when Location 1 is selected from the drop down menu it goes and stops at frame 21.

I have the code in AS3 but it needs to work in HTML5 Canvas and I have very little experience working with JS.

Is someone able to help ??

Here is my AS3 code:

stop();

combobox.addItem( { label: "Please choose a location" } );

combobox.addItem( { label: "Location1" } );

combobox.addItem( { label: "Location2" } );

combobox.addItem( { label: "Location3" } );

combobox.addItem( { label: "Location4" } );

combobox.addEventListener (Event.CHANGE, changelocation);

  function changelocation (event:Event) :void{

  if (combobox.selectedItem.label == "Location1") gotoAndStop (21);

  if (combobox.selectedItem.label == "Location2") gotoAndStop (22);

  if (combobox.selectedItem.label == "Location3") gotoAndStop (23);

  if (combobox.selectedItem.label == "Location4") gotoAndStop (24);

  }

This topic is closed to new replies. Start a new post to keep the conversation going.
kglad
kgladCorrect answer
Community Expert
Sep 14, 2018 1:43 PM UTC

click window>code snippets>html5>components>combobox to see:

if(!this.cb_change_cbk) {  // where this.cb is your combobox

function cb_change(evt) {

// Start your custom code

console.log(evt.target.value);  // use switch/case or multiple if-statments

// End your custom code

}

$("#dom_overlay_container").on("change", "#cb", cb_change.bind(this));

this.cb_change_cbk = true;

}

if that isn't enough info to answer this (and many more questions), repost.

7 replies

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
Sep 14, 2018 1:43 PM UTC

click window>code snippets>html5>components>combobox to see:

if(!this.cb_change_cbk) {  // where this.cb is your combobox

function cb_change(evt) {

// Start your custom code

console.log(evt.target.value);  // use switch/case or multiple if-statments

// End your custom code

}

$("#dom_overlay_container").on("change", "#cb", cb_change.bind(this));

this.cb_change_cbk = true;

}

if that isn't enough info to answer this (and many more questions), repost.

Translate
Participant
Apr 2, 2021 7:44 PM UTC

balasan pekok kglad itu.itu ms newbie bertanya,pelit amat

 

Translate
kglad
Community Expert
Community Expert
Apr 2, 2021 7:59 PM UTC

if you have a question, you'll need to explain it more clearly (or maybe find someone that can read your text without using a translation tool).

Translate