Can anybody explain me , whats the difference this two
NavigationService.GoBack();
and
var rootFrame = Application.Current.RootVisual as PhoneApplicationFrame;
if (rootFrame != null)
rootFrame.GoBack();
Both of this will navigate to the previous page, but i want to know the difference between this two.
Thank you.
There's no difference, they call the same code internally.
Related
Can someone explain to me how to assign and use hasOwnProperty. I did search the web for a decent example but somehow didnt find any even at adobe( or maybe Im to "smart" to understand what it is saying )
so what Im trying to do is to set a propertie onto a MovieClip and after that to see if it exists.
var myMC:MovieClip = new MovieClip();
myMC.hasOwnProperty( "someRandomText" );
this.addChild( myMC );
if( myMC.hasOwnProperty( "someRandomText" ) ) trace(" yes it has it ")
else trace( "nothing here" )
output: nothing here
what am I doing wrong ?
and also :) how do I null/remove it after I add it to the MC
hasOwnProperty() checks whether an object has a property of that name. Basically, it'll return true if a property has an instance name matching the string.
The reason hasOwnProperty("someRandomText") returns false in your code is simply because myMC.someRandomText does not exist. Your second line seems to try making it but that's not what the function does.
A better test would be:
if( myMC.hasOwnProperty( "width" ) ) trace(" yes it has it ");
else trace( "nothing here" );
All MovieClips have a width property so this should return true. I haven't tested it but it should work.
The definition on the AS3 Reference is pretty much the best explanation you can get.
I need help, maybe I am blind. Here is a fragment of my code:
System.out.println("itemPropertyIDS="+item.getItemPropertyIds().toString());
System.out.println("argname="+argName);
Property<?> p = item.getItemProperty(argName);
if (p != null) {
System.out.println("p="+p.toString());
return p.getValue();
}
// Continue ...
It returns a currious null value instead of continue, even if the propertyId doesn't exists.
This is written on my console:
itemPropertyIDS=[iconName, iconResource, nodeType, nodeValue, nodeName, handler, nodeData]
argname=Lab
p=com.vaadin.data.util.IndexedContainer$IndexedContainerProperty#12967
The first row shows list of property names.
I expected getTtemProperty must return null, but not.
The item comes from IndexedContainer.
Can you help me? Any idea? Thanky You.
I tested your code and indeed - property p is not null even though property doesn't exist in IndexedContainer. Reading the comments of Vaadin ticket pasted by kris54321, it makes sense not fixing the bug as some applications may rely on that feature. Fixing the bug may break those apps.
Possible workarounds for this problem:
Check directly the propertyId-collection if property exists in the container:
if(item.getItemPropertyIds().contains(argName) {
Property<?> p = item.getItemProperty(argName);
System.out.println("p="+p.toString());
return p.getValue()
}
Change the logic to check property value
if(item.getItemProperty(argname).getValue() != null) }
//Do things
{
I was forced to make workaround using "item.getItemPropertyIds().contains(argName)". For me, the priority is to check whether the item contains the value (null possible) or not. If yes then I use the value (can be null) else another activity is done.
If they dont want to fix the bug due to application using the bug, then the documentation should be fixed, else all novices in Vaadin (as I am) will be confused.
The implementation in IndexedContainer$IndexedContainer is wrong:
#Override
public Property getItemProperty(Object id) {
return new IndexedContainerProperty(itemId, id);
}
This can never return null as the documentation says.
With the new ASC 2.0 compiler I get warnings when I code like below:
// (_achievementsFromServer is an Array)
while(item=_achievementsFromServer.pop())
{
// do something with item here
}
The warning reads: "Assignment within conditional. Did you mean == instead of =?"
While in general I appreciate all warnings from the compiler, I'd like to suppress this one in this case because I did not mean == here. I want to pop all items in the array and do something with it until the array is empty.
while( (item=_achievementsFromServer.pop())==true )
seems to work but looks a bit confusing. Any other ideas?
This may seem better.
while(_achievementsFromServer.length > 0) {
var item:Object = _achievementsFromServer.pop();
}
Just like removeChild
var d:DisplayObjectContainer;
while(d.numChildren > 0) {
d.removeChildAt(0);
}
While I was hoping for some other way, I think #AmyBlankenship improved my own suggestion:
while((item=_achievementsFromServer.pop())!=null)
{
//....
}
It's clear and understandable what's going on, and doesn't rely on checking the length of the Array on every iteration.
Googling some more I found a compiler option -compiler.warn-assignment-within-conditional that could be set to false but then you won't be warned anywhere in your project anymore. And I'm not so confident that I never accidently type = instead of ==, so that's not a good solution I think.
Trying to display a set of images from uComponents' MNTP, and can't get a value for the umbracoFile property - in the example below, both umbracoFile and url return empty strings:
foreach (var id in #Model.sliders) {
var media = Model.MediaById(id.InnerText);
if (media != null){
var url = media.umbracoFile;
<p>name = #media.Name</p>
<p>alt = #media.altText</p>
<p>url = #media.umbracoFile</p>
<p>url = #url</p>
}
}
It's getting really really really annoying... I've worked around it in other areas like so, using Model.Media:
<img src="#Model.Media("topRightImage", "umbracoFile")" alt="#Model.Media("topightImage", "altText")" />
But that will only help if with the media picker data type, not mntp. It shouldnt' be that difficult, should it?
I can get the images to load if I rebuild the internal search index, but they're gone again on subsequent refreshes.
I've seen others having similar problems, and would really appreciate a solution...
ta
Nathan
This looks like a bug that was fixed in 4.7.2. See the following codeplex item:
http://umbraco.codeplex.com/workitem/30778
I have an XMLList, I am trying to grab one from the list with a stone attribute == Opal but its not working, I don't understand why?
Here is the code:
var xml:XML = <bs><variation price="999999999.99" month="OCT" stone="Magic Pet Rock" image="https://www.sussexjewelers.com/birthstone_images/20_PE105-BT.png" style="PE105" gold_color="White" gold_carat="14"/>
<variation price="999999999.99" month="OCT" stone="Opal" image="https://www.sussexjewelers.com/birthstone_images/17_PE105-OP.png" style="PE105-OP" gold_color="Yellow" gold_carat="14"/>
<variation price="33212221.00" month="OCT" stone="Pink Tourmaline" image="https://www.sussexjewelers.com/birthstone_images/16_PE105-PT.png" style="PE105-PT" gold_color="Yellow" gold_carat="14"/></bs>;
var list:XMLList = xml.children();
trace(list) // returns all three variations
list = list.(#stone == 'Opal');
trace(list); // expecting to return the 2nd variation but actually returns nothing.
Can anyone see why this is not working as expected?
Thanks.
I postd this question right before I figured it out...I need to add toXMLString() when I trace it.
trace(list.toXMLString());