AdvancedDataGrid - access dataProvider - actionscript-3

I have AdvancedDataGrid and I wanted to access dataProvider.getItemAt(i) in function in my view.
I'm not getting any errors nor warning and the code is compiling, but when I run this function I get this error:
Property getItemAt not found on mx.collections.HierarchicalCollectionView and there is no default value.
Why can't I do this? I saw some samples ane people was using this function.
This is how I call it:
var x:Object = _dg.dataProvider.getItemAt(i);

The AdvancedDataGrid's dataProvider is a generic object. That, basically, means the compiler will let any property/method access on it slide without issues.
The HierarchicalCollectionView does not have a getItemAt() method, which is why you get the runtime error. The Hierarchical collection, by nature, contains nested elements I'm not sure how you'd access a single element using a single index.
You probably want to use some form of getChildren() or getParentItem() method to get access to an individual node.
The places where you saw getItemAt() work were most likely using an ArrayCollection.

Related

Passing object through components using service in angular 2

I have one doubt regarding the components communication using services.
Now I have one parent component, where I am rendering the list array of objects in parent component using NgFor. Whenever I click any particular item, a function gets triggered and specific object is passed in that function.
Then I am using subject and Observables to load that particular data in a child component. Everything looks fine, but here am trying to access that particular item before the triggering of the function, so in console.log am getting the errors like Cannot read property 'movie_id' of undefined)
add an *ngIf to child component regarding the particular data.. that way Angular doesn't try to access the 'movie_id' container object before it exists..
for example, if you have myObj = { ..., movie_id: 'tarzan' } add a *ngIf="myObj"

MS Access: Property defined with 'Form' return type in a interface gives user-defined type not defined compilation error

Looking for help writing an interface that has a property (or function) that returns an object typed as a "Form" (e.g. Access.Form as the return type).
Problem description:
The following simple example code returns a "User-defined type not defined" error if I attempt to compile the project.
I_TestInterface:
Public Property Get MyForm() as Form
End Property
cls_TestClass:
Implements I_TestInterface
Public Property Get I_TestInterface_MyForm() as Form
End Property
This is the only code/objects in a otherwise blank Access-2016 database and asking VBA to 'compile' produces a "User-defined type not defined" error. No lines are highlighted, it simply won't compile. Same occurs if replace 'Form' by "Access.Form"
My usecase is writing classes that wrap/hold a reference to a form internally - sometimes it is easiest to provide a reference to the underlying form so that consuming code can get at form properties without coding them all into the wrapper class.
Steps taken:
Lots of searches on 'user-defined type not defined' errors, in almost all cases this is due to a missing reference. Does not seem applicable since can create a standard module and happy to compile if write a function with a Form return type there. (*)
There was one previous SO thread on similar 'ambiguous' 'user-defined type not defined' error but I can't find it again and it wasn't specific to the 'Form' type in MS-Access
Have a clumsy workaround of providing property that returns an Object type that consuming code just has to cast to a Form (e.g. public property get MyFormAsObjectThatCanBeCastToForm() as Object).
(*). Possible clue? - if I just change the return types to object, the code still won't compile. I need to exit and use the 'de-compile' start up switch when relaunch Access. Then the above code with Object used as a return type is happily compiled.
Question / request:
Before I start re-installing Office, can others reproduce this?
Has anyone experienced this before? Developed a solution?
Thanks
PAHTDC

Flash Builder break on warning (of a binding error)?

I've injected some silly binding error in a large legacy project and am having trouble finding it.
This is the error output to the console:
warning: unable to bind to property 'length' on class 'String' (class
is not an IEventDispatcher)
I've tried stepping through with the debugger try to track down where this is happening but there are many thousands of lines of code and with event messaging, a very non-linear program execution.
Question: Is there any way to make Flash Builder break on a warning like this? If not, is there some other method, trick or hack for tracking this down?
This is caused by (wait for it...) trying to bind to a property that isn't marked as [Bindable]. In this case, you have a string variable whose length property is being used for data binding.
This is most likely caused by adding "myvar.length" as a property in the MXML tag for a component -- something like
<s:TextInput maxChars="{myInputString.length}" ...>
Flex will create the data binding for you automatically, but it doesn't realize at runtime that the property isn't Bindable - meaning, if there are changes to the property value the notification won't propagate to update the listeners.
Data binding uses mx.binding.PropertyWatcher to do the binding, and PropertyWatcher.updateParent is where the warning is output.

