Access all views in ViewNavigatorApplication ( Flex Mobile Application )
// This is in my default view MXML
navigator.pushView(MainView);
navigator.pushView(SecondView);
navigator.pushView(ThirdView);
navigator.pushView(FourthView);
.......
// And this is where I try to gain access to my Views (in the Project.MXML)
var totalViews:int = navigator.length;//Length is 5 (4 Views plus menu which is wright)
var obj:Object;
for(var i:int = 0; i < totalViews; ++i)
{
obj = navigator.getElementAt(i);// Tried child here, it's not working either
var currentThumbnail:Preview = new Preview();
var bmData:BitmapData = new BitmapData( obj.stage.width, obj.stage.height );
bmData.draw(obj.stage);
currentThumbnail.setSize( m_previewH, m_previewW );
currentThumbnail.setBitmap( bmData );
currentThumbnail.setLayoutBoundsPosition(i * m_previewW + PREVIEW_GAP * i, 10);
slideMenu.addChild( currentThumbnail );
trace(i.toString() + " " + obj.toString());
}
As I mentioned above this for loop will successfully do the job for the current view then it will crash.Does anyone know how to loop through all the views?
This is my first application with flex so if there are any alternatives to my approach I'll be glad to try them. Although I'd like to stick with a single ViewNavigator as opposed to tabbed naviga开发者_开发知识库tor and multiple views instead of states, I don't mind suggestions from that side.
TIA.I'm pretty sure that for memory consumpation reasons Flex will not keep more than one instance of the view in memory at a time. So, looping over the number of views and trying to access the instance of that view will cause issues; because the view is essentially created every time it is displayed and destroyed every time it is hidden.
To do what you want to do, I think you're going to have to create the view snapshots on your own. Perhaps as in memory bitmaps that will exist even if the view isn't on screen. Or perhaps you'll want to save them temporarily to disk for memory purposes. Or even better, you could provide "pre-rendered" images.
Anyway, then keep a list of the images as they relate to the views and display them in your "Display Shelf" style menu.
精彩评论