pass data to the event handler function

I'm trying to pass the value of the event handler function, but I get the following error. Can someone please tell me what I'm doing wrong?

1067: constraint implied a Sub type value to a type unrelated function

Here is the code

private void myClickListener(myid:int):void {}
Alert.Show ("button was clicked");
}


public void handleStringResult(event:ResultEvent):void {}
catInfo = event.result as ArrayCollection collection;
for each {(var o: Object in catInfo)
var b:Button = new Button();
b.label = o.FILLCOLOR;
b.ID = o.CATID;
b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
b.setStyle ("color", "#FFFFFF");
b.setStyle ("fontFamily", "Arial");
b.setStyle("fontSize",8);
b.setStyle ("textRollOverColor", "red");
b.addEventListener (MouseEvent.CLICK, myClickListener (o.CATID));
myvbox.addChild (b);
}
}
[]] >

"Merlyn MM" wrote in message
News:gb901m$2QD$1@forums. Macromedia.com...
> Of course, here's the code. I am very new to flex and if my code is not
> sense
> so please let me know the correct way to proceed. I really appreciate
> you
> take the time!
>
>
' > http://www.adobe.com/2006/mxml '.
> layout = "absolute".
> backgroundColor = "#FFFFFF."
> initialize = "myService.getcategories.send ()" > "
>
> useProxy = "false".
"" > wsdl = " http://devsite/rc/category.cfc?wsdl"
> showBusyCursor = "true" >
>
> result = "handleStringResult (event)" "
> fault = "Alert.show (event.fault.message)" / > "
>
> fault = "Alert.show (event.fault.message)" / > "
> //Need CATID to pass the ID of category here
>
>
>
>
> > import mx.collections.ArrayCollection;
> import mx.rpc.events.ResultEvent;
> import mx.rpc.events.FaultEvent;
> import mx.controls.Alert;
> import mx.controls.Button;
>
> [Bindable]
> private var catInfo:ArrayCollection;
>
> private void myClickListener(myId:String):void {}
>
> myService.getcounties.send () / / I need to send the catid here to the
> webservice
> }
>
>
> public void handleStringResult(event:ResultEvent):void {}
> catInfo = event.result as ArrayCollection collection;
> for each {(var o: Object in catInfo)
> var b:Button = new Button();
> b.label = o.FILLCOLOR;
> b.id = 'btn' + o.CATID;
>
> b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
> b.setStyle ("color", "#FFFFFF");
> b.setStyle ("fontFamily", "Arial");
> b.setStyle("fontSize",8);
> b.setStyle ("textRollOverColor", "red");
> b.addEventListener ("click", myClickListener);
> myvbox.addChild (b);
> }
> }
> ]]>
>

I would like to change it to this:

private void myClickListener(e:Event):void {}

I do not see where you use the ID, but to do it,
Use this code:
var e.currentTarget.data = myID;

myService.getcounties.send () / / I need to send the catid here to the
WebService
}

public void handleStringResult(event:ResultEvent):void {}
catInfo = event.result as ArrayCollection collection;
for each {(var o: Object in catInfo)
var b:Button = new Button();
b.label = o.FILLCOLOR;
Note that you could not have used your ID
as a 'handle' to anything, so I replaced
This logic with something you _could_ use
b.Data = o.CATID;

b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
b.setStyle ("color", "#FFFFFF");
b.setStyle ("fontFamily", "Arial");
b.setStyle("fontSize",8);
b.setStyle ("textRollOverColor", "red");
b.addEventListener ("click", myClickListener);
myvbox.addChild (b);
}
}

You could also use a Repeater and establish in MXML.

HTH;

Amy

Tags: Flex

