Main Thread (Suspended: ReferenceError: Error #1081: Property #data not found on Object and there is no default value.)
Hi All i am getting the above error when calling:
private function openStrm(event:Event):void {
if (event) {
getThingsInStrm(event.currentTarget.selectedItem.#data);
}
}
There is definitely a data property in the selectedItem i can see it in the watch/Variables window while debugging. I am not an as developer so i am a bit lost. Any help is appreciated! thanks
The selectedItem is usually an object form your dataProvider. Does that object contain a property named data?
Show us your actual data, and perhaps a runnable sample and maybe we can help more.
Related
I instantiated dynamically an object in main() and set it on context like:
Controller *controller = new Controller();
engine.rootContext()->setContextProperty("controller", controller);
After this point I don't have access to the pointer in c++ only in QML. At the end of the application I want to release the pointer (more specific in Component.onDestruction). I couldn't figured out how to do it in QML.
I tried controller.destroy() but it returns : Error: Invalid attempt to destroy() an indestructible object.
Also tried controller.deleteLater() but it gave me: TypeError: Property 'deleteLater' of object Controller(0x4914028) is not a function.
delete controller does nothing.
I've searched the documentation but couldn't found what I was looking for. Anyone has any idea? Thanks!
You can try to use a smart pointer so that it gets destroyed when it goes out of scope.
//main.cpp
QSharedPointer<Controller> controller =
QSharedPointer<Controller>(new Controller(), &QObject::deleteLater);
engine.rootContext()->setContextProperty("controller", controller);
I'm coding a generic <s:GridItemEditor> for spark DataGrid, to create dynamically an appropiate UIComponent for edition, depending on properties types.
Some properties linked to GridColumn's are complex, like:
var gridColumn:GridColumn = new GridColumn("Category.Description");
I'm having this error with this complex properties:
ReferenceError: Error #1069: Property Category.Description not found on GOClases.Person and there is no default value.....
at spark.components.gridClasses::GridItemEditor/set data()[E:\dev\hero_private\frameworks\projects\spark\src\spark\components\gridClasses\GridItemEditor.as:176]**
This is the specific function where this error ocurrs:
public function set data(value:Object):void
{
_data = value;
if (_data && column.dataField)
{
this.value = _data[column.dataField];
}
}
Is it possible to avoid this error redefining properly the set data() function?
How can I workaround this?
Is it possible to define differents properties as label and itemEditor in spark DataGrid?
Thanks a lot.
This is how I solved: it's make more sense assign Object type properties to GridColumn's dataField var gridColumn:GridColumn = new GridColumn("Category"); and use labelFunction to evaluate dynamically complex properties, I used r1.deval.D library here to resolve it:
private function funcionEtiqueta(item:Object, column:GridColumn):String
{
D.eval(complexProperty,item).toString();
}
Maybe this would help somebody else.
Thanks.
I've got a bindable model class (lets call it myModel) with two properties, label and value. The value gets updated frequently, so it is marked as bindable.
Works fine so far, the data is updated and the standard property change event is dispatched.
Now I have to make an ArrayCollection from the object instances of this model to use it as a data provider in a data group. The data gets then passed to a custom itemRenderer in which I access the myModel properties via data.label and data.value.
The only problem I've got now is that the myModel value property doesn't change any more (I suppose because I stored the objects in the ArrayCollection).
The ArrayCollection is marked bindable as well btw, because new object instances of myModel can be added during runtime.
Is there any way to make this work? Any help regarding this would be much appreciated!
Edit: I almost forgot, the value object in the myModel class is updated by another bindable class. Yes, I know that's bonkers but that's why I'm here, to get some input on a simpler (and in fact working) way to solve this problem.
2nd edit: Allright guys, a little bit of code to illustrate the issue;
Lets start with the first bindable class;
[Bindable]
public class FirstClass
{
public var name:String;
public var firstValue:Number;
public var secondValue:Number;
public var thirdValue:Number;
public function FirstClass()
{ }
}
The values (first to third) get updated by a controller class. So far so good.
Now to the second model class (for matters of consistency, lets keep the MyClass name)
[Bindable]
public class MyClass
{
public var label:String;
public var value:Number;
public function FirstClass()
{ }
}
These are the two model classes. Background behind this is that I need a String value (a label) for each property of an instance of FirstClass. I'd like to make this simpler, so I'm really not settled on this "solution" cough ;).
Anyhow, we've got the two models, now to my .mxml class;
[Bindable] private var firstClassInstance:FirstClass;
I create a new ArrayCollection and add objects like this;
myArrayCollection.addItem(new MyClass("This is a label", firstClassInstance.firstValue));
And again, the DataGroup uses this ArrayCollection as a data provider.
As we already established (thank you #Windowns), the ArrayCollection looks only for objects being added or removed, not property changes of these objects.
Call itemUpdated on your ArrayCollection when you update a "piece" of an item stored in it.
There could be many issues with binding. Please post code to help us see what is happening. Here are some "high level" things to watch out for that might answer your question
When using an bindable arraycollection of objects, it's important to note that the binding for the arraycollection only looks at each object instance and if it's added or removed from the collection. It will not know about any property changes that occur to your object. Commonly when you use an itemrenderer, the properties are bound to display elements. Like maybe the "value" property bound to a label in the itemrenderer. Now when your object instance (myModel) changes it's "value" property the label should pick it up. Also note that you need to mark any properties you intend to bind to visual elements with the [Bindable] meta-tag.
public class myModel
{
[Bindable]
public var label:String;
[Bindable]
public var value:String;
public function myModel() {}
}
Answer after code post:
When you do the following:
myArrayCollection.addItem(new MyClass("This is a label", firstClassInstance.firstValue));
You are taking the value of firstClassInstance.firstValue and supplying it as a hard value (as in not passing value by reference). So if you do the following:
myArrayCollection.getItemAt(addedClassIndex).value = 5;
Will not cause any changes to be noted in the firstClassInstance.firstValue as there is no "referening information" stored. We are only working with the basic type of Number which is never passed by reference like all other objects are in Flex.
Maybe try this:
[Bindable]
public class MyClass
{
public var label:String;
[Bindable] //might be redundant due to global [Bindable] flag, been a while since i've used a global one
public function get value():Number{
return m_objRef.firstValue;
}
public function set value(value:Number):void{
m_objRef.firstValue = value;
}
private var m_objRef:FirstClass;
public function MyClass(_label:String, _valueObj:FirstClass) {
m_objRef = _valueObj;
label = _label;
}
}
Allright guys (and gals ;)) after two hours of messing around with BindingUtils, I finally found the solution to my problem.
The two model classes can remain the way they are, so passing the instance of FirstClass isn't necessary.
Simply binding the value properties of FirstClass to the value field of MyClass works as expected and the values in the ArrayCollection get updated as well.
So the solution;
myClassObject = new MyClass();
myClassObject.label = "This is a label";
BindingUtils.bindProperty(myClassObject, "value", firstClassObject, "firstValue");
And then simply add the myClassObject to the ArrayCollection.
Keep in mind that all the code here is pseudo code, so never mind any typos.
Still, #Windowns suggesting with passing the FirstClass object to the MyClass will be incorporated into my final solution as it makes switching between properties a lot easier (FirstClass has got lots of them, not just the 4 in my first post). Many thanks for that!
I took Amy's advice and researched a little further on the itemUpdated method. Turns out, the solution was right there.
See here: http://flex4examples.wordpress.com/2009/08/28/1st/
I applied this methodology (with little variations) to my code and it works quite good. Performance on the iPad2 is good and so is the memory usage of my component.
Let's hope that Amy is fine with this solution as well. Fingers crossed. ;)
I am working on an indent and outdent for the advanced datagrid. I have a set of functions which work when operating on the underlying data fine, but which throw "Error: Bookmark no longer valid" when operating on the selected items of the datagrid.
When I run this code it runs fine:
indentLeaf(l5)
outdentLeaf(l4)
But this code fails:
adg.selectedItem = l5
indentLeaf(adg.selectedItem as Leaf)
adg.selectedItem = l4
outdentLeaf(adg.selectedItem as Leaf)
The code does not fail in all instances, only for some configurations of the data grid data tree.
The code needs to be run in the debugger version of the flash player if you want to see the error thrown. I have cut and pasted the error I get into the text area for reference as well as below.
The code in the toy app seems to recover ok when the exception is thrown, but in my larger app it leads to hard crashes.
Example code can be found here with view source turned on: http://www.crcarlson.com/adg/ADGArrayCollectionUpdate.swf
To create the error, reset the tree and then click "indent/outdent2"
I would appreciate any suggestions on how to get around this.
The full stack trace looks like this:
Error: Bookmark no longer valid.
at ListCollectionViewCursor/seek()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:2417]
at mx.collections::HierarchicalCollectionViewCursor/get current()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionViewCursor.as:220]
at mx.collections::HierarchicalCollectionViewCursor/collectionChangeHandler()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionViewCursor.as:1143]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::HierarchicalCollectionView/nestedCollectionChangeHandler()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionView.as:1595]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ListCollectionView/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1024]
at mx.collections::ListCollectionView/handlePropertyChangeEvents()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1433]
at mx.collections::ListCollectionView/listChangeHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1300]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ArrayList/internalDispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:673]
at mx.collections::ArrayList/itemUpdateHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:704]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at Leaf/dispatchChildrenChanged()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:119]
at Leaf/addChildAt()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:63]
at Leaf/move()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:96]
at ADGArrayCollectionUpdate/outdentLeaf()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:86]
at ADGArrayCollectionUpdate/IO2_clickHandler()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:113]
at ADGArrayCollectionUpdate/__IO2_click()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:183]
I just found a workaround for this bug (I am using SDK 3.5 but I guess a 4.1 fix would be very much the same). The problem lies within the "current()" getter of the HierarchicalCollectionViewCursor class.
It doesn't catch the CursorError that's caused by an invalid bookmark.
Step 1 is to create a better cursor class:
public class HierarchicalCollectionViewCursor2 extends HierarchicalCollectionViewCursor
{
public function HierarchicalCollectionViewCursor2(collection:HierarchicalCollectionView, model:ICollectionView, hierarchicalData:IHierarchicalData)
{
super(collection, model, hierarchicalData);
}
override public function get current() : Object
{
// original HierarchicalCollectionViewCursor class fails to catch the "bookmark no
// longer valid" Error, which is thrown as a CollectionViewError instance in ListCollectionView,
// but transformed to a CursorError within the same class
try {
var result:Object = super.current;
}
catch (e:CursorError) {
result = null;
}
// done
return result;
}
}
Step 2 is to create a HierarchicalCollectionView class, which returns that new cursor:
use namespace mx_internal;
public class HierarchicalCollectionView2 extends HierarchicalCollectionView
{
public function HierarchicalCollectionView2(hierarchicalData:IHierarchicalData=null, argOpenNodes:Object=null)
{
super(hierarchicalData, argOpenNodes);
}
override public function createCursor() : IViewCursor
{
return new HierarchicalCollectionViewCursor2(this, treeData, this.source);
}
}
Step 3 is to actually use that new HierarchicalCollectionView2 class as your data-provider.
var itemsAC:ArrayCollection = new ArrayCollection();
// add items etc
this.adgDataProvider = new HierarchicalCollectionView2(new HierarchicalData(itemsAC));
Now you would think that all is well BUT the drama wouldn't be complete without another annoying Flex-SDK bug. In this case its:
https://bugs.adobe.com/jira/browse/FLEXDMV-1846
So, Step 4 is to subclass the AdvancedDataGrid component as described in the bug issue.
That's it -- works for me!
This Exeption may hapen in Flex AdvancedDatagrid with HierarchicalData.
When items are added to Dataprovider it notifies the datagrid . the datagrid receives colection change events each time items are added to it.then some Datagrid internal can be messed up .
You could disable the automatic ArayCollecion refresh :
dataprovider.disableAutoUpdate();
and when you datagrid is ready to use refresh datagrid rendering :
if (advancedDataGrid) {
advancedDataGrid.invalidateList();
advancedDataGrid.invalidateDisplayList();
advancedDataGrid.expandAll();
}
I hope this will help.
Sami was right about the internals (of HierarchicalCollectionViewCursor) getting messed up. This was one of the most long-standing bugs in the Flex framework. It was recently documented - and fixed - at FLEX-34119 and all its linked tickets. It should be available in Flex SDK 4.14, which means that no workaround will be needed from that point onward.
im trying to getting auto complete working and i can do so fine when i just create an array in my mxml and then just initialize an arrayCollection at the top of the file in the initialize keyword.
However i want to populate the arraycollection from a webservice but i cant seem to get it;
im my application tag i have the following
creationComplete="init()"
initialize="data2 = new ArrayCollection(data1);"
then in my init method;
private function init():void
{
userRequest.loadWSDL(wsdlUrl);
userRequest.getAllCountries();
}
//this is called when i get a result from userRequest.getAllCountries();
private function getAllCountriesResult(e:ResultEvent):void
{
data1 = new Array(e.result);
}
however my text box is not getting any value.
Anyone with ideas?
first off, Array is not Bindable so changing the variable data1 will have no knock on effect.
The arrayCollection is bindable.
So presumming that the result (e.result) is actually an array (you should check this when debugging) then you could do the following
[Bindable]
priavte var ac : ArrayCollection;
then inside you're getAllCountriesResult function.
ac = new ArrayCollection(e.result);
then anything that has is dataprovider set to the var ac will be updated.
If you wish to update a text value inside a textArea or similar then you should listen for the change event in the arrayCollection and take the appropriate action then.
from your additional points below (just edit your original question)
I take it the autocomplete your talking about is the autocomplete text input box from adobe exchange area as a normal text box doesn’t take an arrayCollection.
If you posted some code it may make it easier to help you.
Preinitialize, then initialize, then creationComplete, then applicationComplete (this is the order they get called in).
If your using the component I’m thinking of, check out http://www.websector.de/blog/2008/04/30/quick-tip-avoid-issues-using-adobes-autocomplete-input-component-using-flex-3/
It appears it may have some issues with flex 3, so check out http://blogs.adobe.com/flex/2006/09/component_autocomplete_text_in.html .
Try this:
private function getAllCountriesResult(e:ResultEvent):void
{
data2.source = new Array(e.result); // or data2.source = e.result as Array
}
Make sure data2 is already initialized as a ArrayCollection.
As for AutoComplete, I'm trying to work things out myself.