How to dispatch events from custom AS3 classes to MXML
Hello,
I introduce some custom classes inside my SCRIPT tag in MXML.
These classes should dispatch custom Events (or any events for that
matter) and the listeners should be defined inside the SCRIPT tag.
In the custom class I have:
quote:
dispatchEvent(new Event("customEvent"));
And inside the script tag:
quote:
addEventListener("customEvent", testListener);
quote:
public function testListener(evt:Event):void{
Alert("Event fired successfully.");
However, this event is not handled in the listener (the alert
is not shown). What could be wrong?
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function init():void
addEventListener("customEvent", testListener);
dispatchEvent(new Event("customEvent"));
private function testListener(evt:Event):void{
Alert.show("Event fired successfully.");
Do like this
Alert is the Class Object. This is not the Function.
Similar Messages
-
Dispatch event from the main App file
Hi,I have one simple question.I know how to dipatch events from the some of the components files to the main App file,but I don't know how to do the opposite?
I have an HTTPService with id = "getData" in some component file and I want to dispatch an event that will send it getData.send();
Is this possible,and it if is how?It is possible but not a recommended practice.
Worst case you proxy out methods on your components and call directly:
maiAPpp.someComponent.doSomething();
SomeComponent
doSomething();
someOtherComponent.doSomething();
SomeOtherComponent
doSomething();
servcie.send();
My 2 cents are too look into MVC architecture and have the service inside a command which gets treiggered by a controlled which reacts to your event dispatched by the view.
C -
How to extract data from custom made Idoc that is not sent
Hi experts,
Could you please advise if there is a way how to extract data from custom made idoc (it collects a lot of data from different SAP tables)? Please note that this idoc is not sent as target system is not fully maintained.
As by now, we would like to verify - what data is extracted now.
Any help, would be appreciated!Hi,
The fields that are given for each segment have their length given in EDSAPPL table. How you have to map is explained in below example.
Suppose for segment1, EDSAPPL has 3 fields so below are entries
SEGMENT FIELDNAME LENGTH
SEGMENT1 FIELD1 4
SEGMENT1 FIELD2 2
SEGMENT1 FIELD3 2
Data in EDID4 would be as follows
IDOC SEGMENT APPLICATION DATA
12345 SEGMENT1 XYZ R Y
When you are extracting data from these tables into your internal table, mapping has to be as follows:
FIELD1 = APPLICATIONDATA+0(4) to read first 4 characters of this field, because the first 4 characters in this field would belong to FIELD1
Similarly,
FIELD2 = APPLICATIONDATA+4(2).
FIELD3 = APPLICATIONDATA+6(2).
FIELD1 would have XYZ, FIELD2 = R, FIELD3 = Y
This would remain true in all cases. So all you need to do is identify which fields you want to extract, and simply code as above to extract the data from this table.
Hope this was helpful in explaining how to derive the data. -
How to get username from customer email id.
Hi experts,
How to get username from customer email id.I am using transaction XD02.
I would be thankful for your kind replies .
Regards,
Sachin HadaHi sachin,
Re: Email id field
Regards,
Sravanthi -
How to export events from iPhoto in Iphone 5 to Mac?
How to export events from iPhoto in Iphone 5 to Mac? Thanks
Is this waht you want to do?
It's built into the File Export function of iPhoto 9 (11). Select what every photos you want and use that option to put each photo in a folder with the Event title it came from as in this test of six randomly picked photos:
OT -
How to get event from message?
Hi,All:
I write a run-time interface by CVI, I use TS_EngineRegisterUIMessageCallback to register my callback function, but when message passed to the callback function, as the type is struct IDispatch but not CAObjHandle, I don't know how to read event from message.
Can you help me to solve it? Thanks
Chang ZhangHello Chang-
If your question is simply how to obtain an object handle from an object of type IDispatch, have you investigated the function "CA_CreateObjHandleFromIDispatch"? I would recommend you look over the testexec.prj that is installed along with the TestStand engine (the CVI Operator Interface) and inspect how we handle our callbacks, this may help you understand how to go about emulating the behavior in your own project. To see this particular function in use it may be most helpful to look in the file 'engine.c' and inside the function UIMessageDeferredCallback here you will see the IDispatch pointer being handled and decoded for use by the TS engine.
Regards,
Elaine R.
Applications Engineering
National Instruments
http://www.ni.com/ask -
Dispatching event from Javascript
Can I dispatch events from javascript to flash player? I am trying to do so by calling dispatchEvent() on flash player dom object but the event is not passing inside flash player. Any links or clue?
To be specific ... I can catch a right click and supress it. But I want to send it to flash (lets say) as a left click. Problem is when i do that, javascript listner for dom element will get fired for left click but there wont be any events in flash.
SO the question is can i fire events on flash from outseide or is it outside the public APIs? -
Dispatching a simple event from classB to ClassA
Hi,
I have read at multiple places tutorials/explanations on the EventDispatcher use in AS3 and that confuses me a lot. I would appreciate a lot if somebody could show me in the simple exemple below how I should do to just send a simple message from a ClassB to a Class A. In the exemple below that I made, I have classA that calls classB to send a message that ClassA then gets. Of course, I simplified to the minimum the 2 classes to allow focusing on the problem. Currently, the exemple does NOT work, i.e. the line "trace ("message was received!");" is not executed.
I saw in several exemples on the web that some put the addEventListener on the EventDispatcher object. I do not understand the logic behind this, I would put the addEventListener on the objects that will receive the message.
I wonder also why can't I just put an addEventlistener at the ClassA constructor "addEventListener("hello", receivedHello);" and then send a dispatchEvent from classB. I tried that as well but it does not work.
package {
import flash.display.MovieClip;
import flash.events.Event;
public dynamic class ClassA extends MovieClip{
public function ClassA(){
ClassB.getClassB().registerUser(this);
ClassB.getClassB().sendMessage();
public function receivedHello(e:Event){
trace ("message was received!");
package{
import flash.events.Event;
import flash.events.EventDispatcher;
class ClassB {
public var sender:EventDispatcher;
// constructor
public function ClassB() {
sender= new EventDispatcher();
// function getClassB() to be sure only one instance of this class is running
public static function getClassB():ClassB {
if (ClassB._instance == null) {
ClassB._instance = new ClassB();
return ClassB._instance;
public function registerUser(user:Object){
user.addEventListener("hello", user.receivedHello);
public function sendMessage(): void {
sender.dispatchEvent(new Event("hello"));
Thanks so much in advance for your help
Pieterpackage {
import flash.display.MovieClip;
public dynamic class ClassA extends MovieClip{
public function ClassA(){
addEventListener("customEvent",f);
function f(e:Event){
trace("event received");
package{
import ClassA;
import flash.events.Event;
import flash.events.EventDispatcher;
class ClassB {
// constructor
public function ClassB() {
var a:ClassA = new ClassA();
a.dispatchEvent(new Event("customEvent")) -
Listening to event from custom component
I have a main.mxml file, and 2 custom components: component1.mxml and component2.mxml
I want to dispatch an event from component1 and handle it in component 2.
I'm able to do this by handling the event first in the main.mxml then passing it on.
But is there a way not to involve main.mxml, and to directly listen to the event from component 1 and handle it in component 2?
I need to listen the event in actionscript, not mxml.You can dig in to custom event handlers
Best Regards,
Yogesh -
How to override methods from dynamic instaniated class to call externally?
Hi,
Does anyone knows how to get processWindowEvent() from JFrame to call externally without having to override it in a subclass.
public class UserFrame extends JFrame {
public class Application {
public void main(String[] args) {
UserFrame frame = (UserFrame ) UserFrame .class.newInstance();
processWindowEvent(WindowEvent evt) {
the point is to get the instantiated UserFrame to call Application's processWindowEvent() whenever the window event is generated without having to override it in UserFrame.
Any expert on this?The point is there will be several subclasses of JFrame and I would not want to mannually override each subclasses, but by getting any JFrams's method to be delegated to call another method. VB.net, Delphi and etc. have a feature called class method delegation.
Java has a feature called method Proxy by using InvocationHandler class but is there any example how it could perform what I require? -
How to attach event to custome workflow object ?
Hi Guys,
Could someone help me on how to raise event while creating custom workflow object.We can attach event to object in transaction swe2 . I would like to know how to create that event. Could some send sample custom workflow object with events.
Many thanks in advance.
Cheers,
Garrick.Here's an example using Business object BUS2080 Service notification
I delegated ZBUS2080 to BUS2080 (service notification). Added 2 Events REASSIGNED and MODIFIED.
Use transaction SWO1 for manipulating business objects.
The User performs an action on a service notification (IW52) say PUT IN SERVICE AGAIN.
When the user puts the service notification in service again the event triggered will start a (user defined) workflow which makes a call to a method in the business object ZBUS2080 which launches a batch job.
This batch job creates our user event REASSIGNED which in turn calls a new workflow to be executed.
This workflow performs the action I want -- in this case to re-assign the service notification to a new person, send an email and escalate the deadlines
Code samples are shown below.
So here's how it works.
First you need to set up some entries with table SWE2. I've assumed you've already defined the events to the Business object(s) you want to use.
In SWE2 define entries for BUS2080 (or ZBUS2080) For Events INPROCESSAGAIN and (our event) REASSIGNED.
IN SWE2 define the receiver call as a FUNCTION MODULE
For the receiver function modules for the SAP event (INPROCESSAGAIN) define the receiver module as SWW_WI_CREATE_VIA_EVENT
For the event REASSIGNED define the receiver module as SWW_WI_CREATE_VIA_EVENT_IBF.
I have no idea whatwhat the difference is between the two but the process works when it's done like this.
Ensure the linkage Activated box is clicked in both cases.
Put your workflow numbers in the RECEIVER TYPE in SWE2 table.
In the first workflow when the user puts the service notification in service ensure your workflow starts a batch job which raises another event
Note : You need to instantiate the object (I.e supply the key) to trigger the event correctly. The key is obtained from the WF and will be in the container anyway.
You can do this by adding this type of function module into the method of the business object you want to execute during the first workflow. The code here creates a batch job which submits the EVENT creating program.
function z_create_event_for_cs.
""Local interface:
*" IMPORTING
*" REFERENCE(OBJECT_KEY) LIKE SWOTOBJID-OBJKEY
*" REFERENCE(W_REASON) LIKE HRPXXXX-DUMMY
*" REFERENCE(W_ESCLEVEL) LIKE HRPXXXX-DUMMY
Create Batch job to run ZZREASSIGNCS
which creates event REASSIGNED in Customer query workflow.
data: jobnr like tbtcjob-jobcount,
jobname like tbtcjob-jobname,
pgmname like sy-repid,
w_key like viqmel-qmnum,
w_code type c,
w_num type c.
w_num = w_esclevel.
jobname = 'CREATEEVENT'.
pgmname = 'ZZREASSIGNCS'.
call function 'JOB_OPEN'
exporting
jobname = jobname
importing
jobcount = jobnr
CHANGING
RET =
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = object_key
importing
output = w_key.
w_code = w_reason.
if w_code = ' '.
w_code = 'Z'.
endif.
submit zzreassigncs
with p_key = w_key
with p_escl = w_code
with p_escnum = w_num
via job jobname number jobnr
and return.
call function 'JOB_CLOSE'
exporting
jobcount = jobnr
jobname = jobname
strtimmed = 'X'
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
others = 9
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endfunction.
For the actual program which creates the event use something like this
program zzreassigncs.
This program creates an event REASSIGN
This triggers a "clone" of the initial customer query workflow
which is now marked as completed.
The deadline and escalation level from the original workflow
should be passed to the new workflow via the event container
Program is submitted from the original workflow
Ensure transaction SWE2 has the event REASSIGN for bus object BUS2080
defined or the WF won't start even if the event is raised correctly
As this program is run as a background / batch task
you need to obtain the relevant notification number and pass it
as a parameter.
When run from the WF the you can get the notification number obtained
from the workflow / task container.
include <cntn01>. "For WF macros.
parameters: p_key like swotobjid-objkey, "Service notification number
p_escl type c,
p_escnum type c.
constants: c_event like swetypecou-event value 'REASSIGNED',
c_attrib like swotra-attribute value 'USRSTATUS',
c_object like swetypecou-objtype value 'BUS2080'.
data: w_object like swotobjid,
w_stat like tj30t-txt04.
data: rc like sy-subrc.
data: begin of event_cont occurs 0.
include structure swr_cont.
data: end of event_cont.
data: begin of return.
include structure swotreturn.
data end of return.
if running from WF rather than a batch job
swc_container container.
swc_get_element container 'Znumber' p_key.
w_object-objkey = p_key.
w_object-objtype = 'BUS2080'.
call function 'SWO_PROPERTY_GET'
exporting
object = w_object
attribute = c_attrib
changing
value = return.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
w_stat = return(4).
event_cont-element = 'Status'.
event_cont-value = w_stat.
append event_cont.
event_cont-element = 'Escalated'.
event_cont-value = p_escl.
append event_cont.
event_cont-element = 'Escalation'.
event_cont-value = p_escnum.
append event_cont.
Note WAPI calls only valid from rel 6.1 using Webflow engine
(part of standard WF since rel 6.1)
CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
EXPORTING
OBJECT_TYPE = w_object-objtype
OBJECT_KEY = w_object-objkey
EVENT = 'REASSIGNED'
IMPORTING
RETURN_CODE = rc
EVENT_ID =
TABLES
INPUT_CONTAINER = event_cont.
if rc <> 0. "Houston ---We have a problem !! '
write: text-002 color col_negative.
exit.
endif.
even though no database / table is updated here by the event
we still need the commit work to initiate the event correctly
commit work.
You CAN use Objects (OO ABAP) but if you are fairly new to this sort of stuff just stick with standard BOR (Business objects) to parctice on until you've got the hang of the process.
It's actually a lot simpler than most people realize --which is why WF consultants get paid decently !!!!.
Cheers
Jimbo -
Can I dispatch an event from the skin and have the hostcomponent listen it? I have a text input and an info icon in frnt of it, I want to show the tooltip of the textinput when there is a rollover event on the icon. I wrote a skin with the textinput and icon and in the rollover event on the icon I am dispatching an event and added an event listener to the hostcomponent of the skin. It seems like hostcomponent is not listening the event.
My skin handles all the animation logic and contains the image and the textinput,and then I am extending the skinnable component class with the two skin parts and controlling the skin states from there. In the rollover event I dispatched an event which host omponent is supposed to catch and do the following:
myTextInput. tooltip = _toolTip
_toolTip is in the construcotr of the hostcomponent.
What is wrong in what I did? Why is my host component not receiving a event from the skin?Thanks for your reply. My code is kinda long and apparently I can't copy paste in this window(not sure why).
Is there any way to attach the code somehow? -
How to delete events from iPhone/iCal
How can I delete old/no longer happening recurring events--or any events--from my iPhone?
If you see the "+" button then you have not clicked on the event you want to delete. When you do you will see another screen that looks like the one below.
-
Target movieclip from an AS3 class file - remove/add Child
Halo.
I have a very simple question (for those who use external class files).
Assuming that I have a MovieClip manually added to Stage and I want to access it from inside my class definiton.
So the code would be:
MovieClip(root).MyMovieClip
But I can't figure out how to use remove/add Child in that kind of situation.
I will appreciate any advice.
Thanksif you can reference using that, you can remove using:
MovieClip(root).MyMovieClip.parent.removeChild(MovieClip(root).MyMovieClip);
and you can add to any displayobjectcontainer. -
IDOC :: how to send data from Custom Infotype in SAP HR to third party
Hi,
I have created one custom Infotype by number 9020. How to send data from this infotype to third party system and also change pointers need to trigger for this infotype.
Please help me in doing it.
I am using one Custom Message type ZTALENT and Custom Idoc Type ZTALENT.
ZTALENT Talent Management
5 E1PLOGI Header for an HR Object (Master Data or Organizational Data)
5 E1PITYP HR: Transported Infotypes and Subtypes for an Object
ZPUSER User base Data File
ZPERSON Personal Information File Segment
ZPOST Position File
ZOPE Overall Performance
ZPWORK Outside Work Experience
ZPEDUC Education Details of Employee
E1P0000 HR: HR Master Record Infotype 0000 (Actions)
E1P0001 HR: HR Master Record Infotype 0001 (Org. Assignment)
E1P0002 HR: HR Master Record Infotype 0002 (Personal Data)
E1P0016 HR Master Record: Infotype 0016 (Contract Elements)
E1P0022 HR Master Record: Infotype 0022 (Education)
E1P0023 HR Master Record: Infotype 0023 (Other/Previous Employers)
E1P0041 HR Master Record: Infotype 0041 (Date Specifications)
E1P0105 HR: HR Master Record Infotype 0105 (Communications)
ZE1P9020
ZPLANG Language Details
ZACTION Actions Changes
Regards,
KrishnaHello Shankar,
Technically TEMSE files are read by calling the following 3 function modules in sequence,
1) RSTS_OPEN_RLC or RP_TS_OPEN: open the temse object
2) RSTS_READ : read the object
3) RSTS_CLOSE: close the object
Regards,
Rajesh
Maybe you are looking for
-
Issue with if condition in smartform text elements
Hi all. iam having a problem in smart forms itab has 3 fields id matnr werks 1 a p1 1 b p2 1 c p3 2 b l1 2 c l2 3 q u1 3 l u2 i neead output like in the smart form -id = 1- a p1 b p2 c p3 -id = 2- b l1 c l2 -id = 3- q u1 l u2 I have aloop in mai
-
Ask to shut down when pressing backspace or eject button
I recently changed my topcase (macbook late 2007) through an official repair service and after some days I noticed that when i press the button "backspace" or "disk eject" the computer asks me "Are you sure you want to shut down your computer now? (R
-
Creating table using joins in subquery
can we create a table by using joins in subquery?? like this create table emp as select * from employees e,departments d where d.department_id=e.department_id can we ??
-
i get the message lightroom V5.5 is availeble, i downloaded it, but i always get the error, lightroon.msi is missing, fault 1714, can not uninstall V5.5 ( and i just want to install that ??? )
-
Cannot connect to mobile hotspot using wpa; only open security works
I have a Galaxy S5 and am trying to connect to the mobile hotspot using my Surface tablet. If I have the mobile hotspot setup using WPA2 security with a password I cannot connect however I can connect if I am using Open security. I can connect the s