Similar Questions

  • How can I access the data associated with an event within the event handler function?

    Hello

    In my LabWindows code, I try to use a DLL that has been developed in .NET (c#).  I used the built-in labwindows Wizard that converts the DLL to a usable 'instrument'.  Almost everything seems to work, except that I have 1 problem.

    There is an event (defined in the DLL) that I am able to detect.  I know that the reminder of the event is called at the right time.  But the problem is that in this function, I can't access the data that is supposed to be attached to the event.  It worked fine in c#, but I don't know how to do in LabWindows.  Here's what looked like in c# event handler function:

    void AppLoaderEventCallback (CommonLib.CommandResult MyResults)

    {

    MyResults is used in the body of this function

    }

    But in LabWindows, I can't seem to access the MyResults data structure.  Here's what I do:

    public static int CVICALLBACK AppLoaderEventCallback (CommonLib_CommandResult MyResults)

    {

    I can't access MyResults here

    }

    Can you help me with this?  I'm doing something wrong?

    Thank you very much for your help.

    -Mike

    I think that your statement of callback function is perhaps not quite correct. Look using the parameter "callback function" function Panel of the generated __Create function associated with this event. This shows the declaration of the callback function - make sure that your callback function is declared in the same way.

  • [JS] The event handler function is presented as the result in the ESTK

    I have a ScriptUI tree, with a onExpand event, like this:

    Window1.tvwTree.onExpand  = function (item){
        $.writeln(item.key + " is now expanded.");
    }

    Whenever the script is run, I get this in the console to ExtendScript Toolkit Javascript:

    Execution finished. Result: onExpand()
    

    First question is: why?

    Second question: what is the best and cleanest way to take care of the event onExpand? I failed to assign a function to the event of onExpand, in the same way as I do for functions without parameters.

    For simple events, without parameters, I did like this:

    Window1.....DropDownList2.onChange = cboNewLanguage_onChange;

    ... but the onExpand event has its parameter to "point" to take care of, and I can't seem to assign the function in a similar way. Please enlighten me.

    (It would be possible to use a prototype approach, events like this? Get a common function for all events of onExpand...?)

    Thank you

    Andreas

    Hi Andreas,

    First question: what is supposed to be item.key? Did extend you the ListItem properties?

    How assign you the function of onExpand seems correct to me. The following code should work:

    var myExpandHandler = function(/*ListItem*/ item)
    {
         // this => TreeView
         // item => expanded ListItem
         alert( item.text + ' is now expanded.' );
    };
    myTree.onExpand = myExpandHandler;
    

    Alternatively, you can create a generic handler in the prototype of TreeView :

    TreeView.prototype.onExpand = function(/*ListItem*/ item)
    {
         // this => TreeView
         // item => expanded ListItem
         alert( item.text + ' is now expanded.' );
    };
    

    Works for me in CS4 & CS5 +.

    Note: the onExpand function has no equivalent event listener, you cannot use the form: .addEventListener ('expand', myEventListener).

    I don't know why your script causes the ESTK console display "result: onExpand() '. Your code probably contains the corresponding $.writeln somewhere, isn't? In addition, consider that if your user interface code uses something like myListItem.expanded = true; then the onExpand handler is called before win.show (). This may explain the unexpected reactions in the console (?)

    @+

    Marc

  • Help with the event handler.

    Hello
    We had two adapters entity IOM 10 g that fires when the user group memberships are changed. He was attached to the User Groups.User Members post insert and delete data object after.
    To have the same functionality in OIM 11 g, we try to create the event handler.

    I have doubts in this regard.
    1. how the event handler will fire in 11 g on change of group.
    2. we have event handlers that are registered using Ant plugin to check utility. Now, if I want to join this newly created event handler, do I need to implement the new code already a create a new pot and re-save the plugin or can we have several plugin.zip file.

    Thank you

    concerning
    Stone

    steps below:

    prepare the pot for the class as in 10g-> put the server (anywhere) IOM-> goto /Server/bin/now run below
    UploadJars.sh

    Select as a scheduled task
    provide the absolute path with name of the jar.
    If credentials requested provide IOM credential (xelsysadm)

    Once the pot is downloaded to remove the file system. subsequently if necessary change to use UpdateJars.sh instead of UploadJars.sh
    Once you do this PurgeCache.sh performance as well

    --

  • Display today date + 10 days or show the date of the event if this is earlier.

    I have created an agreement form PDF.

    I would like to have the deposit due 10 days from "Date of the day" or the "EventDate", whichever comes first.

    currently it shows the date of the day + 10 days but sometimes the event date is earlier than that.

    Thank you all in advance!

    This script can be used for the filing date:

    document level scripts;
    function GetField (oDoc, cName)
    {
    get the object field with error checking.
    oField = oDoc.getField (cName);
    if(oField == null)
    {
    App.Alert ("Error to the field named" + cName + "\nPlease check the spelling of the domain name and capitalization.', 1, 0");
    }
    return oField;
    } / / end GetField function;

    Scand (cFormat, cDate) function
    {
    convert date stirng date with error checking object;
    Kai var = util.scand (cFormat, cDate);
    if(oDate == null)
    {
    App.Alert ("Date of conversion Error" + cDate, "using the format" + cFormat + "\nPlease verify that the date is valid", 1, 0);
    }
    Return to oDate;
    } / / end Scand function;

    function Date2Num (oDate)
    {
    convert the date object to the number of days since the EPO / / date of ch;
    set the time at midnight of the date;
    oDate.setHours (0, 0, 0, 0);
    convert milliseconds to days;
    Math.ceil (oDate.getTime (return) / (1000 * 60 * 60 * 24));
    } / / end of function Date2Num;

    function Num2Date (nDays)
    {
    Convert number of days date object.
    Back to oDate = new Date (nDays * 1000 * 60 * 60 * 24);
    } / / end Num2Date funciton.

    SetDate() function
    {
    If (GetField(this,_"Today").valuesAsString == null |) GetField(this,_"Today").valuesAsString == "")
    {
    var oToday = new Date(); get the date system;
    oToday.setHours (0, 0, 0, 0); Set to midnight;
    GetField(this,_"Today").value = util.printd ("dd-mmm-yyyy", oToday);
    }
    return;
    }
    Set the field to today's date.
    SetDate();
    end document level scripts;

    Event.Value = ""; Turn off the field;
    get the field objects and field values;
    var cToday = GetField(this,_"Today").valueAsString;
    var cEvent = GetField(this,_"Event").valueAsString;
    var cDateFormat = "dd-mmm-yyyy";
    If (cToday! = "" & cEvent!) = "")
    {
    objects convertdate to days;
    var oTodayDays = Scand (cDateFormat, cToday)
    var nTodayDays = Date2Num (oTodayDays);
    var oEventDays = Scand (cDateFormat, cEvent);
    var nEventDays = Date2Num (oEventDays);
    Make sure that the date of the event is not before the date of the day;
    If (nEventDays<>
    {
    App.Alert ("event date cannot be before the date. today', 1, 0);
    }
    on the other
    {
    Assume that filing date is the date of today + 10 days
    var nDepositDays = nTodayDays + 10
    If (nEventDays<>
    {
    nDepositDays = nEventDays;
    }
    fixed date of filing;
    Event.Value = util.printd ("dd-mmm-yyyy", Num2Date (nDepositDays));
    }
    }

  • [JS CS5] problem with memory leak possible with the dialog box in the event handler

    Hello

    I'm having a very difficult problem.

    I am attaching a script in a handler for a menu item, by using an installation script menu that I wrote based on one by Marc Autret. My version of the script menu installation attach a bunch of event handlers at the same time, to the actions of different menu.

    What is the event handler, with that I have a problem is to prompt the user for a URL and then applies the URL as a hyperlink to the text selection, with our house style for the way in which the URL should look like.

    The problem is the following:

    1. all other installed menu actions work very well, except for this one.

    2. the addition of URL script works fine, when you run it directly from the script menu.

    3. the combination of #1 and #2 (using the script to add URL by function as an event handler in the Edit menu) blocks to InDesign. But it is only after the addition of URL script has finished and done what it was supposed to do!

    4. when I comment on the section of the script URL adding user input, so that instead of saying

    userInput = myDisplayDialog();
    

    It is said

    userInput = "http://thisworks.com";   // userInput = myDisplayDialog();
    

    It works well as an event handler.

    So obviously a problem with the dialog box, but only when adding URL script is executed as an event handler. My first guess is that this is some kind of memory leak, but I think I am following the model of. destroy() the way I saw it elsewhere.

    Someone knows something like that before?

    I can provide all relevant if necessary scripts, but they are quite complicated. The most important of them is the input of the user function. Here it is:

    var myDisplayDialog = function( defaultText ) {
      
        var defaultText = defaultText || "";
        
        var myDialog = app.dialogs.add({
            name: "Type in a URL"
        });
        
        var myOuterColumns = [];
        var myInnerColumns = [];
        var myOuterRows = [];
        var myBorderPanels = [];
        var myTextEditboxes = [];
        var myInput;
        
        myOuterColumns[0] = myDialog.dialogColumns.add();
        myOuterRows[0] = myOuterColumns[0].dialogRows.add();
    
    
        myBorderPanels[0] = myOuterRows[0].borderPanels.add();
        myInnerColumns[0] = myBorderPanels[0].dialogColumns.add();
        myInnerColumns[0].staticTexts.add({
            staticLabel: "URL:"
        });
        
        myInnerColumns[1] = myBorderPanels[0].dialogColumns.add();
            
        myTextEditboxes[0] = myInnerColumns[1].textEditboxes.add({
             minWidth: 300,
             editContents: defaultText ? defaultText : "http://"
        });
        
        var myResult = myDialog.show();
        var myInput = myTextEditboxes[0].editContents;
        
        myDialog.destroy();
    
        if (myResult == false) {
              exit();
        }
        
        return myInput;
    
    }
    
    

    Hi Richard,

    Unfortunately, there is no guarantee that the ScriptUI longer work.

    Thake a peek here: http://forums.adobe.com/message/2881364

    --

    Marijan (tomaxxi)

    http://tomaxxi.com

  • Is there a c# example to use the event handler ExpressionEdit Custom Button control

    TestStand 4.1

    VISUAL C# 2008

    I've added the event handler for ExpressionEdit events as I would any event handler:

    exprEdit.ButtonClick += new NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEventHandler (_ExpressionEditEvents_ButtonClickEvent);

    Then, I create the event handler using the syntax

    public void _ExpressionEditEvents_ButtonClickEvent(NationalInstruments.TestStand.Interop.UI.ExpressionEditButton btn)

    {

    }

    I get the following error when I compile Isaiah:

    Error 1 no overload for delegate matches '_ExpressionEditEvents_ButtonClickEvent' 'NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEventHandler '.

    I guess that means that I don't have the right parameters or types in my statement of event handler, but it corresponds to the object browser.  Any ideas on what I'm missing?

    See my last edition but I think you want your handler to look like this:

    Public Sub exprEdit_ButtonClick (ByVal sender,
    NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEvent
    (e)

  • Epson Event Manager cannot find the scanner driver. Epson said that the event handler is a windows thing, and so is the problem.

    I installed an Epson Stylus SX215. I can print, scan and copy if I use another way, but if I want to use the event handler it says that it cannot find the scanner driver may not use the event handler at all (cannot yet open the program).
    In addition, the scan option "attached to electronic mail" does nothing either. Don't know if this is because the event handler program or because he can not see e-mail programs I have.

    Hi bdelrio,

    Thanks for posting. Try running a System File Checker to find errors.

    Click Start.
    In the search box type cmd
    In the menu start right click on cmd.exe and select Run - As-Administrator.
    In the command prompt, type "sfc/scannow".
    Allow this to fill and run. Please let us know if this corrects and error, or if it reports errors, it cannot fix.

    Thank you! Shawn - Support Engineer - MCP, MCDST
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • Measures to develop the event handler in 11 GR 2 IOM user name generation

    Friends,

    Can you please provide me steps to develop the event handler in GR 11, 2 IOM user name generation?

    Thank you
    Chakri

    The detailed procedure received in my blog for this. Take a look.

    http://Srini-bellamkonda.blogspot.com/2012/11/develope-pre-event-handler-to-generate.html

  • Marshall plan: how to pass data between the main field and sub-application

    Hello

    I'm trying to load a Flex 3.5 application in Flex 4. In the process, I need to move a strong local typed object from main application to the loaded swf file. And I also have to pass a rope and a bitmap of application sub to the main application. Have an example to show how to pass data in the application domain?

    Thank you

    SW

    Define scaleContent = true, set a breakpoint on SWFLoader.as:doScaleContent and

    see if he thinks there's a swfBridge.

  • Error during execution of the event handler

    Hello

    I've implemented a before update event handler (made sure the name is true, the package is right, file loaded on the server, the java code compiled in jdeveloper) but had this error during execution. -What this means and how can I solve this problem?

    Thank you

    ERROR, 4 June 2009 17:25:32, 701, [XELLERATE. SERVER], class/method: tcDataObj/eventPreUpdate some problems: Event handler com.oracle.events.UcdCheckAndSetSponUserExpDate has no name assignedjava.lang.RuntimeException: Event handler com.oracle.events.UcdCheckAndSetSponUserExpDate has no name assigned
    at com.thortech.xl.client.events.tcBaseEvent.run (unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.runEvent (unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.eventPreUpdate (unknown Source)
    at com.thortech.xl.dataobj.tcUSR.eventPreUpdate (unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.update (unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.save (unknown Source)
    at com.thortech.xl.dataobj.tcTableDataObj.save (unknown Source)
    at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.updateUserData (unknown Source)

    In your constructor did you set the name of the event handler?

    Something like:

    setEventName("Enter-a-name-here");

    Best regards
    / Martin

  • How to raise an event (in the structure of the event) comparison function output

    Hello

    I want to triger specific event from a structure of event with the release of the comparison function. I tried several times but the output of the comparison function is not triggered. Please, propose solutions.

    Kind regards

    Mlad

    If you want to use a structure of the event, you must react on the digital inputs, for example as follows:

    Notice that the VI is inactive unless a change control (x, y, stop), date on which Boolean values are updated, comparison made, his played if necessary, and VI stopped if you press stop.

  • Pass data to the swf format.

    Hello

    I would spend my SWF file in an amount of data (text).

    • Is there a limit? I don't speak of thousands of characters
    • I know the simple way of file.swf? data = "mydata"
      but I know that you can transmit data via 'flash vars', when you embed the file in HTML (object <>...
      How to pass the data in this way? Is it's better to simply read from a text file?

    Thank you!

    Gunto

    var sendLV:LoadVars = new LoadVars();

    var receiveLV:LoadVars = new LoadVars();

    {receiveLV.onData = function (src)}

    trace (SRC);

    }

    If you send data to the executable file:

    sendLV.data1var = "whatever";

    sendLV.data2var = "whatever" another;

    etc.

    //

    sendLV.sendAndLoad (sometextfileorexecutable, receiveLV, "POST");

  • Can what information I leave the descriptor in the event callback function?

    I have a plugin automation "A-plugin" when starting it uses AddNotify to set a reminder in waiting for an event to filter:
    sPSActionControl-> AddNotify (pluginRef, eventFilter, reminder, this);

    Then run a plug-in "B-plugin" filter, callback function will be called:
    void CallBack (DescriptorEventID eventID, PIActionDescriptor desc, PIDialogRecordOptions opt, void * data) {...}

    As a reminder, how can I get enough information of the "B-plugin" that raise the event? I knew that A plugin can get the name of the plugin-B, just use "keyUsing" as the key to query the descriptor, if the value of the result is the name of B-plugin, I'll do more surgery. But this method is not reliable because it is hard coded, the B-plugin name may change (e.g. in another language). So someone knows it is it possible to get specific information from the B-plugin? Any suggestion will be appreciated.

    For filters of the event ID must be unique. Or in other cases of plug-in keyUsing ID must be unique.

    Make sure that generate you a unique id for your filter and that place in your resource HasTerminology. Then use this resourceID and StringIDToTypeID to get your event ID. Now, your callback is called only for plug-ins and you know it's B-plugin. Because plugin A and plugin C and X-plugin you have generated a different id to use.

    It's AutomationFilterPiPL.r, the 'AuFi"is ignored because that Photoshop found a string as the fourth parameter id.

    You can use four character codes, but the chances of you be unique becomes less likely.

    HasTerminology

    {

    "AuFi."

    "AuFi."

    16000,

    'adc931a0-cfe2-11d5-98bf-00b0d0204936 '.

    },

  • Bug: RichTextEditor 'Initialize' not classified as the event handler

    I'm trying to load the RichTextEditor control in a pop-up window. Here is my code:

    var rte:RichTextEditor = new RichTextEditor();
    
    rte.width   =  600;
    rte.height  =  500;
    rte.title   =  'Edit Text';
    

    I have to add the initialize event handler, so I can add a button to the toolbar (as on the model on the Adobe Web site).

    However, when I type:

    rte.initialize  =  "addSaveButton()";
    

    Flash Builder says this isn't valid as "initialize" is in fact a function that accepts no parameters.

    Compare this with:

    <mx:RichTextEditor initialize="addSaveButton()"/>
    

    Flash Builder recongises "initialize" as an event handler and therefore accepts the addSaveButton() function.

    Can anyone else confirm if this is a bug with the SDK or not? I can simply add the button outside the RTE for now, but then I wrap the RTE in a separate panel for the button, which is not ideal.

    Thanks in advance.

    Hello

    This is how to add the event listener

    rte.addEventListener (FlexEvent.INITIALIZE, addSaveButton);

    David.

Maybe you are looking for

  • DC 7700: Power HP DC7700

    I got this motherboard and not power. I want to know what food to use and also if possible what is the configuration for edge micro ATX plug so I can use a normal ATX power supply power supply.

  • How can I get rid of Internet Explorer? It's crap!

    I use Firefox Mozilla because Internet Explorer is a piece of crap that constantly displays the message "Internet Explorer has stopped working" and "a problem caused blocking the program works properly...". "Dasmn keeps apppearing message even I don'

  • HP OFFICEJET J5750 ALL-IN-ONE: 10 WINDOWS DOES NOT RECOGNIZE MY PRINTER

    I tried to print my documents without result.  Nothing prints; I tried the test pages, word documents, etc.  I followed several directions that now I am totally confused.    When I go to print devices, everything is as it should.  I tried to add a ne

  • PowerConnect 6224 piling on XFP

    Hi all Just curious about something I've been trying to find a hard yes/no answer on but have had no luck.  Long story short, I'm looking to pick up a pair of 6224 switches and would set up in a pile.  I'm looking at the use of fibers to connect and

  • confusing upgrade patch...

    I currently have a VDI infrastructure that looks like this...vCenter 5.5Hypervisor 5.5Horizon 6.0.1Composer 6.0.1VSAN 5.5Can someone guide me in the right order to upgrade these components. A hard time to find a clean way through vmware I want to go