I'm currently working on some code for a project. The question is about targeting child with a unique parent. For example. Let's say I have a box people can move called box_mc and 3 platforms it can jump on called:
Platform_1
Platform_2
Platform_3
All of these platforms have a child element called hit.
Platform_1
Hit
Platform_2
Hit
Platform_3
Hit
I use an array and a for each statement to detect if box_mc hits one of the platforms childs.
var obj_arr:Array = [Platform_1, Platform_2, Platform_3];
for each(obj in obj_arr){
if(box_mc.hitTestObject(obj.hit)){
trace(obj + " " + obj.hit);
box_mc.y = obj.hit.y - box_mc.height;
}
}
obj seems to output the unique parent it is hitting but obj.hit ouputs hit so my theory in this is that it is applying the change of y to all the childs called hit in the stage. WOuld it be possible to only detect the child of that specific parent?
Thanks in advance again guys!
Related
I've been looking for the difference of ExitRule and EnterRule in Listener in "the definitive antrl4 reference" book but I still don't understand the difference. What is the difference between these two? And how does Listener travel the tree?
simply said, these are auto generated events created by Antrl
to keep track of the walker, so to speak.
Imagine, you stand in the middle of a long floor with countless doors on either site. Which you have to open and something in the rooms.
To keep track on which doors you've already visited, you mark them with a X and an incrementing number behind.
enterRule == You opens the door of a room.
you get in and search
exitRule == leave the room and paint the X and the next number on the door.
Now you are able to tell exactly which rooms you have already visited, but further more you are able to go to a specific room again for another search, without having to go all the way back and start all over again.
more technically spoken.
Antrl creates an enter and exit method for each Rule that is defined.
These Methods, or also known as callbacks, being used by the walker to walk the given tree.
Using a *ParseTreeListener you provide an entry point which indicates the beginning of the tree. For example enterAssign.
The Walker looks for this event and triggers it.
It then looks for a sub enterRule to trigger this event, and so on...
It keeps walking for as long as it find further enter rules or triggers exitAssign and the walker stops its walk.
Keypoint here is the automated or indipendent walk behavior.
The ParseTreeVisitor on the other hand,
will not generating enter/exit Rules to walk a tree.
It will generate visitRule instead.
The visit methods have to be called explicitly!
That means, if you forget to invoke a visit all its children don't get visited at all.
Antrl-Doc --> Parse Tree Listeners
Antrl-Mega-Tutorial --> many Information, short and precise
Tree Walking
Walking starts from a Root-Node and goes down on it until it have found the very left-most nested item. Then goes back up until it reaches the first node and looks for a sub-tree on the right.
It enters the right tree if one is found.
Or, it gets futher up the chain to find the next node.
...
Until it reaches the Root-Node again.
short Picture:
parent
|
/ \
/ \
Child1 Child2
/
/
Grandchild
chain of Calls:
enter parent
enter Child1
enter Grandchild
exit Grandchild
exit Child1
enter Child2
exit Child2
exit parent
I want to achieve the following process. The scripts are written in Katalon, but it does not matter. Selenium approach is enough.
I test an appearance of two elements in a dialog window. If a text message appears, the second element will not come and the dialog window is closed. If the first element (message) is not displayed, a button that displays after a certain amount of time is clicked.
I would like to continue and avoid using wait until element is visible/invisible. I do not know how to do it, but any action is triggered first it will go through it.
The problem is that the test waits for the message for the certain time and if it not displayed in (let say 30 sec), it clicks on the button. I want to avoid to wait until it is visible, and instead of waiting just to click immediately on the button. So the aim is to track two parallel actions (not selenium actions) and which one is fired first. Is there any approach? Maybe using tasks?
Here is the code:
TestObject dialogWinEl = findTestObject("Object Repository/FinacDocAndPayments/dialogWindow/div_dialogWin")
WebUI.waitForElementVisible(dialogWinEl, GlobalVariable.TIMEOUT_ELEMENT, FailureHandling.OPTIONAL)
TestObject statusMsgFilesDownloadEl = findTestObject("Object Repository/InvoiceDetailPage/div_dialogWin/span_noDocFoundStatus")
boolean noDownloadFiles = WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL)
if(noDownloadFiles){
KeywordUtil.markPassed("No files found to download. Closing dialog")
}
else{
KeywordUtil.markPassed("Files found. Click on Download files")
TestObject btnEl = findTestObject('Object Repository/InvoicesAndPayments_Global/btn_generic', [('btn_text'):btnName])
WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(btnEl)
KeywordUtil.markPassed("File downloaded. Closing dialog window")
}
TestObject xBtn = findTestObject('Object Repository/InvoicesAndPayments_Global/confDialog/div_closeBtn')
WebUI.waitForElementClickable(xBtn, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(xBtn)
KeywordUtil.markPassed("Dialog window has been closed")
Basically the variable noDownloadFiles is equal to the status of the particular element (visible or not) and it waits for the time that is in the var GlobalVariable.DOWNLOAD_BTN = 20sec. The problem here is if this variable is false it means that it waited for the specific amount of time and then it continues in the else branch. The point is if the button appears earlier it does not have to wait to see if statusMsgFilesDownloadEl is visible or not.
I simply want to use this:
WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL)
and
WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT)
and once the first or second is evaluated it continues. There is no reason to wait for one and then for the other.
I have a test case that shows that angular element.remove() removes elements from the DOM sometimes, and fails miserably at other times even though I don't see an error. Here is the JSFIDDLE.
To see it working, click the Search button (no need to put in any data in the input field). This does two things:
deletes elements above the field and
deletes any elements below the fields (nothing to delete the first time around) and adds new ones.
This is the code that should clear out the elements below the search button.
$scope.searchTargets.forEach(function(target){
var resultNode = angular.element(document.getElementById('id_' + target.name));
if(resultNode != undefined)
resultNode.remove();
Repeatedly clicking on the search shows that the number of elements below the search button keeps increasing - even though it should really be staying at 3 elements. Why does the remove() method fail here?
Take a look at this forked fiddle:
http://jsfiddle.net/wcca93qc/
You need to reset the search results during each search using $scope.searchResults = [];
I also refactored to code a bit, to merge 3 loops that basically can be done in 1 loop.
This AppEngine task seems like it should be trivial to do but I haven't quite worked it out. I have some data in a GrandParent/Parent/Child relationship thus:
EntityName Key
----------- -------
GrandParent W
GrandParent X
Parent W.A
Parent X.A
Parent X.B
Child W.A.i
Child X.A.i
Child X.A.ii <=== matches X.*.ii
Child X.A.iii
Child X.B.i
Child X.B.ii <=== matches X.*.ii
I'm trying to construct a query that matches all children with keys X.*.ii. In other words, it would return the keys X.A.ii and X.B.ii from the above, and nothing else. I'm using the low-level query mechanism, and what I have so far is this:
Entity gpX = new Entity("GrandParent","X");
Query q = new Query("Child");
q.setAncestor(gpX.getKey());
Which returns five children. If the i/ii/iii attribute was a property and not a key this would be trivial, but it is a key, and it is not clear to me how to specify that 'ii' is a search criterion.
There's no way to do this without a separate property. All filters in the App Engine datastore have to be either equality or range tests (which are equivalent to string prefix tests); it's not possible to filter in the way you're describing using a single filter.
My 1st question here on stackoverflow.
I am trying to print a long grid, which was dynamically generated.
pdoc.PrintPage += (p, args) =>
{
args.PageVisual = myGrid;
args.HasMorePages = false;
};
When I use args.HasMorePages = false;, it prints the first page of the grid as it should (although it takes some time, since it sends a 123MB big bitmap to the poor printer - thanks for silverlight 4's print feature implementation.).
However, when I enable printing more pages withargs.HasMorePages = true;, the printing job runs amok on the memory and sends endless copies of the first printing page of the document - effectively disabling my developer machine. Even if the grid is only 2 pages long.
Why does this happen?
What is a possible workaround here? All I found on the net is that SL handles printing badly, but not a real solution.
The HasMorePages property indicates to silverlight printing that you have a least one more page to print. The PrintPage page event fires for each page to be printed.
Hence when you set HasMorePages to true you will get another PrintPage event, if you always set it true (as your code appears to be doing) you are creating an infinite loop.
At some point the code has to leave HasMorePages set to false.
Ultimately its up to you the developer to perform all the pagination logic and decide what appears on each page, Silverlight does not automagically do that for you.