Referencing Flashbuilder Views by their string name - actionscript-3

I have a TabbedViewNavigator application with a navigatory bar which opens view just fine. In each view there is a ButtonBar that will open a new view related to the parent view. I have a single handler which decodes the name of the button and can build a string with the name of the view to be opened. I am looking for some way of referencing the view from this string, in a similar fashion to this["someName"] or getDefinitionByName("someName"). In my code, 'this' refers to the current view and the views that I need to find are not child elements. I don't know where getDefinitionByName() is looking, but it can't find the view either.
I have solved it temporarily with a switch statement, but this is not a good solution. Is there a view collection; if so, who is the owner of the collection or am I not going about this in the correct way.
Thanks for reading this far.

If the view is in a package/folder, you need to supply the full package to getDefinitionByName:
var viewClass : Class = getDefinitionByName("com.us.project.AwesomeView");
var view : DisplayObject = new viewClass();

Related

transitionViewForCurrentTransition is not set error

Here is my project:
It only crashes in iOS8.
I have 5 view controllers:rootViewController,A,B,C and D.Every view controller has a button that present another view controller except D. Evert time presenting a view controller, the Manager singleton object will add the presented view controller into an array. The last view controller D, which has a dismiss button, will use the array to dismiss view controller,and here's the code:
while ([Manager sharedManager].viewCont.count) {
UIViewController *viewController = [[Manager sharedManager].viewCont lastObject];
[viewController dismissViewControllerAnimated:NO completion:nil];
[self removeViewCon];
}
But I meet a crash,which shows:
I use some manage object because I want to manage the view controllers in some case.
My question is why this crash occurs when in "while" statement? Is it about runloop or iOS8 has some features like UIPresentationController that will not allow this case? And how to fix this?
Thanks in advance.
I just hit this also. It seemes the UIPresentationController crashes if it's presenting view disappears before it is done using it. One fix is to keep the view controller around a little bit longer.

How can you present modal UIViewControllers in MonoTouch using MvvmCross?

By adding IMvxModalTouchView to MyView, let the view become modal. But, I cannot change it at runtime. i.e. MyView must be modal every time. Is it possible to make it more flexible, let say, Show(MvxShowViewModelRequest view, bool isModal); ?
This area of MvvmCross is called "preesentation"
Other Mvvm frameworks may refer to it as "INavigationService"
Within MvvmCross, the presenter on each platform is 100% overrideable. Some examples and source code links are provided on http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html
If you want to implement some custom navigation hint, then:
all ShowViewModel calls have an presentationHint parameter - https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross/ViewModels/MvxNavigatingObject.cs#L40
the presenters receive these hints in the PresentationValues property of the MvxViewModelRequest in the Show call

When I navigate to a view, how do I link a viewmodel to it?

I have a basic MVVM light Windows Phone 8 app created. I have MainView, being shown as the startup page. This is automatically getting the datacontext of a new instance of MainViewModel.
I want to navigate to another view, and have a new viewmodel (or an existing one provided on navigation) set as the datacontext for that view.
How do I do this?
I have navigation working through http://mvvmlightnavigation.codeplex.com/SourceControl/latest#MVVMlightNavigationService/NavigationService.cs
Should I be using something else for navigation?
In the basePage tag in XAML
you can add your view model like this
<basepage:BaseApplicationPage
DataContext="{Binding YourViewModel, Source={StaticResource Locator}}">
Make sure the you have to registered the ViewModel with the same name that you are giving in the data context.
I am using MVVMlight, so ViewModel and View are registered in the 'ViewModelLocator'.
Hope this helps

Issue with Document Class and Tutorial

