Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5943549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:24:42+00:00 2026-05-22T16:24:42+00:00

i am using Flex builder 4.5 and my problem is this that this code

  • 0

i am using Flex builder 4.5 and my problem is this that this code doos not work, when i used trace(event.target) i get following in result in console,

deleteme.ApplicationSkin2._ApplicationSkin_Group1.contentGroup.VGroup5.button1

And if i replace this long line in ‘if’ statement code works.(deleteme is the project name). Dont you think it should only say button1 instead of this all long line with all hierarchy , if that is the case then how we can shortend it?

<?xml version="1.0" encoding="utf-8"?>
 <s: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"
           initialize="handleClick(event)">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<fx:Script>
    <![CDATA[
        private function init():void{
            button2.addEventListener(MouseEvent.CLICK, handleClick);
        }
        private function handleClick(event:Event):void{
            trace(event.target);
            if(event.target == "button1"){
                button1.label = "Button 1 clicked";
            }else if(event.target == "button2"){
                button2.label = "Button 2 clicked";
            }
        }

    ]]>
</fx:Script>
<s:VGroup width="100%">
    <s:Button id="button1" label="Button 1" click="handleClick(event)"/>
    <s:Button id="button2" label="Button 2" />
</s:VGroup>
</s:Application>

thanks in advance,

(i tried with sdk 4.1 still same answer)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:24:42+00:00Added an answer on May 22, 2026 at 4:24 pm

    Use the following code instead:

    <?xml version="1.0" encoding="utf-8"?>
     <s: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"
               initialize="handleClick(event)">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    
    <fx:Script>
        <![CDATA[
            private function init():void{
                button2.addEventListener(MouseEvent.CLICK, handleClick);
            }
            private function handleClick(event:Event):void{
                trace(event.target);
                if(event.currentTarget == button1){
                    button1.label = "Button 1 clicked";
                }else if(event.currentTarget == button2){
                    button2.label = "Button 2 clicked";
                }
            }
    
        ]]>
    </fx:Script>
    <s:VGroup width="100%">
        <s:Button id="button1" label="Button 1" click="handleClick(event)"/>
        <s:Button id="button2" label="Button 2" />
    </s:VGroup>
    </s:Application>
    

    It has no sense to compare visual objects with strings. Compare objects with objects themselves.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is the code, i am using flex builder 4.5, <?xml version=1.0 encoding=utf-8?> <s:Application
Using Flex Builder 3 : I have been getting this problem in every single
I'm using subclipse in Flex Builder 3, and recently received this error when trying
I'm using Flash Builder 3 to edit my Flex app, but I noticed that
I have a Flex project that I need to work on that using some
I am using Flex Builder 3 to develop my first application that will communicate
I'm using Flex Builder 3 now and it suddenly refuses to start debugging session.
I'm using Flex Builder more and more and attempting to create a fairly asset
how can I set embed parameters for html wrapper using Flex Builder ? For
I am using the Flex Builder 3 debugger almost every day and it's starting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.