Solved

capture selected value from mouseover

Posted on 2011-03-22
12
307 Views
Last Modified: 2012-06-27
hi guys


i have a requirment where i have a label . when user puts the cursor on the label
a small window should popup and show the usernames from an ArrayCollection. When a username is clicked the clicked username should be passed to backend.

Here is the mxml

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
      xmlns:projectWork="org.view.projectWork.*"
      xmlns:projectNav="org.view.projectNav.*"
      creationComplete="init()"
      styleName="dashBoardPage"
      xmlns:services="services.*">

<mx:Script >
<![CDATA[
import org.entity.project.ProjectSummaryDTO;
[Bindable]
public var users:ArrayCollection;  --> this collection has a list of usernames
public var selectedusername:String; -->holds the selected username
                  
<mx:Label styleName="usernames" text="show users"/>  --when user puts mouse here, a window should popup and show the usernames from 'users' Arraycollection

<mx:VBOX>

If 5 usernames are displayed in the box , when user clicks on a username i need to capture that username and pass it to the backend.
So i have created a string var 'selectedusername' which will contain the selected username.

Am i in the right direction?
Can anyone please help me with some code

thanks
0
Comment
Question by:royjayd
  • 6
  • 6
12 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 35194434
Why you cannot user component List and show all 5 usernames as dataProvider
when user click on row you will listen itemClick event and set selectedusername - event.target.selectedItem;
0
 

Author Comment

by:royjayd
ID: 35194508
by dataprovider do you mean datagrid? I dont want to use a datagrid. My boss wants a pop-up window when the mouse cursor is placed on the label. Is that possible?

thanks
0
 
LVL 29

Expert Comment

by:dgofman
ID: 35194528
Everything is possible just need to know what you want

<mx:Script>
            <![CDATA[
                  import mx.controls.Alert;
            ]]>
      </mx:Script>
      <mx:Label styleName="usernames" text="show users" mouseOver="Alert.show(event.target.text)"/>

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:royjayd
ID: 35194717
Ok cool.. When I click on a username I need to pass the username to my
java backend. Any idea how I can do that?

Thanks for the help
0
 
LVL 29

Expert Comment

by:dgofman
ID: 35194725
what services are you using? RemoteObject, WebService or HttpService?
0
 

Author Comment

by:royjayd
ID: 35194913
using RemoteObject to call java methods. So i am basically passing the selected username
to the backend java method.

thx
0
 
LVL 29

Accepted Solution

by:
dgofman earned 500 total points
ID: 35195006
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
      
      <fx:Script>
            <![CDATA[
                  import mx.containers.TitleWindow;
                  import mx.controls.Alert;
                  import mx.controls.List;
                  import mx.events.ListEvent;
                  import mx.managers.PopUpManager;

                  [Bindable]
                  private var selectedUser:String;
                  [Bindable]
                  private var users:Array = ["User1", "User2", "User3"];
                  
                  private function selectUser(event:Event):void{
                        var popup:TitleWindow =  PopUpManager.createPopUp(this, TitleWindow, true) as TitleWindow;
                        popup.title = "Select User";
                        popup.width = 300;
                        popup.height = 200;
                        PopUpManager.centerPopUp(popup);
                        var list:List = new List();
                        list.percentWidth = 100;
                        list.percentHeight = 100;
                        list.dataProvider = users;
                        popup.addChild(list);
                        list.addEventListener(ListEvent.ITEM_CLICK, itemClickHandler);
                  }

                  protected function itemClickHandler(event:ListEvent):void
                  {
                        selectedUser = event.itemRenderer.data as String;
                        PopUpManager.removePopUp(event.target.parent);
                        ro.UpdateUser.send();
                  }

            ]]>
      </fx:Script>
      <fx:Declarations>
            <mx:RemoteObject id="ro" destination="MyRemoteObjectDest"
                                     fault="Alert.show(event.fault.faultString), 'Error'">
                  <mx:method name="UpdateUser">
                        <mx:arguments>
                              <user>{selectedUser}</user>
                        </mx:arguments>
                  </mx:method>
            </mx:RemoteObject>
      </fx:Declarations>
      <mx:Label text="Current Selected User is '{selectedUser}'" click="selectUser(event)"/>
</mx:Application>

0
 

Author Comment

by:royjayd
ID: 35195023
cool, thx very much

>><mx:Label text="Current Selected User is '{selectedUser}'" click="selectUser(event)"/>
Instead of click, i should be able to do 'mouseover' ,right ?

0
 
LVL 29

Expert Comment

by:dgofman
ID: 35195028
you can assign any events for Label component. (focus, mouseOver, mouseDown, click etc..)
0
 

Author Comment

by:royjayd
ID: 35207240
thanks.

trying to impliment this , have a question

You have      

    <mx:arguments>
    <user>{selectedUser}</user>
    </mx:arguments>
i understand the arguments tag, but can you tell me what is <user> tag? Is this a tag in Flex?

thanks.
0
 
LVL 29

Expert Comment

by:dgofman
ID: 35207634
0
 

Author Comment

by:royjayd
ID: 35233648
thx v much, it works perfectly.

can you please help out with the next question
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Flex/Q_26916522.html

thx.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reloading a complete air application 13 448
flash keyboard access html form 15 345
Function to return shape (as3) 1 529
learning partner 1 216
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
How do we balance the user experience (UX) with reasonable security measures? It can be done, if you keep these fundamentals in mind.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now