Get a dynamic width of a dynamic button

Hello, I'm trying to understand what is the width of a button dynamically generated compenent (in a forloop). Here is my code:

var buttonFilterData:Button = new Button();
set the data of the button - the filter data
buttonFilterData.id = "instance__" + items ['data'];
buttonFilterData.label items =
['label'];
buttonFilterData.data = elements ;
set the appearance of the text button
buttonFilterData.setStyle ("fontWeight", "normal");
buttonFilterData.setStyle ("fontSize", "10");
buttonFilterData.setStyle ("textAlign", "Center");
define the attributes of position buttons
buttonFilterData.height = 20;

THIS PART DOES NOT WORK!)
Alert.Show (buttonFilterData.Width.ToString ());

buttonFilterData.x = event.currentTarget.mouseX;
buttonFilterData.y = event.currentTarget.mouseY;
Add the event listener of keys used to drag the component
buttonFilterData.addEventListener (MouseEvent.MOUSE_DOWN, dragIt);
Adds the button to the Web as a child
memberFilters.addChild (buttonFilterData);

Im trying to get a button's width (the width will depend on the length of the text within the key) to determine where I wasn't the button to be placed in x, is to coordinate a canvas. Help!

Click on the Web and you will see how the button is centered.
The key is to add the listener to the button creationComplete.

http://www.Adobe.com/2006/mxml '.
layout = "absolute".
xmlns:view = "view.*".
>


Import mx.controls.Button;

private function clickHandler (e: Event): void {}

create a new component button
var buttonFilterData: button = new Button();
buttonFilterData.label = 'Label XXXX';
set the appearance of the text button
buttonFilterData.setStyle ("fontWeight", "normal");
buttonFilterData.setStyle ("fontSize", "10");
buttonFilterData.setStyle ("textAlign", "Center");
define the attributes of position buttons
buttonFilterData.height = 20;
buttonFilterData.addEventListener ("creationComplete", btnCreateCompleteHandler);
buttonFilterData.x = e.currentTarget.mouseX;
buttonFilterData.y = e.currentTarget.mouseY;

cvs.addChild (buttonFilterData);

}

private void btnCreateCompleteHandler(e: Event): void {}
var ix: int = e.currentTarget.x - (e.currentTarget.width / 2);
IY var: int = e.currentTarget.y - (e.currentTarget.height / 2);
e.currentTarget.x = ix;
e.currentTarget.y = iy;
}

]]>


Tags: Flex