SharedObject and Dictionary problems in Flash Builder

I'm usin Flash Builder to create some actionscript code that uses SharedObjects.
First question: how can I delete my local SharedObject in Flash Builder? I am debugging my program and the SharedObject sems to persist between runs. I want to start fresh and clean with no SharedObject storing my data. How do I get rid of it?
Also, in my SharedObject, I used mySharedObject.data["mykey"] to store a Dictionary. This Dictionary will have String keys and values of MyCustomClass. The problem is that when I later try to loop over the values of this Dictionary, I get error #1034 cannot convert object to type MyCustomClass. It seems like I can put an item of type MyCustomClass into this dictionary, but I can't get the item back out as anything other than an object.
Any idea what is going wrong?
Those are essentially two questions, so should have been asked as two questions. Anyway, I'd answer them here but still prefer that you break them up in two parts (possibly leave a link to the other one here for reference sake):
Local shared object, are useful exactly for persistence across runs. And then there's SharedObject.clear() to clear the state as required.
For you second issue, Shared Object's serialize your object into AMF, so that it can be written to disk or sent over network using RTMP. Now, your custom class can't really be serialized in AMF. What actually happens is that the public properties (and dynamic ones, if the class is declared dynamic) are serialized into the structure. So, the public data is stored... but it's essentially a general Object.
To work around that, you can have a public static readFrom(object:Object):MyCustomClass type function, which would read the properties from the passed object to construct a new MyCustomClass representing that information.
There are ways to register your class with the player to be stored in SharedObject (see here)... but you need to make sure that the code that de-serializes that data is aware of the class as well.
To make a class available for conversion, in your global initialization use registerClassAlias() call with MyCustomClass and its fully qualified name as parameters. The manual. Say your custom class is foo.bar.TheClass, you write:
registerClassAlias('foo.bar.TheClass',foo.bar.TheClass);
In order to drop old SO use delete call against so.data["mykey"] and do so.flush(). Edit: SharedObject.clear() is way better.
1/ Being persistent is one of the particularity of a SharedObject. To cleanup all its content, you need to call the clear method.
var shareObject:SharedObject = SharedObject.getLocal('justatest');
shareObject.data.test = 'test';
trace(shareObject.data.test)
shareObject.clear();
trace(shareObject.data.test)
output
test
undefined
2/ To store complex data types in SO, you need to use flash.net.registerClassAlias (example here)

Return read-only ui component in Flex

In Flex, I want to create some variable that would hold a dictionary of ui components used throughout my application. Ideally, there would be a function in Application component that would return component for id:
public function getComponent4Id(id:String):UIComponent {}
Then I would access component using the following line:
var myComponent:UIComponent = FlexGlobals.topLevelApplication.getComponent4Id("someId");
Now, the only problem is: I want the component returned to be read-only.
It is very convenient to read some properties of myComponent from every corner of application, but I don't want my developers to abuse it and change myComponent.
Is it possible to return a copy of myComponent? Or is it possible to make it read-only somehow?
In the situation you describe, it is not possible to retrieve read only components.
You can create read only variables by implementing get methods without set methods. Something like this:
public var get myValue():UIComponent{
return UIComponent;
}
This would allow you to retrieve the UIComponent instance, myValue, from the component; but you would not be able to set it.
However, this would not prevent people from changing properties on the returned UIComponent unless those properties were also implemented as read only.
I'll add that there is already a method, getChildByName() to retrieve a child component by name. If you have an instance to a parent, you can use this to access the children.
All that said, I'm not sure I completely understand what you hope to achieve; with this functionality.