Согните - TypeError: Ошибка № 1034: Напечатайте подведенное Принуждение: не может преобразовать flash.events:: [email protected] к mx.events. CloseEvent

Получаю ошибку, загружая данные во всплывающем окне.

Ошибка:-

TypeError: Ошибка № 1034: Напечатайте подведенное Принуждение: не может преобразовать flash.events:: [email protected] к mx.events. CloseEvent. в flash.events:: EventDispatcher/dispatchEventFunction () в flash.events:: EventDispatcher/dispatchEvent () в mx.core:: UIComponent/dispatchEvent () в com.nxp.pcn.modules.avl. view::AvlMediator/onAutoConfirmUploadPtaFile()[D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\view\AvlMediator.as:219] в flash.events:: EventDispatcher/dispatchEventFunction () в flash.events:: EventDispatcher/dispatchEvent () в mx.core:: UIComponent/dispatchEvent () в com.nxp.pcn.modules.avl.view.components.popups:: статистика AvlUploadPopup/set() [D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\view\components\popups\AvlUploadPopup.mxml:138] в com.nxp.pcn.modules.avl. view::AvlMediator/validateUploadedProducts()[D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\view\AvlMediator.as:339] в com.nxp.pcn.modules.avl. view::AvlMediator/handleNotification()[D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\view\AvlMediator.as:312] в Function /http://adobe.com/AS3/2006/builtin:: обратитесь () в org.puremvc.as3.multicore.patterns.observer:: Observer/notifyObserver() [C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\observer\Observer.as:100] в org.puremvc.as3.multicore.core:: View/notifyObservers() [C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\core\View.as:114] в org.puremvc.as3.multicore.patterns.facade:: Facade/notifyObservers() [C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\facade\Facade.as:294] в org.puremvc.as3.multicore.patterns.facade:: Facade/sendNotification() [C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\facade\Facade.as:277] в org.puremvc.as3.multicore.patterns.observer:: Notifier/sendNotification() [C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\observer\Notifier.as:60] в com.nxp.pcn.modules.avl. model::AvlProxy/uploadProductsResult()[D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\model\AvlProxy.as:77] в flash.events:: EventDispatcher/dispatchEventFunction () в flash.events:: EventDispatcher/dispatchEvent () в mx.rpc:: AbstractOperation/http://www.adobe.com/2006/flex/mx/internal:: dispatchRpcEvent () в mx.rpc:: AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal:: resultHandler () в mx.rpc:: респондент/результат () в mx.rpc:: AsyncRequest/acknowledge () в NetConnectionMessageResponder/resultHandler () в mx.messaging:: MessageResponder/result ()

И я загружаю код здесь.