Similar Questions

  • dynamic button action

    I have a button that submits a page. When a user clicks this button the button should be disabled
    and the label of the button should change to "present" to "loading...". ».

    I was able to get the button disabled by dynamic action. But I don't seem to be able to get the label to change.

    The button is a button style html.

    I tried the following dynamic:

    Event: click on

    ExecuteJavaScriptCode: this.value = "loading...". »
    SetValue: Static assignment: loading...

    selection type - element triggering and point

    Someone has an idea what I am doing wrong?

    Thank you
    Wayne

    Edited by: wcoleku may 6, 2011 11:11

    No problem at all. In this case, instead of use 'this' in your dynamic action javascript code to reference the button, use:

    document.getElementById().value="loading....";
    

    You don't even have choose anything in the section 'Elements affected', you leave "- select Type -" selected.

    Sergio

  • Cannot get a dynamic conversion

    Hello

    I have a document that I checked in to the content server using the option "New Check In." When my check-in is completed and clicked on the content information, and then when I try to get the conversion using the option 'get Conversion (HTML)' in the content information page I get the below error.

    ************************************************Error Log Starts***************************************************************

    * Application server has no content *.
    * Cannot get a dynamic conversion. Cannot export the document '000417' by using the 'BLANKTEMPLATE' template and layout "RVH_DCLAYOUT_NEWSSTORY." Export process: "DCExport."

    * [Details] *.
    intradoc.common.ServiceException:! csFailedToExport, 000417, BLANKTEMPLATE, RVH_DCLAYOUT_NEWSSTORY! $Export process: & amp; #39; DCExport & amp; #39; to dynamicconverter. DynConverterHandler.doConversion (unknown Source) at the dynamicconverter. DynConverterHandler.runHtmlConversion (unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617) at intradoc.common.ClassHelperUtils.executeMethodReportStatus(ClassHelperUtils.java:293) at intradoc.server.ServiceHandler.executeAction(ServiceHandler.java:79) at intradoc.server.Service.doCodeEx(Service.java:490) at intradoc.server.Service.doCode(Service.java:472) at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1353) at intradoc.server.Service.doAction (Service.java:452) to intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1194) at intradoc.server.Service.doActions(Service.java:447) at intradoc.server.ServiceRequestImplementor.executeSubServiceCode(ServiceRequestImplementor.java:1064) at intradoc.server.Service.executeSubServiceCode(Service.java:3497) at intradoc.server.ServiceRequestImplementor.executeServiceEx(ServiceRequestImplementor.java:942) at intradoc.server.Service.executeServiceEx(Service.java:3492) at intradoc.server.Service.executeService(Service.java:3476) at intradoc.server.Service.doSubService(Service.java:3465) at sun.reflect.GeneratedMethodAccessor16.invoke (unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) to intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617) to intradoc.common.ClassHelperUtils.executeMethodEx(ClassHelperUtils.java:279) to intradoc.common.ClassHelperUtils.executeMethod(ClassHelperUtils.java:264) to intradoc.server.Service.doCodeEx(Service.java:507) to intradoc.server.Service.doCode(Service.java:472) to intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1353) to intradoc.server.Service.doAction(Service.java:452) to intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1194) to intradoc.server.Service.doActions(Service.java:447) to intradoc.server.ServiceRequestImplementor.executeActions(ServiceRequestImplementor.java:1114) to intradoc.server.Service.executeActions(Service.java:433) to intradoc.server.ServiceRequestImplementor.doRequest(ServiceRequestImplementor.java:635) to intradoc.server.Service.doRequest(Service.java:1707) to intradoc.server.ServiceManager.processCommand(ServiceManager.java:359) to intradoc.server.IdcServerThread.run(IdcServerThread.java:197)

    ************************************************Error Log Ends******************************************************************

    Help to solve the problem is highly appreciated.

    Kind regards
    Abhijit

    Hello

    Have you set the X server option for raterization. If that's the case then without defining the x server you run these question:

    1. connect to the Complutense University of MADRID
    2. in the Administration menu, select the item "Dynamic converter Admin", then "Settings".
    3. uncheck the box "use x-windows of pixelation.
    4. click Update at the bottom of the page button.
    5 restart the UCM.

    A test to see if the problem is still there

  • How can I get a dynamic mic to work on the iMac?

    How can I get a dynamic microphone to work via the usb input? Do I need a plug-in?

    Well Yes, if it is a USB microphone, the support is to plug.  Note, Apple provides an Audio configuration and Apple Midi utility in Applications-> utilities that once connected develops on the parameters in the menu-> Preferences-> sound-> entry

    Some microphones require Mac OS X drivers.  It would therefore be important to determine if yours is a.   Google your brand and model micro with Mac OS X and the drivers of Word to see if someone needs.

  • QML dynamic buttons

    Is it possible to create dynamic buttons in QML?

    I would like to create a variable array of buttons in QML, I don't know how much I need before execution.  It is not possible to do in QML.  If it is possible, is there an example I could mention?

    Thank you!

    Hello! This can be done. We discussed a similar topic today, please check this thread:

    http://supportforums.BlackBerry.com/T5/Cascades-development/how-to-add-the-one-container-in-another-...

  • I recently turned from a PC to an IMac.  I use Lightroom 5 and I can no longer open older videos or import videos from my D7100.  The error I get is "dynamic links media server has encountered a problem.  Anyone know a fix or will be updated into the ligh

    I recently turned from a PC to an IMac.  I use Lightroom 5 and I can no longer open older videos or import videos from my D7100.  The error I get is "dynamic links media server has encountered a problem.  Anyone know of a patch or upgrade to Lightroom 6 will fix the problem?

    Hey billo,

    Could you please check and confirm the version of Lightroom you use?

    What operating system do you use?

    ~ UL

  • New dynamic button for printing

    How to create the new dynamic button for printing in the dashboard?
    Before that I created the button with code below, but when I select the command prompt, the query depend on prompt will be changed, but the print page not be changed. Is it possible to solve my requirement? Thank you.

    < input type = "button" name = "Button" value = "Print" onClick = "window.open ('http://prcsgi03162:9704/analytics/saw.dll?Dashboard & CheminPortail = / shared, Kobe, _portal, kobe & Page = 9 & Action = Print & Format = pdf', 'Download');" return false; ">

    Published by: kobe on November 23, 2011 00:19

    Hello

    In your onclick try to paste the below:

    onClick = "return PortalPrint ("saw.dll? Table edge & CheminPortail = / shared, Kobe, _portal, kobe & Page = 9 & Action = Print & Format = pdf', true); return false; »

    Thank you

  • Dynamic button mode Full_Screen problem

    Hello

    I was wondering if someone could help me. I really really need help. It's the only thing holding my project and I had to restore yesterday.

    I have a button movie clip with a dynamic text inside field. I am loading dynamically to the scene, while a video is running in the background. I also have a button fullscreen (Flash component) on the stage. After clicking on the button full screen and mode Full_Screen static buttons, including the button fullscreen work without problem, but the dynamic button seems to not work at all. Basically, the button dynamic when you click it should change his message to "you clicked the button 1. This works in normal mode, but not in full screen.

    I tried btn_cuePt_1.enabled = true; but without success.
    It has something to do with not to use the events of full-screen?
    exp. stage.addEventListener (FullScreenEvent.FULL_SCREEN, fullScreenRedraw)

    Thank you!!

    The solution was so simple. I didn't have to completely redo, but I replaced the button full screen and everything is good now.

    Thank you, again.

  • How can I get him to minimize, maximize, and close buttons appear in Adobe Reader XI

    How can I get him to minimize, maximize, and close buttons appear in Adobe Reader XI

    davidm96675864 wrote:

    I use Kaspersky Internet Security, which is updated (Version 15.0.0.463 (b)).  Thank you, David.

    The latest version is 15.0.2.361.

    Kaspersky Internet Security 2015 | Latest releases | Kaspersky Lab

  • How can I get audio to not start when the button is clicked?

    I am new to adding audio to slides, buttons, click boxes.  Import the recorded voice on the overall slide of files sounds easy enough.  However, there are several buttons that display a legend I want audio to not start when the button is clicked.  I added audio just for this button, but it starts when the slide begins.

    How can I get audio to not start when the button is clicked?

    Hello

    Audio playback when the assigned object with the audio appears. That's why hear you when the button appears.

    Try to assign audio instead to the object that is displayed when you click the button. Perhaps the legend.

    See you soon... Rick

    Useful and practical links

    Captivate wish form/Bug report form

    Certified Adobe Captivate training

    SorcerStone blog

    Captivate eBooks

  • How to get the name of the instance of button to display in the dynamic text box

    first of all, thank God for you people. Laughing out loud.

    Here is my scenario, I am the designer of consumate and learning coding by leaps and bounds, today its been a lot of stumbling blocks however.

    I have a site I designed that contains buttons that navigate the user at various points on the timeline using image tags. When they arrive at the appropriate image tag, they are presented with a movieclip containing two layers. The bottom layer is a card, and the top layer is a collection of buttons printer having a component tooltip on them showing you the information on detailed mouse printer on and takes you to the Remote UI printer on release. each button has a name of unique queue for the printer appropriate under its name of the instance (e.g. itm100_btn). Here's the jist... I want to be able to place a dynamic text box near the printer and using action script button it display printer queue name automatically simply based on the button, targeting, or even place the dynamic txt area inside the printer button mc. See, on some pages, there are like 24 printers... I'm AFRAID to have to put all these names in manually because there are total 150 printers! OUCH...

    Oh it is AS2.0 with Flash cs4

    In short... God bless you people... for the love of God someone help me? Laughing out loud.

    Thank you so much peoples!

    "I make things look purdy, but do not know why the sky is blue".

    to create a movieclip button:

    create a (insert/new symbol/movieclip) movieclip and attach a stop() to its first image and etiquette 'up '.  create any graphic you want for the up state button movieclip.  create a 'more' and, if necessary, a "low" setting

    When you place this button movieclip on stage give an instance name (for example, printer1) and use:

    {Printer1.onRollOver = Function ()}

    this.gotoAndStop ("over");

    }

    {Printer1.onRollOut = Printer1.onDragOut = Function ()}

    this.gotoAndStop ("up");

    }

    {Printer1.onPress = Function ()}

    this.gotoAndStop ("down");

    }

    and add your onRelease to do all that.

    If you also wanted to add a textfield that displays the instance name of the button when the button is postponed, place a textfield on the framework of the "over" and give it a name instance (say tf) and associated to the MovieClip "over" frame that uses:

    TF. Text = This._name;

  • Difficulty getting on component width dynamic (width is always 0)

    Hello

    I'm a newbie to flex and I was struggling with getting a width on components that I create in AS3 blocks. I have a TileList with a custom ItemRenderer component called ImageRenderer. When a user clicks on one of my articles, I would like to appear on the screen as well as a few other components. I have this work:

    public void onClick(e:ListEvent):void {}

    var i: Image = new Image();

    i.source =. img.source (e.itemRenderer as ImageRenderer);

    var h:VBox = new VBox();

    var t:TextArea = new TextArea();

    h.addChild (t);

    h.addChild (i);

    t.text = "Sample Text";

    h.x = 100;

    h.y. = 100;

    addChild (h);

    trace (h.width, h.height, root.width, root.height);

    }

    I get the Hbox to appear on the screen and displays the image, but the width and height that I get for the Hbox is always zero. Can someone tell me why this happens and how to fix it? I had another similar problem do anything else I ever solved, so perhaps my understanding of how flex calculates the width won't.

    Thank you

    I wonder if your trace is before printing the HBox has time to update its size - because of the asynchronous nature of Flex.  To find out, I put your trace() in a separate method and call this new onClick method using setTimeout(newMethod,500). Will give him half a second set to date. If it's always 0 try changing from 500 to 2000 (2 seconds). If it is still zero after that, then I'm wrong.

  • Add dynamic buttons to each line of the report and bind the data line to this line-specific buttons

    I have a page with a form in the upper part and a report at the bottom that is bound to a table. I need to add a pair of buttons for each row in the table and add dynamic actions for these buttons. I need to submit the data corresponding to the line to a REST service and update the table/line. I know that it is possible to add ajax call and refresh the table after receipt of the response. But I don't know how can I dynamically include a pair of buttons on each line and access the data corresponding to the record when a particular button is clicked. I was not able to find such a feature using the help page. Can you please let me know if this is possible. Thanks in advance.

    Here is the representation of how I need to the page to look like.

    Col 1

    Col 2

    Col 3

    data 1

    data 21

    data 31

    Button 1

    Button 2

    data 2

    data 22

    data 32

    Button 1

    Button 2

    data 3

    data 23

    data 33

    Button 1

    Button 2

    data 4

    data 24

    data 34

    Button 1

    Button 2

    I should be able to access the data 1, data21, data button 31 11 and button21 etc.

    Select data1,

    data2,

    data3,

    ......,

    Button1 null,

    Button2 null,

    ROWID r_id

    Of...

    If you change the column for button1 and navigate to the area of column formatting you can create your button here, in several different ways.  You will need to play with the way you prefer.  See below:

    or or you could use and apply css of your theme.

    You create also two buttons in a single column.  From here you can reference columns in your selection by using the format #COLUNMNAME # (as I did with R_ID).

    Then, you will need something similar for all columns that you want to be able to recover when you click the buttons.  See below:

    -It would be Data1 column

    #DATA1 #.

    You would do this for each column that you want to access click the button as shown above.  You can skip this step and use jquery to iterate through the DOM using the. closest() and. find() and give each column a separate class.  Is your preference.

    You then create a dynamic action, when it is clicked on .button1.  Now that you have this object, you can get the id of the trigger object that would be your r_id and from here you can access all your individual data points (all this in a JavaScript in the dynamic action) and assign to items hidden on your page.  The next step in this dynamic action, you could run pl/sql and transmit the page elements.

    Hope that all of the senses.

    David

    Post edited by: DLittle

    As a bit of clarification: the r_id column does not have to be rowid, but it must be unique for each return line.  You can use your primary key or rownum.  Just what works for your scenario.

  • Update of dynamic buttons via actionscript vIewstack

    Someone has a good example of how update an index of a Viewstack in a MOUSE_OVER event triggered by a button that is generated dynamically? It's my butt.

    I have a viewstack left (containing images) component and a component vbox to the right (with buttons). Both the viewstack and buttons are generated dynamically from a XML file. I want to be able to assign an event handler for the button, MOUSE_OVER so that it changes the index of current viewstack. There are several examples showing how to proceed with actionscript who wrote online on buttons that are hard coded. However my buttons are generated once the script XML is loaded and for some reason, I can't successfully the viewstack to update.

    When I try to use viewstack.selectedChild name = I get an Error 1067 telling me I can't assign a string to a container. And when I try to use viewstack.selectedIndex = the id of the swf file freezes.

    An overview of my problem would be appreciated. Thank you.

    G.

    Thanks again for the code. I gave it a try, and thanks to your code, I noticed a few things that I was doing wrong. Above all, I tried to use MOUSE_OVER/MOUSE_OUT instead of ROLL_OVER/ROLL_OUT. Also, I came to the conclusion that trying to update the events triggered by the images button States was a bad idea. So I created a method when it is called all the States of the button ROLL_OUT past and then adjust the current button to ROLL_OVER. I am able to call this method from several locations, and it seems to do the trick.

    in any case... I would have been stuck with your help. So thank you. Here is a zip file of my project. It seems to work very well locally, but I'm under questions get the XML file to load on my test server. I think it might be a problem of crossdomain.xml. I will try and resolve Monday. Aside from that I have something bothering me, when I move my cursor on a button, that there are not in the ROLL_OVER State of the current image. I'll try to find a way to deal with this.

    Thank you.

  • Adding listener to the dynamic button fields

    Hello members.

    I am facing a problem when adding buttons dynamic/multiple listener.

    I download the images corresponding to my custom buttons and display buttons in landscape Manager. Now, I need to specify a particular task for each field button. I read different posts, but could not able to find the success it please help me solve this problem.

    My code is: -.

    for (int i = 0; i)<>

    Items (Items) = XMLParseData.LevelOneVector.elementAt (i) obj;

    Bitmap mediumIcon = obj.getmBmpMediumIcon ();
    Btn1 = new BitmapButtonField (mediumIcon, mediumIcon);
    Btn1.setChangeListener ((FieldChangeListener) this);
    scrollhf. Add (btn1);
    }

    My class implements Fieldchangelistner

    and in the field changed the method that I'm confused what measures to follow

    ' Public Sub fieldChanged (field field, int context)
    {

    Please provide me with some help here, I would like to specify each button with forefinger, and then you can add an action to it.
    }

    Thank you

    };

    For this you must use the ButtonFields dashboard. This code can help:

    public class Abc extends MainScreen implements FieldChangeListener
    {
        int size=5;
        ButtonField button[];
        public Abc()
        {
                    size=5;// here give your Vector.size();
            createGUI();
        }
        public void createGUI()
        {
            button=new ButtonField[size];
    
            for(int i=0;i
    

    ==================================================================================

    Do not hesitate to click like button if the solution is correct;

Maybe you are looking for