error called to undifined method when using pop() - actionscript-3

I'm trying to add the pop function to a button in flex 4. But I keep getting an error call to undefined method when I try to use it, but it's a built in function isn't it? I posted my code below, any ideas?
<s:Button x="405" y="410" label="Undo last" width="85" click="data.pop()" id="undo"/>

data.pop() most likely won't work unless you are using your button as item renderer or item editor in a DataGrid.
In case you defined a variable of type Array called data try to rename it to something else. data is used by the framework itself.

Related

How do I bind an expression to <paper-button>.active?

I'd like to activate a <paper-button> using an expression bound to its active property, but this code doesn't work:
<paper-button id="btnPointDown" on-click="{{decrement}}" active="{{points == 0}}">\/</button>
How can I fix this?
In Polymer, you can't put an expression directly in the bindings. You have to use a function, which will return your condition result, and use it in the binding instead.
With your example, it would look something like this:
<paper-button id="btnPointDown" on-click="decrement" active="[[_checkIfPointsIsZero(points)]]">\/</paper-button>
The function _checkIfPointsIsZero will be evaluated each time points changes, assuming points is in the component's properties.
I also recommend using a simple data binding in that case.

How can I customize the filter function for SelectOneMenu

I tried to find on Primefaces Documentation but I have not found how can I customize the filter function for SelectOneMenu.
I add filterMatchMode="custom" filterFunction="#{mainRandevuBean.ilFilter()}"
But I don't know how can I write bean filterFunction.
The filter is a javascript (client-side) function. It all IS in the PrimeFaces documentation, which you should always look into first, carefully, thouroughly.
So use filterFunction="myFilter"
and create a javascript function like
function myFilter(itemLabel, filterValue) {
// return true if this label matches, false otherwise
}
Just as a sidenote: primefaces documentation doesn't say anything semantically about the parameters. It also does not mention where the label comes from (in fact, the docs mention "the item value" which is not very clear).
In fact I used the JavaScript function to debug this in order to figure out what was provided by default as a label.
function filterList(label, filter){
alert("label="+label+" and filter="+filter);
return false;
}
At first I thought it would be anything like the text inside the HTML generated for each list item. But when debugging it I saw the alert said that the label was something like my.package.SomeValueObject#123456 (which is obvously the Java object toString on each item in the list).
You need to define the itemLabel property on the selectItems which is inside the selectManyMenu to generate a proper text value used by the standard filtering mechanisme. As far as I could figure out that is the only reason why you have to put itemLabel there. In the documentation itemLabel is specified before explaining filtering which is confusing.
And as far as I know the itemValue defaults anyhow to just the object value, so I believe following from the documentation is redundant.
itemValue="#{player}"
Hope it helps anyone :.)
I resolve this problem with autocomplete component. Primefaces autocomplete component with dropdown="true" property works like one menu.

Flex 4.6 setting selectedChild= with a bound Variable from a Component

I'm getting the following error:
1067: Implicit coercion of a value of type String to an unrelated type mx.core:INavigatorContent.
Which is located in my main application at the line where I set the selectedChild=
Here's my code for my viewstack which is in my main application:
<mx:ViewStack id="mainViewStack"
width="100%" height="100%"
selectedChild="{topViewControlComponent.selectedChild}">
My component contains the following:
[Bindable]
public var selectedChild:String;
protected function changeView2(child:String):void
{
this.selectedChild = child;
}
<s:Button styleName="controlBarButton"
label="Events"
click="changeView2('userEvents');"/>
I got this to work when I set the viewstack navigator content base off of selectIndex and using an integer...worked fine. But I would rather call them by the id of the Navigator content so that they don't have to be in specific order, if this is possible. Or maybe there's a better way to go about this...Thanks for any help!
The selectedChild property on the ViewStack takes an actual view as its argument, not the name of a view. Using selectedIndex with an int will work fine, or you could call a function in your main application that maps between id and view instance.
Edit: As you said in the comments, you can use click="mainViewStack.selectedChild=userEvents" to set the view as desired.
However, your code in the question is acting like this:
click="mainViewStack.selectedChild='userEvents'"

Accessing instance from symbol class

I have created a text field with the type "Input text" and put the instance name to NameInput. I have also created a MovieClip symbol which works like a button. Basically, I want to trace what text/input NameInput has from the button class.
trace(NameInput.x) does not work and shows the error "1120: Access of undefined property NameInput."
How can I access the instance NameInput from the button class?
When you say trace(NameInput.x), ActionScript looks for an object within your button with that name, and doesn't find it. You might be able to try
var nameInput = MovieClip(this.parent).getChildByName('NameInput');

Passing javascript objects as function arguments

I want to pass a javascript object (JSON) as an argument to another function. But i am getting following error:
missing ] after element list
the function is called on onclick event of href like
"<a href='javascript:void(0);' onclick='javascript:openTab("+ sTab +");'>"+ sTab['SavedTab']['title'] +"</a><br/>";
When i pass whole value : sTab['SavedTab']['title'] , it works fine but i want to pass whole object, not just single value out of it.
Please help me out.
Thanks.
This is because 'javascript:openTab("+ sTab +");', here sTab is a collection and the script cannot do anything for this collection. You would probably have to pass an index as "sTab['SavedTab']['title']"
I believe if your get sTab not as parameter but as variable inside your js function it will work. 'javascript:openTab();'
javascript:openTab(){
//sTab as global variable will be accessible here
}