so I am trying to assign a number to a variable that is dynically generated from a binded array...when i try and assign it and trace it out nothing happens, which means I am obviously doing something wrong but I am not sure? just for fun i decided to bind the data to a label like so...
<s:Label text="{this.dd.selectedViews.length}"/>
and that work and updated properly, but when running in debug mode i got this warning...
warning: unable to bind to property 'length' on class 'Array' (class is not an IEventDispatcher)
so what would be the best method of assigning the array to a variable to use throughout my application
thanks in advance for any help
I'm not really sure what you are asking here, but maybe this will help you out. As your error message says, the Array class is not an IEventDispatcher. What that means is that if you try to use a plain old Array as the source of a data-binding expression, it generally is not going to work.
If you need to bind to an array, you can try using a different class such as ArrayCollection, which supports data binding.
Related
I would like to achieve the following in visual basic. Is it possible to be able to have the reference change with each iteration inside the for loop? I have an array of object names (as Strings) stored in "objectArray" that contains the names of objects with the property "valuePath". I would like to change the property of "valuePath" for each object from "objectArray" in one for loop. I do not want to statically call each of the objects manually. I can access the property of the object by calling "Me.objectName.valuePath" from inside the method where this code exists.
For item in objectArray
Me.item.valuePath = "some value"
Next
Any help would be greatly appreciated! Thank you.
I ended up saving an array of Objects instead of an array of Strings and that solved my problem. Thank you for your assistance!
I have an array in my main
public var graphArray:Array = [1,2,3,4,5,6];
And I'm trying to access it from within a MovieClip that I've put on my timeline using:
var graph1scale:Number = MovieClip(root).graphArray[0]
It looks like it would make sense to me but when I try to run it I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Am I wrong to be using MovieClip(root) to try and access it? I've only just started using external classes (this is my first project doing so) and usually I just do everything on the timeline. So MovieClip(root) is familiar to me but I guess it's not the right thing to do here.
Is there a way I can access vars from Main.as?
-----SOLVED-----
I realised MovieClip(root) did work all along but I was just calling on the array before the array was being defined in Main.as. I put a delay on calling graphArray and it worked.
Not sure how that makes sense though because the graphArray is the first thing I've defined in the whole main.as class
Try using this instead
MovieClip(this.root)
This works for me on a test that you can see here:
http://marksost.com/test/as3arrayaccess/
And the source files here:
http://marksost.com/test/as3arrayaccess/test.zip
I did a separate levelData class to be able to flexibly add levels. I was happy with it until my supervisor ordered me to convert my levelData into XML. I did an XML version of the levelData's data (question, answers, correct answer...). I used the old class and converted it so that it fetches the XML.
All seems well, I did traces of my answers array and it printed nicely...
But the headache started when I tried this.
// This code appears in a different class with
// currentLvl:LevelData initialized in the constructor.
quizHolder.ansA.ansHud.text = currentLvl.choices[1];
quizHolder.ansB.ansHud.text = currentLvl.choices[2];
quizHolder.ansC.ansHud.text = currentLvl.choices[3];
quizHolder.ansD.ansHud.text = currentLvl.choices[4];
// BTW, I can't make a for loop to do the same function as above. So wierd.
I tried to run it. it returned:
TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at QuestionPane/setQuiz()
at QuestionPane/setQuestion()
at QuestionPane()
at LearningModule()
Where did I go wrong? I tried making a custom get function for it, only to get the same error. Thanks in advance. If I need to post more of the code, I will gladly do so =)
LevelData Class in PasteBin: http://pastebin.com/aTKC1sBC
Without seeing more of the code it's hard to diagnose, but did you correctly initialize the choices Array before using it? Failing that I think you'll need to post more code.
Another possible issue is the delay in loading the XML data. Make sure your data is set before QuestionPane tries to access it.
When did you call
quizHolder.ansA.ansHud.text = currentLvl.choices[1];
quizHolder.ansB.ansHud.text = currentLvl.choices[2];
quizHolder.ansC.ansHud.text = currentLvl.choices[3];
quizHolder.ansD.ansHud.text = currentLvl.choices[4];
these? You load the XML and on complete you fill the array, what is correct. but is the XML loaded and parsed to the time when you access (fill the TextFields) the choices array already?
Hey Everyone,
I am trying to get a better understanding of DependencyProperties in WPF. One thing I am trying to get clarity with is the LocalValue. There is a function called ReadLocalValue that is supposedly supposed to return the local value of the property otherwise it should return UnsetValue.
For instance I have a TextBlock named "justATest" with the TextProperty value set to "Test" on the element.
When I try calling:
MsgBox(ReadLocalValue(CType(justATest.TextProperty, DependencyProperty)).ToString)
All that gets returned is {DependencyProperty.UnsetValue}
Shouldn't I be getting back the value "Test"?
Can anyone shed some more light on the Local value and how the ReadLocalValue function works. Also are their any good resources out there that explain this?
Thanks,
Nick U
Shouldn't you be calling
justATest.ReadLocalValue(TextBox.TextProperty)
is it possible to read the value of an IdentityTag if you place it on the TagVisualizer, without having initalized it before?
I would like to use the tags for registering a new object on the Surface but having all the "free" IdentityTags in a Collection for initalizing them all... There must be a better way to do in I think.
But the TagVisualizer doesn't seem to do anything when you put a tag on it that it doesn't know.
If I understand correctly, you'll need to start by setting up your TagVisualizer with a TagVisualizationDefinition with a Matches method that always returns true.