пакет com.nxp.pcn.modules.avl.view { импорт com.evelopers.flex.components.placedmodule.view.components. ModulePlaceholder; импорт mx.collections. ArrayCollection; импорт com.evelopers.flex.components. Confirmator; импорт com.nxp.pcn.modules.avl.view.components. Avl; импорт com.nxp.pcn.modules.avl.view.components.renderers. AvlPartNumberRenderer;

import com.nxp.pcn.modules.avl.view.components.popups.AvlUploadPopup;
import com.nxp.pcn.modules.avl.view.components.popups.ManageActivationPopup;
import com.nxp.pcn.shell.model.vo.AvlProductVO;
import com.nxp.pcn.modules.avl.AvlConstants;
import com.nxp.pcn.modules.avl.view.components.sf.searchAvl;
import com.nxp.pcn.shell.interfaces.IDictionaryVO;
import flash.events.Event;
import com.nxp.pcn.shell.ApplicationConstants;
import com.nxp.pcn.shell.model.SessionUserProxy;

import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;
import com.evelopers.flex.modules.ValueListModule;
import com.nxp.pcn.modules.avl.view.AddAvlProductMediator;
import com.nxp.pcn.modules.avl.view.ManageActivationPopupMediator;
import flash.display.DisplayObject;
import flash.utils.setTimeout;
import mx.utils.ObjectUtil;
import mx.managers.PopUpManager;
import mx.core.FlexGlobals;
import com.nxp.pcn.modules.avl.model.vo.AvlAttachmentVO;
import com.evelopers.flex.utils.PopupUtils;
import com.nxp.pcn.modules.avl.model.vo.AvlUploadStatsVO;
import com.nxp.pcn.shell.helpers.Tracer;
import com.nxp.pcn.shell.view.components.ProductDescriptionPopup;
import com.evelopers.flex.utils.PopupUtils;
import com.nxp.pcn.shell.model.SessionUserProxy;
import flash.display.DisplayObject;
import com.evelopers.flex.helpers.SmartEvent;
import flash.external.ExternalInterface;
import mx.utils.StringUtil;
import com.nxp.pcn.shell.model.vo.CompanyVO;

public class AvlMediator extends Mediator
{
    public static const NAME:String = "AvlMediator";
    private var _sessionUserProxy:SessionUserProxy;
    private var _dicts:Object = {};
    public var _productsToRemove:Array;
    private var _uploadAvlPopup : AvlUploadPopup;

    public var avlCompanies : ArrayCollection;

    public function AvlMediator(viewComponent:Avl)
    {
        super(NAME, viewComponent);
    }

    override public function onRegister():void {
       //Retrieve the proxies
        _sessionUserProxy = facade.retrieveProxy(SessionUserProxy.NAME) as SessionUserProxy;

       //Create and register Mediators
        component.addEventListener(Avl.REJECT, onReject);
        component.addEventListener(Avl.REJECT_UPLOAD, onRejectUpload);
        component.addEventListener(Avl.UPLOAD, onUpload);
        component.addEventListener(Avl.ADD_PRODUCT, onAddProduct);
        component.addEventListener(Avl.REMOVE_PRODUCT, onRemoveProduct);
        component.addEventListener(Avl.DOWNLOAD_AVL_TEMPLATE, onDownloadAvlTemplate);
        component.addEventListener(Avl.MANAGE_ACTIVATION, onManageActivation);
        component.addEventListener(AvlPartNumberRenderer.VIEW_PRODUCT_DETAILS, onViewProductDetails);
        //component.addEventListener(ManageActivationPopupMediator.POPUP_REMOVED, onManageActivationPopupRemoved);

       //Register view handlers
        sendNotification(ApplicationConstants.GET_SESSION_USER);
        sendNotification(ApplicationConstants.REQUEST_DICTIONARY, ApplicationConstants.dicts.CUSTOMER_ACTIVE_COMPANIES);
        sendNotification(AvlConstants.GET_AVL_COMPANIES);

       //register Mediators
        facade.registerMediator(new AddAvlProductMediator());
        facade.registerMediator(new ManageActivationPopupMediator());

    }

    public function get selectedOrg():CompanyVO
    {
        return component.selectedOrg;
    }

    private function onDownloadAvlTemplate(event:Event):void
    {
        Tracer.trace(this, sf.sessionUser, 'session user');
        Tracer.trace(this, StringUtil.substitute(ApplicationConstants.urls.AVL_SPECIFIC_EXPORT_SERVLET, ApplicationConstants.valueLists.AVL_PRODUCT_TEMPLATE_VL), 'on download avl template');
        ExternalInterface.call('downloadFile',
            StringUtil.substitute(ApplicationConstants.urls.AVL_SPECIFIC_EXPORT_SERVLET,
                ApplicationConstants.valueLists.AVL_PRODUCT_TEMPLATE_VL));
    }

    private function onRejectUpload(event:Event):void
    {
        sendNotification(AvlConstants.PRODUCTS_UPLOAD_REJECT_QUERY);
    }
    /*

    */
    /*
    private function onManageActivationPopupRemoved(e:Event):void
    {
        Tracer.trace(this, 'onManageActivationPopupRemoved', 'AvlMediator');
        facade.removeMediator(ManageActivationPopupMediator.NAME);
    }
    */

    private function onUpload(e:Event):void
    {
        PopupUtils.addFixedPopup(uploadAvlPopup, FlexGlobals.topLevelApplication as DisplayObject, true);
        uploadAvlPopup.updateView();
    }

    private function onManageActivation(e:Event):void
    {
        sendNotification(AvlConstants.ADD_MANAGE_ACTIVATION_POPUP);
        /*
        var detailsPopup:ManageActivationPopup = new ManageActivationPopup();
        //detailsPopup.productData = event.data;
        //detailsPopup.sessionUser = (facade.retrieveProxy(SessionUserProxy.NAME) as SessionUserProxy).userVO;
        PopupUtils.addFixedPopup(detailsPopup, this.component, true);
        */
    }

    private function onViewProductDetails(event:SmartEvent):void {
        var detailsPopup:ProductDescriptionPopup = new ProductDescriptionPopup();
        detailsPopup.productData = event.data;
        detailsPopup.sessionUser = (facade.retrieveProxy(SessionUserProxy.NAME) as SessionUserProxy).userVO;
        PopupUtils.addFixedPopup(detailsPopup, event.target as DisplayObject, true);
    }

    public function get uploadAvlPopup():AvlUploadPopup {
        if (_uploadAvlPopup == null) {
            _uploadAvlPopup = new AvlUploadPopup();
            _uploadAvlPopup.addEventListener(AvlUploadPopup.AUTO_CONFIRM_UPLOAD, onAutoConfirmUploadPtaFile);
            _uploadAvlPopup.addEventListener(AvlUploadPopup.CONFIRM_UPLOAD, onConfirmUploadPta);
            _uploadAvlPopup.addEventListener(AvlUploadPopup.REJECT_UPLOAD, onRejectUploadPta);

            _uploadAvlPopup.addEventListener(AvlUploadPopup.UPLOAD_FILE, onUploadPtaFile);
            var orgs:ArrayCollection = new ArrayCollection( ObjectUtil.copy(avlCompanies.source) as Array);
            //orgs.removeItemAt(0);
            _uploadAvlPopup.organizations = orgs;

            //Tracer.trace(this, selectedOrg, 'selected org');

            if (selectedOrg)
            {
                for each (var org : CompanyVO in _uploadAvlPopup.organizations)
                {
                    if (org.name == selectedOrg.name)
                    {
                        setTimeout(setUploadOrg, 500, org);
                    }
                }
            }

            _uploadAvlPopup.addEventListener(Event.CLOSE, function(event:Event):void
                {
                    PopUpManager.removePopUp(_uploadAvlPopup);
                    sendNotification(ApplicationConstants.CP_REJECT_PTA_UPLOAD_QUERY);
                    _uploadAvlPopup = null;
                });
        }
        return _uploadAvlPopup;
    }

    private function setUploadOrg(org:CompanyVO):void
    {
        _uploadAvlPopup.companyCombo.selectedItem = org;
        _uploadAvlPopup.companyCombo.text = org.name;
    }

    private function onConfirmUploadPta(event:Event):void 
    {
        PopUpManager.removePopUp(_uploadAvlPopup);
        sendNotification(AvlConstants.PRODUCTS_UPLOAD_CONFIRM_QUERY, true);
    }

    private function onRejectUploadPta(event:Event):void 
    {
        PopUpManager.removePopUp(_uploadAvlPopup);
        sendNotification(AvlConstants.PRODUCTS_UPLOAD_REJECT_QUERY);        
    }

    private function onUploadPtaFile(event:Event):void {
        var att:AvlAttachmentVO = new AvlAttachmentVO();
        att.companyId = _uploadAvlPopup.companyCombo.selectedItem.id;
        att.fileReference = uploadAvlPopup.fileReferenceVO;            
        sendNotification(AvlConstants.PRODUCTS_UPLOAD_QUERY, att);

        Tracer.trace(this, att, 'upload file');

    }

    private function onAutoConfirmUploadPtaFile(event:Event):void {
        sendNotification(ApplicationConstants.INFO_MESSAGE, 'Avl file has been uploaded successfully');
        sendNotification(ApplicationConstants.INFO_MESSAGE, 'A new match has been made, organization list has been re-created.');
        uploadAvlPopup.dispatchEvent(new Event(Event.CLOSE));
        //reloadPcn(pcnCreation.pcnVO, CreationProductsSection.NAME);
    }

    private function onConfirmUploadPtaFile(event:Event):void {
        //sendNotification(ApplicationConstants.CP_CONFIRM_UPLOAD_PTA_QUERY, true);
    }

    private function onRejectUploadPtaFile(event:Event):void {
        //sendNotification(ApplicationConstants.CP_CONFIRM_UPLOAD_PTA_QUERY, false);
    }


    private function onReject(event:Event):void
    {
        sendNotification(AvlConstants.PRODUCTS_REJECT_QUERY);
    }

    private function onAddProduct(e:Event):void
    {
        sendNotification(AvlConstants.AVL_ADD_PRODUCT_POPUP);
    }

    private function onRemoveProduct(e:Event):void
    {
        var fullData:ArrayCollection = avl.vlStateData.fullData;
        _productsToRemove = [];//
        for each (var record : Object in fullData)
        {
            if (record['isSelected'])
            {
                _productsToRemove.push(new AvlProductVO(uint(record['companyId']), record['nc12']));
            }
        }

        if (_productsToRemove.length == 0) return;

        if (fullData.length == _productsToRemove.length && _productsToRemove.length > 1) 
        {
           //Gonna delete ALL distributors
            new Confirmator('Remove Products confirmation',
                'You are about to remove ALL products\nPress "OK" to proceed',
                Confirmator.OK_CANCEL, removeAllProducts);
        } else {
            new Confirmator('Remove Products confirmation',
                'You are about to remove ' + _productsToRemove.length + ' product(s)\nPress "OK" to proceed',
                Confirmator.OK_CANCEL, removeProducts);
        }

    }

    private function removeProducts(event:Event):void 
    {
        sendNotification(AvlConstants.AVL_REMOVE_PRODUCTS_QUERY, _productsToRemove);
        _productsToRemove = null;
    }

    private function removeAllProducts(event:Event):void 
    {
        sendNotification(AvlConstants.AVL_REMOVE_PRODUCTS_QUERY);
    }

    override public function listNotificationInterests():Array 
    {
        return [
            ApplicationConstants.RESPONSE_DICTIONARY,
            AvlConstants.PRODUCTS_ADD_CONFIRMED,
            AvlConstants.PRODUCTS_ADD_CONFIRMED_RESULT,
            AvlConstants.PRODUCTS_REJECT_QUERY,
            AvlConstants.PRODUCTS_DELETED,
            AvlConstants.PRODUCTS_UPLOAD_QUERY_RESULT,
            AvlConstants.PRODUCTS_UPLOAD_CONFIRMED,
            AvlConstants.PRODUCTS_UPLOAD_QUERY_FAULT,
            AvlConstants.GET_AVL_COMPANIES_RESULT

        ];
    }

    override public function handleNotification(note:INotification):void 
    {
        switch (note.getName()) 
        {
            case ApplicationConstants.RESPONSE_DICTIONARY:
            var dict:IDictionaryVO = note.getBody() as IDictionaryVO;
            switch (dict.getName()) 
            {
                case ApplicationConstants.dicts.CUSTOMER_ACTIVE_COMPANIES:
                _dicts[ApplicationConstants.dicts.CUSTOMER_ACTIVE_COMPANIES] = dict;
                sf.organizations = dict.filter;
                break;
            }
            break;
            case AvlConstants.PRODUCTS_UPLOAD_QUERY_RESULT:
            validateUploadedProducts(note);
            break;
            case AvlConstants.PRODUCTS_UPLOAD_QUERY_FAULT:
            PopUpManager.removePopUp(_uploadAvlPopup);
            break;
            case AvlConstants.GET_AVL_COMPANIES_RESULT:
            //Tracer.trace(this, note.getBody(), 'GET_AVL_COMPANIES_RESULT');
            avlCompanies = ArrayCollection(note.getBody());
            if(avlCompanies.length > 0){
                avl.hasAvlCompanies = true;
            }
            break;
            case AvlConstants.PRODUCTS_UPLOAD_CONFIRMED:
            case AvlConstants.PRODUCTS_ADD_CONFIRMED_RESULT:
            case AvlConstants.PRODUCTS_ADD_CONFIRMED:
            avl.vlSearchAvl.dispatchEvent(new Event(ValueListModule.DO_SEARCH));
            break;
            case AvlConstants.PRODUCTS_DELETED:
            sendNotification(ApplicationConstants.INFO_MESSAGE, 'Avl product(s) were removed successfully');
            avl.vlSearchAvl.dispatchEvent(new Event(ValueListModule.DO_SEARCH));
            break;
        }
    }

    private function validateUploadedProducts(note:INotification):void
    {
        var stats : AvlUploadStatsVO = AvlUploadStatsVO(note.getBody());
        uploadAvlPopup.stats = stats;

        if (!uploadAvlPopup.isAutoConfirm()) 
        {
            PopupUtils.addFixedPopup(uploadAvlPopup, component, true);
        }
    }

    public function insertUI(placeholder:ModulePlaceholder):void 
    {
        component.sessionUser = _sessionUserProxy.getSessionUser();

        if (!component.sessionUser) {
            return;
        }

        placeholder.addChild(component);
    }       

    private function get component():Avl 
    {
        return viewComponent as Avl;
    }

    private function get avl():Avl
    {
        return component;
    }

    private function get sf():searchAvl
    {
        return component.sf;
    }
    public function getCurrentOrg():int
    {
        if (sf.searchFilter.obj.companyId == null)
        {
            return -1;
        } else
        {
            return sf.searchFilter.obj.companyId.id;
        }

    }

}

}

Пожалуйста, сообщите мне, где проблема и как решить его.

С уважением, Рави

0
de
я попробовал то же самое.. но это дает то же самое сообщение об ошибке.
добавлено автор Ravikanth, источник
Иногда вы получаете конфликты типа, если вы работаете с модулями, и браузер загружает более старую версию модуля от тайника. В этом случае необходимо очистить кэш браузера и видеть то, что происходит.
добавлено автор splash, источник

1 ответы

Необходимо послать близкое мероприятие с CloseEvent класс в вашем onAutoConfirmUploadPtaFile функция. Вместо

uploadAvlPopup.dispatchEvent(new Event(Event.CLOSE));

необходимо написать

uploadAvlPopup.dispatchEvent(new CloseEvent(Event.CLOSE));

Иначе соответствующий укладчик споткнется выше Событие класс, в то время как это ожидает CloseEvent класс.

2
добавлено
Спасибо.. Это хорошо работает...
добавлено автор Ravikanth, источник