How do a dragDrop() with the right mouse button? - sikuli

Does anyone know how to do a dragDrop() with the right mouse button?
I got this example code:
image = ("image.png")
App.focus('<nameProgramHere>')
imageE = find(image)
rightClick(dragDrop(imageE, imageE.offset(Location(0, -250))))
It does make a rightclick, but the dragDrop() is preformed with the left mouse click.
(I can see this becasue the colour is then different in my program.)
I do see the rightClick() in my log.
[log] RIGHT CLICK on L(1039,556)#S(0)[0,0 1920x1080]

Found the answer myself on how to drag and drop with the right mouse button.
image = ("image.png")
imageE = find(image)
imageE.hover()
wait(2)
mouseDown(Button.RIGHT)
mouseMove(imageE.offset(Location(0,-250)))
wait(2)
mouseUp()

Related

How to make another ImageButton appear when hovering over ImageButton

How can i make so that if i hover over a imagebutton another imagebutton appears over that imagebutton and when you move your mouse outside it returns back to the first imagebutton? I have tried a lot of combinations but nothing so far.
So far i have tried
ImageButton(Drawable imageUp,
Drawable imageDown,
Drawable imageChecked)
but the setChecked(boolean isChecked) hasn't worked for this method and when using focusListener it turns the ImageButton into another ImageButton when you hover over it but it doesn't return to its first stage when you go outside the ImageButton. Any help appriciated.
Instead of using imageDown use imageOver.
According to my understanding:
imageUpdefault button
imageOverwhen the mouse/focus is over the button
imageDownwhen the button is pressed (the mouse is clicked)
imageCheckedwhen the button has the status checked
imageCheckedOverwhen the button has the status checked and the mouse/focus is over the button
imageDisabledwhen the button has the status disabled
You can use the ImageButtonStyle for this. Pass it to the consructor of your button or use the appropriate setter.
ImageButtonStylestyle = new ImageButtonStyle();
style.imageUp = imageUp;
style.imageOver = imageDown;
style.imageChecked = imageChecked;
Ps.:
I assumed you do not really want to change the button, just the displayed image.

How to make text disappear when mouse is not on object?

I have objects and they show texts when the mouse is over them. I used MOUSE_MOVE event for this. The problem is when mouse leaves the object, the text stays at the last position. I want it to disappear till the moment mouse will touch the object again. How to do it?
EDIT
I found out MOUSE_OUT or ROLL_OUT works very well. The only problem now is, when I'm on object and text shows up, when I move my mouse fast enough over the text, it blinks. I think it's because text is over the object and when I'm on text, I'm not on object anymore. So I'll just move the text a little away from the cursor. Thanks for answers :)
import flash.events.MouseEvent;
import inventory.inventorySystem;
import inventory.item;
import flash.text.TextField;
var IS:inventorySystem;
var IT:item;
apple.itemName = "Apple";
apple.itemIcon = new AppleIcon();
apple.addEventListener(MouseEvent.MOUSE_MOVE, showItemNameF);
apple.addEventListener(MouseEvent.MOUSE_OUT, hideItemNameF);
pear.itemName = "Pear";
pear.itemIcon = new PearIcon();
pear.addEventListener(MouseEvent.MOUSE_MOVE, showItemNameF);
pear.addEventListener(MouseEvent.MOUSE_OUT, hideItemNameF);
function showItemNameF(e:MouseEvent):void{
var itemNameBox:String;
itemNameBox = item(e.currentTarget).itemName;
stage.addChild(infoBoxObject);
infoBoxObject.infoBox.text = itemNameBox;
infoBoxObject.x = mouseX;
infoBoxObject.y = mouseY;
}
function hideItemNameF(e:MouseEvent):void{
infoBoxObject.x = -145;
infoBoxObject.y = 61;
}
Simply you can make the Enabled to false and if the MouseOver-Event then enabled true.
If you are using the MOUSE_MOVE event, please be aware that this event fires constantly while moving your mouse. This can in certain cases cause your app to slow down if you execute to much logic on this event. (just a side note)
If you are using MOUSE_MOVE, you could use the hitTestObject() to check if you're touching the text container (There are a lot of examples to be found out there on how to accomplish this).
Preferably, you would use a mouse enter and mouse leave event on the container of the text.
For more help you would need to give us some code examples.

