Spinner SelectedItem and ItemsSource - mvvmcross

I have deserialized my spinner object, and loaded it in the view model (the property is then bound to SelectedItem). Mvx keeps saying that it could not find the spinner object, that the spinner SelectedItem cannot be null.
I realised that the deserialized spinner object was not part of ItemsSource, since it was deserialized from json. Therefore I searched the corresponding item in ItemsSource and replaced the SelectedItem with the correct object. Now it works.
Is there any cleaner way of doing this? Perhaps I should implement IEquatable in my object. Please advise.

the deserialized spinner object was not part of ItemsSource, since it was deserialized from json. Therefore I searched the corresponding item in ItemsSource and replaced the SelectedItem with the correct object.
I'm not entirely sure what you are asking.
However, hopefully this helps: there is an example of using Equals to provide object matching in a Spinner in https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Core/ViewModels/ViewModels.cs#L105

Related

How can i get return data from listener?

I am testing some code and facing some problem that in using listener. I want String return data from mouseListener. when some label is clicked, mouseListener return that label's data like that. Pls Help!......
Edit ...I have referenced some code from this site at autoComplete category. And I test to use this by creating object for each textfield (e.g ....first autoComplete object for first textfield and second autoComplete object for second textfield ,etc..). But when I created second object, the first one was unresponse. Here is my code link .....
http://www.mediafire.com/download/op9mfpkyughrq3d/AutoCompleteImp.rar

AS3 - What happens when an object that is executing code is removed?

What happens when an object which has a function currently being executed has all its references removed?
I want to have a dialog box type object held in an array by the main class for my program, and when the dialog needs to be closed, I want it to be removed from the array during that close-screen function. My question is, assuming the dialog box object is in all other ways eligible for garbage collection, what happens to the code it's supposed to be executing?
Edit for clarification:
The array is a layer of visual elements in my program, of which the dialog box is one. The idea is that the "OK" button (or whatever) that closes the box will also remove it from the array of objects being displayed at the same time.
Your object won't be eligible for garbage collection if there is something referencing it (in your case to call a method within it).
If you want to make your Dialogue Box eligible for garbage collection from within itself, you'll need to add a method that deals with self-removal from arrays that it may be within, etc.
Yours may look like this.
public function destroy():void
{
var ix:int = someArray.indexOf(this);
someArray.splice(ix, 1);
if(parent)
parent.removeChild(this);
// ...remove event listeners, etc
}
If all references to the object have been removed while a function of this object is being executed, the rest of the function will keep executing. When it's done, the object will be removed during the next garbage collection cycle.

What is the complementary event of 'show' for flex displayobjects

Since flex memory management is poor, objects once instantiated dont die very easily (even when they go out of scope), one would need to check on various properties of components. I am using one such thing to know if the screen (which is a display object) is in current view. For this I am turning on a boolean property (currently visible), and I am setting it true on show event of the display object.
What I need to know is, which event (something opposite of show, e.g left?) could be used when the screen is replaced by another display object?
Something like focusIn and focusOut from dotnet.
Or if there is some property which could directly tell me if the display object is currently in view (hasFocus doesnt seem to be giving me expected results).
Thanks.
You can Use PropertyChageEvent check the documentation and base of the newValue and kind property you can do some action :
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/events/PropertyChangeEvent.html
hope this help
Name of the event is: removedFromStage.

TweenLite does not work with object

I got the following problem:
I have an object called tempScore for my game.
This object is blitted to the canvas by a renderer via the copyPixels method. The object is NOT a display object. It's a Score-object (self made). The Score-object extends an object called BasicBlitArrayObject. The BasicBlitArrayObject extends an EventDispatcher (therefore no display object).
I tried to apply several different TweenLite-plugins to my tempScore-object (i.e. TransformAroundCenter, colorMatrixFilter, etc.). But nothing happens. Absolutely nothing.
Sometimes I get error messages (when a plugin requires a display object and my object is NOT a display object). So far so good.
According to Greensock (maker of Tweenlite) his engine can tween ANY numeric property of ANY object. So when a plugin like TransformAroundCenter requires a display object for tweening I have to modify the plugin to get it working for my non-display object (tempScore). Currently I can't do that because it's way too hard for me.
My game rests upon this code:
http://www.8bitrocket.com/book/ch11_blastermines.zip
Try to apply TweenLite with an object called tempMine inside the game class BlasterMines. It won't work. Any help, please?
Greensock's claim is correct, in it's exactness. You can tween any numeric property of any object. This statement does not include the application of plugin features.
The reason that the TransformAroundCenter and ColorMatrixFilter plugins don't work for you is that they each utilise some property or method of DisplayObject. In the case of transformAroundCenter that's DisplayObject.localToGlobal() and for ColorMatrixFiler it's DisplayObject.filters.
I have to ask why you're applying these plugins to something that is not a display object? In blitting (as it applies to AS3), the basic idea is that you read an area from a sprite sheet to a BitmapData object, which in turn you write to a Bitmap object on the stage. Both BitmapData and Bitmap extend DisplayObject, which is what you need. For higher compatibility you should target the Bitmap object that is actually on the stage, TransformAroundCenter will not work correctly with an object that is not on the stage.
For a better answer you will have to post some code, and possibly a screenshot from a debugger like Monster Debugger 3 which shows your expanded display tree.

flex datagrid re-assign dataprovider

I am working on a datagrid with custom itemRenderer & [Bindable]xmllist as dataprovider. Now the changes done in xmllist are not reflected on datagrid UI until unless I re-assign the dataprovider as the same xmllist.
As the dataprovider is Bindable so re-assigning is not required.
But it was not working so I re-assigned the xmllist to the dataprovider of datagrid. It worked.
Now my problem is when I re-assign the dataprovider my datagrid flicker(refreshes). It should not happen.
1) Is there any way out to avoid re-assigning of dataprovider?
2) Is there any way to stop flickering of datagrid on re-assigning the dataprovider?
Thanks in advance.
I think xmlList, along with xml are not able to be bound for whatever reason, so binding doesn't work with them. You could convert your xmlList to an arrayCollection and bind to that. The flicker would probably have something to do with your custom itemRenderer, but I think we would need to see the code to know more.