Your code looks good to me, and I am doing the same and it works in both Android and destop AIR deployments/builds.
Have you debuged your application to ensure:
- The event is being fired and handled by your function
- The list.selectedItem Class is the same type your Details view is interfacing with (errors casting will result in null and view will not display data)
- The selectedItem object state is as expected (data model is populated)
- When the view(Details) is activated does its data property reference the selectedItem passed
My air app will not recognise 'navigator' and I didn't expect it to as a thought it was a mobile app class that I could not import and use in an air app. I am just using standard air desktop classes. Can I use navigator? And if so do you know what package it is in?
Oh, I see.
Your right if I remember correctly you implemented your own version of a ViewNavigator for your AIR application.
If you want to use the mobile components in your AIR application you need to add the swc to your project 'mobilecomponents.swc'.
You do this right click project->propertie, then select Flex Build Path and focus on the Library Path tab. Then click "Add SWC" and browse to 'C:\Program Files (x86)\Adobe\Adobe Flash Builder Burrito\sdks\4.5.0\frameworks\libs\mobile' and select the mobilecomponents.swc.
That should allow you to leverage the ViewNavigator in your AIR application. However, as your AIR app is not a MoblieApplication you will have to instanciate your own instance of ViewNavigator to use and push views to.
Hope that helps.
Have added the mobilecomponents.swc and am a bit excited now because I think this means I can revert to the more elegant mobile approach for my desktop app. Sorry to be really slow, and I have looked so as not to waste your time, but what import statement to I need so that I can instantiate my own ViewNavigator? Not sure what package the classes that come with mobilecomponents.swc are in.
Yes, with no API doc's kinda hard to figure out how to import.
A trick I have been using to find the imports is to use the code completion when defining a new variable type
Related issue. <windowedApplication> has no "firstView=" parameter. How can I auto switch views to my first view as per mobile app? I have tried calling a self made function gotoFirstView() on "creationComplete=" but can't get the compiler to recognise nagivator.pushview unless it is in a function associated with a view.
Concerning my additional query below I have now solved this via this useful post ...
The only thing now between a successful migration from mobile to air desktop seems to be applying the appropriate skins.
Have uploaded new post on this.
I came across an issue in the navigator.pushView function and wondered if you had any thoughts on it.
I have a scenario assigning variables from a list. My problem is the limitation of not being able to assign a variable which identifies the VIEW in a click event of the list.
In the list I have a 'click' handler that passes the list.selectedItem as the data element. However I want to choose the different VIEW based on another variable that I pass to the click handler but find I cannot pass the name of the VIEW as a variable. I tried this as a string, an Object but to no avail. It seems that the VIEW is a class and will not accept anything other than a Class in the navigator.pushView(VIEW , list.selectedItem) thereby not able to accept any other variable.
I have tried using
var SomeView:String = list.selectedItem.vPage.valueOf()
var SomeView:Object = list.selectedItem.vPage // where vPage was the variable string that was assigned from the data of the object in each ListDataItem
navigator.pushView(VIEW , list.selectedItem) // works because it is a static Class VIEW destination named VIEW
navigator.pushView(SomeView , list.selectedItem) // won't work because it cannot convert (SomeView) String or Object variable to Class
So if anyone has any thoughts on this it would be useful.
@Gerard Brandon - The first parameter of pushView() takes a Class, not a string or object. A new instance of the Class you pass in is then created.
For example this is correct:
But these are incorrect:
var newView:MyNewView = new MyNewView();