Show button after two clicks Flash CS6 As2 - actionscript-2

I want to make my "button 3" visible after click in "button 1" and "button 2". How can I do it?
I have not tried any code cause I have no idea how to do this :p

You can use global variables for each bt and a listener for the last btn, for example, when you click bt1 replace the original value of the variable, lets say:
bt1 = 0; now could be bt1 = 1;
you write these somewhere in your first frame o in the root, just remember to point the right timeline if you write it outside your current timeline.
Let's say you write in the first frame of the root:
bt1=0;
bt2=0;
mybt._visible = false; //here you turn it off
onEnterFrame = function(){
if (bt1 == 1 && bt2 == 1){
trace("Say it Worked");
mybt._visible = true; //and here you turn it on
delete this.onEnterFrame;
}
}
Then each button must have something like:
on (release) {
_root.bt1 = 1; // or 2, depends on what button it is
// Your Actions
}
And your invisible button must have an instance name, in this case: "mybt"

Related

Kotlin how set a button listener to use another button inside it

There is a bookbutton and are around 10 buttons in my program each one contains a specific value.
How to make bookbutton save the data depending on what the user choose from the 10 buttons
This is simple code of what I've tried to do to link a button with the bookbutton.
var i = 10
button1.setOnClickListener {
bookbutton.setOnClickListener {
i++
textview.text = "$i"
}
}
You're setting the listener on button2 within the button1 click, not enabling it.
Try to do button2.isEnabled = true inside the button1 click listener, and set the button2 click listener outside of it:
var i = 10
button2.isEnabled = false // disable by default (you can do this in XML instead)
button1.setOnClickListener {
button2.isEnabled = true
}
button2.setOnClickListener {
i++
textview.text = "$i"
}

Auto choose, populate and click

I want to load the page https://game.ultimate-bridge.com/table/ in PhantomJS, choose tournament or 4-hand, populate table and board and then click the load hand.
I have mainly tried to click the button "Load Hand" but not even that is going well.
if ("complete" === readyState) {
console.log("if " + readyState);
var x = document.getElementById("root").querySelectorAll(".jss7.jss46.jss51");
x.click();
console.log("klick");
} // if-statement
The button do not get clicked
page.evaluate(function() {
var ev = document.createEvent("MouseEvents");
ev.initEvent("click", true, true);
document.querySelector("div.jss7.jss46.jss51 button[type='submit']").dispatchEvent(ev);
});

Is it possible to dynamic set menu items in a wxMenu?

Hi: I have in a wxFrame a menubar with this wxMenus: File|Edit|Personal. During the frame creation the wxMenu Personal has two wxMenuItems (Information and Need Help), which tells the user that must fill the form and help abou how to fill it. After the user fills the form with personal information, the menu is populated with new items: send, clear, check and remove, deleting/removing the previous ones... At this point I manage to trap the event, like this:
Bind (wxEVT_MENU_OPEN, &MyFrame::processMenuPersonal, this);
// the method
void MyFrame::processMenuPersonal (wxMenuEvent& event) {
wxMenu *menu = event.GetMenu ();
wxMenuItem *item = menu->FindItem (IDM_PERSONAL_EMPTY);
if (item) {
// here I want to dynamic add items and remove the current ones
}
}
Any ideas about how to do this?
Yes. Just append as submenu and treat it like any conditional statement. Here is a sample
void MyFrame::processMenuPersonal (wxMenuEvent& event) {
wxMenu *menu = event.GetMenu ();
wxMenu *item = menu->GetMenu(YOUR_MENU_INDEX);
menu->AppendSubMenu(item, wxT("User Items"));
if (YouConditionHere) {
item->Append(wxID_ANY, "Item 1")
item->Append(wxID_ANY, "Item 2")
item->Append(wxID_ANY, "Item 3")
}
}
Note that Items 1,2,3 are the information you want to append after processing your data (in your case deleting old entries)

How to pause a method until a condition is true then resume

Upon a button being pressed, i would like to begin tracking whether other buttons are being pressed.
Right now this is how i am attempting to do like this:
while(true)
{
if button1pressedbool and button2pressedbool
{
break
}
usleep(20000)
}
[self doMethodNowThatButtons1&2arePressed]
I need for the user to select another button before proceeding in this method, is there a better way to do this?
Edit: User...'s answer looks correct, does anybody have an example code of how to use and check a selector as he suggested?
There is a much better way to do this.
Set button1 tag to 0 and button2 tag to 1.
button1.tag = 0;
button2.tag = 1;
Then set the action for both buttons for the same selector.
In that method, check the tag of the button (use sender). If the tag == 0 set a BOOL button1Pressed to YES. Do the same for the other button.
This way, regardless of which button you pressed first, when button1Pressed == YES && button2Pressed == YES you can do whatever you want.

