Actionscript 3 :: Bindable Getter Function Of Singleton Instance Never Being Called In A Data Binding Expression
Oct 26, 2011
I have a singleton class that looks something roughly like this (only with more bindable public properties):
public class Session extends EventDispatcher
{
private var _Id:String;
private static const _instance:Session = new Session( SingletonLock );
private static const SESSID_CHANGED:String = 'SessionIdChanged';
[Code]...
The abnormal behavior I'm discovering is that the event listeners registered through registerOnSessionChange are indeed being called when the session Id changes, but the MXML data binding expression is not updating. I've tried all combinations of dispatching the event during the capture phase, and making it not cancelable, but to no avail. My understanding of [Bindable (event= ...)] is that the MXML should update the url string when the event specified is dispatched, so what am I doing wrong or misunderstanding?
Note: I realize there are lots of different ways of doing the singleton pattern in Actionscript, but unless the way I am doing it is actually causing my problem somehow,
In my case, some user interaction produces new values for the bindable variables "someDataProvider", and "someSelectedItem". However, when flex renders the DropDownList, the control's selected value is empty.
The reason for this is that the DropDownList's "selectedItem" property gets bound before the "dataProvider" property. The "dataProvider" needs to be bound first for "selectedItem" to be valid, this is because the new "selectedItem" points into the new "dataProvider".
what is the best practice for updating bindable properties in a specific order? I've come up with a few ways (e.g. using a valueCommit handler), but I wanted to see what the community had to say.
I'm using setInterval and the issue is "how can i send data to function that are called from setInterval?". Now I have this: ActionScript Code: si = setInterval( startLoading(dir + "/" + f[i]) , t); If i send the function parameter in setInterval the function do all her job but the setInterval don't work. Wich are the best pratice to do this?
i am trying to return an XML object, but having issues. The object is only created via an Event.complete function. I need to return the XML created from my loadXML function via my grabXMLfromFile function.
Code: function grabXMLFromFile(attrPathToXML:String):XML { var fileUrl:String = attrPathToXML; var myUrlRequest:URLRequest = new URLRequest(fileUrl);
My first swf loads a singleton class and instantiate it , and I access to it in the following swf's files (they were loaded in local system).
Now I have to load all swf via http. The issue is when I load second movie throw the first one, I can't get the singleton instance... it seems it lost reference...
The generally used workaround for this, is to use a regular function instead of a getter/setter. This results in having to have ( ) after the function variable obviously. The question is, can a Function variable be assigned to a getter/setter function and retain its attribute of not needing brackets.
Below is some Pseudo code representing the question:
######################################################### public class Foo(){ private var prop:Object; public function get Prop():Object{return prop;}
My Combobox is not alway updating when I update the ArrayCollection.[code]...
the first time it updates the combobox fine and sometimes it works the 2nd, 3rd, etc time is might update the combo box. After it stops updating the combobox, it never does until I restart the app. I have verified that the ArrayCollection is updated via the debug data, it is just the combobox is not updating the display.
If user change the value of the TextInput, then click refresh button to retrieve the data model from backend again, the GUI value will not change back. Re-binding not happen, Since the value of data model not changed, no propertyChanged event fired.In this case, I must Programmatically set the model value to the GUI after data refreshing done.I know bi-directional binding can solve this problem(when user change value on GUI, set the new value to data model immediately). But sometimes I cannot use bi-directional binding, for example, the data model is a int, but user input a non-int value, I cannot set the value to data model. So the value in data model do not change, when refresh data, rebinding still not happen.
This will make the data binding useless. How to resolve this?I put pseudo-code here for now, I will put real code later:1. retrieve a data model from server, via blazeds or something else.2. bind the model to a TextInput on GUI.3. user change the TextInput text.4. User click a refresh button, triger retrieve the model value again.5. Now since the model value do not change, no PropertyChanged event fired.6. GUI value still is the user's input, not the value from the model. can clear the model value before set the velue back, make re-binding happen.(but sometimes you do not know how to clean the model value, take int for example, you may do not know the original value and happen set the same value). Or I can manually set the model value to GUI. But both are not good looking.
I know that one can give a symbol already placed in the scene and instance name and be able to manipulate that object programatically through ActionScript in Frame actions. What I want to do instead, is bind that instance name to a class member so I can use it inside a class file and and eliminate the need for frame scripting.
I am new at this and I'm trying really hard to figure out what the ideal workflow is. I would like to use a fully OOP approach at developing my applications, however I like to use the graphical interface to position assets on the scene because I find it easier than positioning assets programatically. So the solution I am looking for is binding assets to class members. If such a workflow is not possible, what's the best approach in dealing with assets in a fully OOP design?
Getter functions allow obj.meth syntax instead of obj.meth(), I'd like to create an anonymous one of these to return from another function. function get ():Object { } is invalid syntax. I don't suppose Flex offers an easy way to get this functionality, if it's even possible?
My application uses fx tag in which it loads some xml. I want to create the xml name by binding, but I get an error that Data binding expressions not supported with attributes processed at compile time.
This time want to know is it possible to use the user input string as part of reqular expression for instant search... I am aiming to add search feature in my game.. Where i m going to have several items available in list... what i am planning is to have a text box from which i will accept user input and perform instant search am still a noob in AS3... so whether using RegExp meet my goal ?
first one shows playheadtime of videodisplay and another is also used for same purpose. the difference is that when we are in add mode(decided from a flag variable) both should show current playheadtime using binding. but when we are in edit mode(again decided from flag) the latter label should remain static, to be more specific, the value retrived from database.how can I do that using actionscript. I tried ChangeWathcer but I found it a bit tricky. Is there any other simpler way or am I missing something. following is my code.
private function init():void { if (queFlag == 'a')
I'm having some troubles with binding data. I have an application that contains a viewstack of components. Let's say I have comp1, comp2 and comp3 inside the viewstack. Each component, has its own data class --> comp1Data.as, comp2Data.as and comp3Data.as. All values in each component are binded to the corresponding data in it's data object.
A click in a control in comp1 leads to comp3, the same goes for comp2. Clicking a control in comp2 leads to comp3. When going from comp1 to comp3, comp3Data.as is initialized and and comp3 displays the binded values. When going from comp2 to comp3, comp3Data.as is also initialized but the binded values are not displayed...
I'd like to add a derived property to flex:[code]However, derived won't update when I change a or b.Is there a better (faster) way to make derived update than giving a and b setter methods which invalidate it?added keyword "get".This makes more sense now, I hope.
I need to bind a property to an edit control and have the control write its value back to the same property. The problem is, I'm setting the source value before the control is created:
<mx:Panel> <mx:Script> <![CDATA[ [Bindable] public var editedDocument: XML;
But I get a warning from Flex that the binding wouldn't work that way and it doesn't. It works the first time I load up the component but every time I change findFriendsPaginationElement it doesn't reflect on the component. Do you know how I can go about doing this? (making changing a value in the binding variable changes the status of an element inside a component?)
I'm binding two AutoCompleteModified objects to one another; meaning you type in one and it selects the correct object in the other. It works fine when I define it in MXML: However, a user can add a new row to a Grid and then I set up the binding and objects via actionscript and it gives an 'undefined' error: ChangeWatcher line 427/wrapHandler.
var innerHBox:HBox = new HBox(); var dtc_acm:AutoCompleteModified = new AutoCompleteModified(); dtc_acm.dataProvider = data2; dtc_acm.labelField = 'id'; var cp_acm:AutoCompleteModified = new AutoCompleteModified(); [Code] .....
If I only keep it 1-way binding then it works fine. But both throw this error. Is there something about not only doing it 2-way in actionscript, but adding components that aren't on the stage yet?
But the ComboBoxes are being created dynamically with AS3, everything is working except I cant bind the second ComboBox dataProvider to be the XMLList in the first ComboBox's selectedItem.
I love MXML but am starting to notice some of its drawbacks. The main one I'm struggling with is its larger memory usage due to the need for binding. In the super simple code snippet below, which I've tested on Flex 4.0[code]...
My main question: is there any way to set variables in MXML that doesn't eat up memory? I'm aware that I can do this explicitly in AS and keep MXML as a bare bone structure but was wondering if there was an alternative path.
Secondary question: why memory usage in c different from a and b? I've looked up at the intermediate code and it seems like the const case still sets up some binding logic but not as much and have been wondering why that is.