RollOver and RollOut effect in buttons

I'm using the code bellow to change the color of button on rollover and rollout and clicked. I have following issues in this
1. The color did not changed when button is clicked.
2. Button wont work after once clicked.
pages.gotoAndStop("home");
// list of button instance names
var previousClicked:DisplayObject;
var buttonsss:Array = [home, menudown.about, menudown.portfolio, menudown.clients, menudown.pricing, menudown.contact];
for each ( var mc:MovieClip in buttonsss)
{
mc.buttonMode = true;
mc.mouseChildren = false;
mc.addEventListener(MouseEvent.MOUSE_UP, onClick);
mc.addEventListener(MouseEvent.ROLL_OVER, rolloverEffect);
mc.addEventListener(MouseEvent.ROLL_OUT, rolloutEffect);
}
function onClick(e:MouseEvent):void
{
pages.gotoAndStop(e.target.name);
e.currentTarget.mouseEnabled = false;
TweenLite.to(e.currentTarget,2,{tint:0x666666, ease:Strong.easeOut});
TweenLite.to(previousClicked,2,{tint:null , ease:Strong.easeOut});// set the previous clicked to null tint
previousClicked.addEventListener(MouseEvent.ROLL_OUT, rolloutEffect);// restore the Roll_Over effect
previousClicked = DisplayObject(e.target); // update the last clicked button
e.target.removeEventListener(MouseEvent.ROLL_OUT, rolloutEffect);
}
function rolloverEffect(e:MouseEvent):void{
TweenLite.to(e.currentTarget,2,{tint:0x666666, ease:Strong.easeOut});
}
function rolloutEffect(e:MouseEvent):void{
//should change tint to null just when its enabled, but its changing always (enabled or disabled)
TweenLite.to(e.currentTarget,2,{tint:null , ease:Strong.easeOut});
}
How I have always done this is with the built in buttons instead of doing it with code.
If you click window up in the top bar then click on components (near the bottom) it will bring up a little window then if you expand the user interface folder and drag and drop from the button item. Then with that button on the stage if you double click on it you will go into the edit symbol screen and it will have pictures of each state that the button and if you double click on the state you want then you can visually edit that version of the button.
Hope this helped.
Note: I first started with flash pro-cs5.5 and your tag says flash-cs5 I don't know for sure if that function is available or not in 5.
I am unfamiliar with Tweenlite, but I'm guessig that what it does in this case is simply change the color, am I right? If so, I'd suggest creating the color changes on your timeline and using framelabels combined with gotoAndStop to create the different effects. This should also solve your problem concerning the button not working after it has been clicked once.

AS3 - Unable to capture button click when using Mouse Move listener

In my first AS3 project (not used Flash since AS1) I need to use a custom movie clip as a cursor and detect clicking on a button. Using the code below, the custom cursor works as expected, but I am unable to capture clicking on the button.
If I comment out the first line, the trace for clicking works as expected. I have tried changing the order of the event listeners, applying the follow to the button rather than the stage, but cannot get both to work together.
Any advice as to where I'm going wrong ould be appreciated.
stage.addEventListener(MouseEvent.MOUSE_MOVE,follow);
start_button.addEventListener(MouseEvent.MOUSE_UP, playPhrase);
function playPhrase(event:MouseEvent) {
trace("Click received");
};
function follow(event:MouseEvent) {
cursor.x = mouseX;
cursor.y = mouseY;
};
Looks like that's because you always click on the cursor object as it always positioned right under mouse cursor. Make it "transparent" for mouse clicks:
cursor.mouseEnabled = false;
And if it's a DisplayObjectContainer then also:
cursor.mouseChildren = false;

Adobe cs5 actionscript 3

I'm doing a simple drag and drop number game for kids. Once the user places all the numbers and presses the go button (btn_go) how do I get a another button appearing after the user has click the go button?
I think you ask about "How get DisplayObject by name in Flash, from main stage?"?
If I'm rigth
stage.getChildByName("nameOfMyAnotherBtn");
btn_go.addEventListener(MouseEvent.CLICK, btnGoClicked);
function btnGoClicked(evt:MouseEvent):void {
another_button.visible = true;
btn_go.visible = false; //Optionally hide button go
}
Likewise, if you wanted to show/hide btn_go when another_button is clicked it's the same idea.