error when using custom class in itemrenderer

I created a subclass of Event Class. I used the subclass in an itemrenderer, no error observed. But once I declared the itemrenderer to the List in the Main application, errors appears in the itemrenderer claiming "Type was not found or was not a compile-time constant: CustomDeleteEvent" and "Incorrect number of arguments: Expected no more than 1"

Please give me some advice. Thanks in advance.

In subclass :

package widgets.GetMap { import; public class CustomDeleteEvent extends Event { public static const DELETE_ITEM:String = "DELETE_ITEM"; public var deletedItem:String; public function CustomDeleteEvent(type:String, deletedItem:String) { super(type); this.deletedItem = deletedItem; } } }

In ItemRenderer :

<?xml version="1.0" encoding="utf-8"?> <s:ItemRenderer name="CustomItemRen" xmlns:fx="" xmlns:s="library://" xmlns:mx="library://" autoDrawBackground="true" minHeight="24"> <s:states> <s:State name="normal" /> <s:State name="hovered" /> <s:State name="selected" /> </s:states> <fx:Script> <![CDATA[ import mx.controls.Alert; import; import spark.components.List; protected function deleteHandler():void { var deleteItem:String = itemIndex.toString(); var tryevent:CustomDeleteEvent; owner.dispatchEvent(tryevent,deleteItem); Object(owner).dataProvider.removeItemAt(itemIndex); } ]]> </fx:Script> <s:HGroup width="100%" height="100%" verticalAlign="middle" paddingLeft="2" paddingRight="2" paddingTop="2" paddingBottom="2"> <s:Label id="lbl" text="{data.toString()}" width="100%" color="#30FF00"/> <s:Button id="btn" includeIn="hovered,selected" y="-16" width="35" height="22" label="X" accentColor="#FFFFFF" color="#FF0000" fontFamily="Verdana" fontSize="12" fontWeight="bold" mouseDown="deleteHandler();" toolTip="Delete item"/> </s:HGroup> </s:ItemRenderer>

In the main application:

<s:Application name="Spark_List_itemRenderer_hovered_test" xmlns:fx="" xmlns:s="library://" xmlns:mx="library://"> <fx:Style source="test.css"/> <s:List id="lst" itemRenderer="CustomItemRen" width="300" horizontalCenter="0" verticalCenter="0"> <s:layout> <s:VerticalLayout gap="0" horizontalAlign="justify" requestedRowCount="8" /> </s:layout> <s:dataProvider> <s:ArrayList> <fx:Object label="Application" /> <fx:Object label="Label" /> <fx:Object label="List" /> </s:ArrayList> </s:dataProvider> </s:List> </s:Application>

-------------Problems Reply------------

In this line, you didn't initialize the event object ("tryEvent" like new CustomDeleteEvent())..

and also in your "CustomDeleteEvent"..there is "type" parameter, which is not in "tryEvent" object...

var tryevent:CustomDeleteEvent; owner.dispatchEvent(tryevent,deleteItem);

Use below code for dispatch the event....

owner.dispatchEvent(new CustomDeleteEvent(CustomDeleteEvent.DELETE_ITEM, deleteItem));

hope this will help you....

Category:flex Views:4 Time:2014-02-20
Tags: flex

Related post

  • How can I redirect a 404 Error in a custom 404 page using Codeigniter? 2010-02-22

    Kind sirs, I'm using Codeigniter to build a blog. I might need a way to redirect a 404 error into a custom 404 page. Just like what's 404 page. Is it possible to control this by using routes? Or should i use controllers to direct it to

  • How to wrap Zend_Form error message in custom html? 2010-03-09

    I need to wrap zend form error messages in custom html. <div class="cerror" id="ID-error"> <div class="ui-widget"> <div class="ui-state-error ui-corner-all" id="IDerror-msg"> %ZEND_FORM_ERROR_MESSAGE% </div> </div> </

  • Why The error message for custom validator is not shown in message box? 2011-01-16

    I have tried in many way but the error message for custom validator is not shown in validation summary but it(ValidationSummary) shows error message for every other type of validator. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Expt_Cu

  • Duplicate Id error when using custom component in JSF1.1 with DataTable 2011-05-05

    I am getting the following error when i try to return to same page without redirect. org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Duplicate component ID '_id20' fo

  • Finding Classic ASP errors in a custom 404 error page in IIS7 2012-03-12

    We are migrating some Classic ASP sites from an IIS6 box to a new Server 2008 box running IIS7. We have been through a learning process with regard to custom errors and now have these working correctly and Server.GetLastError is now working. The site

  • Error found in Custom UI XML of "Business Contact Manager for Outlook" 2012-12-05

    I checked the ""Show add-in user interface errors" box and am getting this message when I start Outlook Error found in Custom UI XML of "Business Contact Manager for Outlook" Line: 45 Cloumn: 48 Error code:0x0004005 Failed to find Office control by I

  • Error message: The custom form cannot be opened 2014-01-30

    Error message: The custom form cannot be opened. Outlook will use an Outlook form instead. The form required to view this message cannot be displayed. Contact your administrator. What does this message mean? Is there something I can do myself to corr

  • I get the error message. Custom UI runtime error. Error code: 0x80004005 2014-07-13

    Original Title: outlook 2010 "7" Custom UI runtime error one note notes about outlook item Error found in custom UI XMULF “ one note about outlook iems Line 1 Column 403 Error code 0x80004005 “violates minlingth of “1” The attribute “ screentip “ wit

  • jQuery Ajax error handling, show custom exception messages 2008-12-18

    Is there some way I can show custom exception messages as an alert in my jQuery Ajax error message? For example, if I want to throw an exception on the server side via Struts by "throw new ApplicationException("User name already exists");", I want to

Copyright (C), All Rights Reserved.

processed in 0.067 (s). 11 q(s)