So I've been following this tutorial on AS3 and Flash. Its been going well until, note I have tried to contact the writer of the tutorial and had no reply. Here's what it tells me to do;
Right-click PlayScreen in the library, select Properties, and check Export for ActionScript. This time, instead of accepting the default value, enter the name of your document class. Click OK.
So it pops up an error, first we’ll have to make a new document class, since no two different objects can share the same class. Cancel the Properties box.
Hit File > New and select ActionScript File. Enter the (by now familiar) code.
Save this in the Classes directory as DocumentClass.as. (There’ll be no confusing the purpose of this file!) Now, back in your FLA, change the document class to DocumentClass.
Check everything’s fine by clicking that pencil icon — if it’s all OK, that should bring up the AS file that you just created.
// So this bits all fine, its the next that i'm stuck with:
Now you can set the PlayScreen‘s class to AvoiderGame. So do so!
// So I go ahead into the properties and change the name but then it pops up with the same error as before: 'Please enter a unique class name that is not associated with other library symbols'
What does this mean!? How do I resolve this!?
Full tutorial here:Flash Tutorial
Its hard to tell what you are trying to accomplish without knowing what all the parts you are referring to actually do, which are objects in the library and which are classes, but maybe this can help:
First of all, document class in AS3 typically refers to the project's main set of code that initializes the app. This class can be called anything but is often called Main, and is entered in the property panel that is displayed when you click the projects main stage in the field called class.
Now, when linking a class to an object in the library, its a little different. In the library object's property panel, tick the box for Export for Actionscript, and put a unique name in the top box. This is what you reference in your code to call it, like new somethingOrOther() or using the pic below as an exaample, new Ball(). The second box is the base class, pathed to where it lives in your code base. This is the class you will write that actually controls the object you've linked the class to. Giving a linked object a base class and a unique identifier allows you to use the same base class for multiple linked objects.
Note that when you do this approach, Flash will warn you that there is no class associated with Ball and one will be created for you. Don't worry, this is normal behavior. If you set this up properly, your object will still be controlled by its base class.

Preload dynamically created views in Actionscript for Flex Mobile App

I've got the following problem, my boss wants me to make our app far more responsive without any waiting time between switching views. It used to a "standard" application based on a ViewNavigator but with just one View that was destroyed and re-created with different content based on the user's selection of tabs he created himself. Views were switched with the default SlideViewTransition. I'm down to half a second now with a slightly more lightweight approach as described below, however that half second is still too much.
The app is a tabbed application where the user can create and edit new views himself, so create/edit/delete tabs and their corresponding tabs.
My current implementation is based on a ButtonBar and a Group that is used to display the "views". The group's content is created based on the selected tab. The content is based on XML data that stores all the required information to build the "view". Naturally, removing and creating the component's takes a little while (the half second I talked about), so I'm after another solution.
What I thought about is using the ViewNavigator and create all stored views upon application start.
Very much like this:
for each (var _view:XML in _allViewsConfig.children()) {
var compView:View = new View();
compView.percentHeight = 100;
compView.percentWidth = 100;
compView.name = _view.label;
for each (var _groupElement:XML in _view.vgroup) {
var group:VGroup = new VGroup;
group.percentWidth = 100;
group.percentHeight = 100;
for each (var _windowElement:XML in _groupElement.window) {
var window:WindowContainer = new WindowContainer;
for each (var _componentElement:XML in _windowElement.component) {
var component:UIComponent = _componentManager.create(_componentElement.#type, _componentElement);
window.addElement(component);
}
group.addElement(window);
}
compView.addElement(group);
}
views.addItem(compView);
}
views is an ArrayList that is used to store the created views.
The only problem I've got right now is that I can't use the Views stored in this ArrayList in the corresponding ViewNavigator.
I tried it the usual way, i.e. navigation.pushView(_viewCreator.views.getItemAt(0) as Class);
This, however doesn't work, no error or anything, the ViewNavigatorjust doesn't do anything, so I guess that a View class can't be created like this.
So how can I make this work?
Also, do you guys think that this is a proper solution to the problem, especially considering the whole dynamic nature of the application (being based on tabs)?
Naturally, slide transitions will be completely disabled as they are quite slow with our complex components.
Any help, comments or thoughts would be greatly appreciated!
EDIT:
On second thought, simply using Groups instead of ViewNavigator and View should make this a little more lightweight and solve the issue of views not being pushed.
In fact ViewNavigator pushView() is a mechanism which create an instance of a given Class (method parameter).
For all navigation history purpose, ViewNavigator uses NavigationStack objects to store relevant values (that you can customize too).
I don't have a straightforward answer for you, but I think you'll have to implement your own custom ViewNavigator mechanism (extending ViewNavigator to leverage existing useful methods and override others).