Flex :: Adding Click Handler On SkinnableDataContainer Items
May 21, 2010
I am new to Flex. What I am looking for here is adding a click handler on all the items created by a SkinnableDataContainer. I tried several things that didn't work, and I have no idea what is the right way to do it.
<s:SkinnableDataContainer id="teamList" itemRenderer="TeamSummaryRenderer">
<s:dataProvider><s:ArrayList>
<fx:Object teamName="A super team 1"/>
<fx:Object teamName="A super team 2"/>
<fx:Object teamName="A super team 3"/>
</s:ArrayList></s:dataProvider>
</s:SkinnableDataContainer>
Furthermore, I don't want to declare the handler in my custom TeamSummaryRenderer component. I would prefer that the handler code stays at application level.
I'm trying to put a label and an image on a UIComponent, side-by-side. I want to use UIComponent for efficiency reasons, and the entire component is more complicated than just a button with an icon.
I'm trying to get a click handler on ther entire UIComponent so that when a click happens on either the label or the image, the same [click] event handler is called. If I add a click handler on the root component, it works, but when I introduce space between the label and the image, the space between them becomes un-clickable. I produce the space by using the move(x,y) method for the label and the image with a small gap between the x/y coordinates.
I have a skinnableDataContainer that I extended with some properties that I would like to use in my itemRenderer. When I try to call (from the itemrenderer)
extended_SkinnableDataContainer(owner).myProperty
I get an error stating that owner is a List and cannot be converted to extended_skinnabledatacontainer Is the owner not the hostComponent?Or is the hostComponent just something completely different?
I have some images I would like to display in TileList in Flex. My TileList dimensions are 2 columns by n rows. What I want to do is to display the first item (row 1, column 1) empty and not clickable, and to start displaying my items from row 1, column 2.I also wonder when I create click event for the same TileList, is there a way get an index of clicked element?
add a click event handler to the vertical axis (or any axis) of a barchart in flex? If I add the handler to the BarChart itself, it looks as though the event doesn't fire unless you click on the actual chart, not the axes.
I want to iterate over an ArrayCollection in Flex while there can be items added and removed.
Since i didn't find a way to use a "classic" Iterator like in Java, which would do the job. I tried the Cursor. But it doesn't really work the way i want it to be ;) So how do I do it nicely ?
var cursor:IViewCursor = workingStack.createCursor(); while (!cursor.afterLast) {
I have a button labeled 'blueButton' and I'd like to use an anonymous function to handle the click, like so:
blueButton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void { trace( "-----click detected-----" ); // now do other stuff });
Problem is, the click handler is called multiple times per click. The number of times called seems to be random (sometimes 2, sometimes 4, sometimes 3 etc). could I be missing something in my code, or maybe I set up the button wrong?
also I noticed that it seems to always get called once on the first click. After the first click is when it starts getting called additional times, maybe that has something to do with it?
I have s:list component in my MXML and a different actionsscript file which does the socket connection to the server.Everytime a user is connecting to the server I'm sending to all clients the updated users in the server by sending strings of ports (port for each user).Now, when the data gets to the client (to the action script file SocketData function), I want it to be added as an item to the s:List in the MXML file.
I have a custom component, containing a List displaying items from an XMLListCollection:
[Code]....
Also if I click twice, only 1 mouse click will cause my custom event to be dispatched (because obviously there is no change between the items). how to make my List only react to mouse clicks? UPDATE: Yes, I've tried using "change" event for the List before, but then I have the problem that it is fired, even if the List scrollbar is clicked.
I have a game here, and I would like to add event handlers to my buttons to change the time. I know how to do all this, I'm just having troubling actually adding the event listeners to my buttons in my .as file. I have a button named "btnEasy" with the Linkage as "btnEasy" as well.I am getting this error: "1061: Call to a possibly undefined method AddEventListener through a reference with a static type Class".[code]
Given the following:private var errorHtml:String = "<TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><p>Existing account, please <a click="clickHandler(event);">click here</a>.</p></TextFlow>";
I'm having a problem with my following situation: I made a class "Scrollbar" which I can use to create a scrollbar for a certain movieclip.This movieclip extended class (Scrollbar) has 3 movieclips (see code below):1 - which has the complete scrollbar1.1 - which has the background for the scrollbar.1.2 - which has the slider for the scrollbarNow, I'm trying to make an onPress handler inside my class, I tried to override the onPress() handler of the MovieClip class but it doesn't work.[code]
I've got a bar chart with some elements.values as this:
[Code]...
This doesn't work, although the openflashchart doc says Each dot can have its own on click event. and Don't forget that all charts can have on click events
I'm trying to start a function from within a click handler that is being triggered when I load some XML, just like this:
Code: function LoadSomeXML(e:Event):void { thumbContainer_mc.addEventListener(MouseEvent.CLICK, thumbClick); } function thumbClick(event:MouseEvent):void { startImgSlider(); } function startImgSlider():void { trace("ok, now you reached 'startImgSlider()' function !!!"); }
The problem is that I cannot reach the startImgSlider() function with the code above. How to do it right. Has something to do with the scopes?
I'm trying to add a custom callback handler to a NetStream client in a p2p application. The problem is, when I add such a handler, the NetStream Client doesn't function as it did before. It seems the NetStream.client object is changed. I know the default object is this. But changing the client to this doesn't solve the problem. The remoteControlStream, is the incoming stream. And the localControl stream is the stream being published. This is the localControlStream that's being send by the peer, and received as remoteControlStream:
private function initLocalControlStream():void{ localControlStream = new NetStream(nc, NetStream.DIRECT_CONNECTIONS); localControlStream.addEventListener(NetStatusEvent.NET_STATUS, localControlHandler); localControlStream.publish(myPeerID+"control"); var localControlStreamClient:Object = new Object(); [Code] .....
The onPeerConnect method of the localControlStream doesn't get called when I connect when the above handler is added. When I remove the that handler, the onPeerConnect method gets called. Obviously the problem is the NetStream.client.
Is there an event that is dispatched when a text input gets clicked (i.e. to add text), but not after text has been added, simply when it is clicked? It won't have changed, and text won't have been entered.
I need a few pointers on how to create multiple buttons programmatically with different event handlers, or rather: differently parametrized event handlers. My real use is a bit more complex, but it comes down to this: I need a button that can delete itself upon getting clicked.
var Buttons:Vector.<Button> = new Vector.<Button>; var newButton = new Button; var int = Buttons.push(newButton);
I have a couple of Sprites on my screen and I want to write a single event handler to handle the double click on any of those Sprites. The following approach works for every event type except DOUBLE_CLICK:
[Code]...
To make it work, because in my application I will have lots of Sprites. In my opinion, a single event and the target property are more efficient than hundreds of event listeners. Am I right or should add event listeners to every Sprite?
I'm creating a facebook application in flex. I'm actually working on the friends component that shows your friends who are using the application. now, each friend has a profile image.
I created the component using a s:List element.
In the Skin Class of the element i configured the requestedColumnCount to 3, which means it shows 3 friends. i added buttons to scroll left and right in the list.
Whenever I scroll to see a different friend, for a half of a second i see no image because the List component is loading the image in order to view it.
is there a way to make the list preload all the elements so i won't have this kind of problem ?
I have entered the following code and both items do import, but i cant control the label of the second library item called "Cool"After doing some digging, i think i found out the class name of the second object was called "Cool" and the base class was "import flash.display.SimpleButton;" so it looked like i had to import that class at the top like i did! But still not working. and still no joy!I think i need to add in "public class Cool extends SimpleButton" so it inherits the SimpleButton class after the first public class and then create a new function called "public function Cool() " and then add the function body but when i go to do that it all goes wrong. Am i on the right track or am i missing a trick!!
I am trying to learn how to add sub menu items to my main menu which is being generated using XML. I have been able to add the top level menu items but I am not sure how to integrate the sub menu items. a link to my development site [URL] In my code I have a variable showInMenu this value is true if it is a top level menu item and false if it is a sub menu item. If I list out the XML menu items they look like this where About Us is a top level menu item and Our Mission is a sub menu item of About Us. how to set up the sub menu items. I attached the fla with xml file.
I've got a combo box adding items from an array. The labels are working just fine, but adding the data with a variable won't work for me. If I put in an actual number, I get that result, but trying to add it with a variable I always get 1 as a result. classData only ever = 1. I can access the array. I know it must be in the syntax.[code]
The buttons search and find the movie clip in the array flawlessly, but I'm having trouble adding a transition to every movie clip as it is appears. Most tutorials on transitions require a specific instance name, but I want ALL instances to have a transition. Heard the .getChildAt() method is the way to go but cannot find solid guidance on this. Here is the basic code:
Quote:
var myDishArray = [chicken, steak, tuna, pasta, iceCream]; for each (var btn in myDishArray) { btn.addEventListener(MouseEvent.CLICK, onDishBtnClick);
[code]....
how do I properly use the transition manager or add a transition code?