DynaTree has two highlighted nodes on right click after left click

My problem is whenever I left click a dynatree node then right click another dynatree node to display my context menu the node which was left clicked remains highlighted in blue so I end up with two nodes in blue. If I then right click successive nodes the highlighting works correctly but the left clicked node remains highlighted.
The left click processing clears the previous node on mouseup. I initiate context menu processing via
document.oncontextmenu=contextMenu
which is also called on mouse up.
I have tried to capture the right button mouseup event and make the context menu node active thinking that would change the state of the left clickked node but not so.
$("#tree").mouseup(function(e){
if(e.button == 2){
e.target.setActive();// right mouse up
}
});
How should I get the last left clicked node to unhighlight when another node is right clicked ? It does not look right to have two nodes highlighted at once. I have noticed the dynatree context menu demo does not unhighlight the previously left clicked node when another node is right clicked so is this by design ?? Can you get around it ?
Thanks,
Al
OK this works
In my myfile.js after I create the dynatree I added:
var dtnode; //dynatree node Global <--ADDED
var elem; //DOM node Global <--ADDED
Function BuildTree()
//ADDED following code after the dynatree was loaded
$("#tree").mouseup(function(e){
if(e.button == 2){ //RIGHT MOUSE UP
if(!(elem == null)){
var elem2 = e.currentTarget.document.activeElement;
dtnode = tree.getDtNodeFromElement2(elem);
dtnode.deactivate();
elem = null;
}
}else{//LEFT MOUSE UP
if(!(elem == null)){
elem = null;
}
elem = e.currentTarget.document.activeElement;
}
});
//In jquery.dynatree.js
//$Version: 1.1.1$
//$Revision: 481, 2011-03-02 07:25:35$
//The following changes were made:
getSelectedNodes: function() {
return this.tree.getSelectedNodes();
},
// AFTER THE ABOVE FUNCTION THE FOLLOWING FUNCTION WAS ADDED
getDtNodeFromElement2: function() {
return this.tree.getDtNodeFromElement2();
},
//********************************************************
getSelectedNodes: function(stopOnParents) {
var nodeList = [];
this.tnRoot.visit(function(node){
if( node.bSelected ) {
nodeList.push(node);
if( stopOnParents === true ){
return "skip"; // stop processing this branch
}
}
});
return nodeList;
},
// AFTER THE ABOVE FUNCTION THE FOLLOWING FUNCTION WAS ADDED
getDtNodeFromElement2: function(elem) {
var sourceNode = getDtNodeFromElement(elem);
return sourceNode;
},
Summary:
By keeping track of the last element to be left clicked and exposing the dynatree getDtNodeFromElement method through getDtNodeFromElement2 it is possible to call the deactivate method on the last left clicked node whenever the first right click of a node occurs. This eliminates simultaneous highlighting of tree nodes.
I need to add a short method I added to jquery.dynatree.js to make it work.
//--- Class members ------------------------------------------------------------
DynaTree.prototype = {
// Constructor
// member functions
getDtNodeFromElement2: function(elem) {
var sourceNode = getDtNodeFromElement(elem);
return sourceNode;
},
I know this is old, but I just ran into the same problem. When manually trying to manage 'dynatree-active' classes on nodes to force highlighting, I was having issues with multiple nodes being selected. By using a left click along with the right click, dynatree managed all of the selecting and deselecting active nodes.
$("#tree").mouseup(function(e){
if(e.button == 2) e.target.click();
});
I struggled with this one for a bit, I hope it can save someone some pain.
One more change I found while clicking around the display
Instead of
}else{//LEFT MOUSE UP
if(!(elem == null)){
elem = null;
}
elem = e.currentTarget.document.activeElement;
}
use
}else{//LEFT MOUSE UP
if(!(elem == null)){
elem = null;
}
elem = e.currentTarget.document.activeElement;
if(elem.tagName != 'A'){
elem = e.target;
}
}
This corrects a issue where the old highlighting problem reappears of a non A element is clicked.
Al