Broadcast events between classes (objects)
Hello,
I'm can't figure out how to broadcast an event to another
class.
In actionscript 2 I created 2 classes. The first class called
the second class to load a file from an url. When the file was
loaded I used dispatchEvent({type: "fileLoaded", target: this,
filename: sFilename})
In the first I simply wrote addEventListener("fileLoaded",
handleFile)
But with AS3 this no longer works.
Can anyone tell me how to accomplish this? Because I can't
find a clear example and I don't know how to do this.
In the defintion of your custom event I miss the isEnabled
part (don't know if that has anything to do with the issue though).
Below a custom event that works for me
package Components {
import flash.events.Event;
public class ZoomEvent extends Event
public var isEnabled:Boolean;
public static const ZOOM:String = 'zoom';
public var vertical:Boolean = true;
public var minvalue:Number = 0;
public var maxvalue:Number = 0;
public var zoomfactor:Number = 0;
public function ZoomEvent(type:String,
isEnabled:Boolean=false) {
super(type);
this.isEnabled = isEnabled;
public override function clone():Event {
return new ZoomEvent(type, isEnabled);
Furthermore I have somewhere read in the documentation that
using custom event should go together with adding an embedded
statement like: [Event(name="update",
type="Components.UpdateEvent")] in the class where you use the
event, but for me it also works without this embedding code (???)
And is your class XMLData a subclass from a class that
supports dispatchEvent. I do not know what classes support
dispatchEvent, maybe all. Then this remark makes no sense.
Good Lcuk
Similar Messages
-
Controlling events between classes
hello
i know i'm asking a lot, but i couldn't find anything. the problem is i've got a jframe and some panels with buttons.
eg:
class A extends JFrame
getContentPane().add( B ) ;
getContentPane().add( C ) ;
class B extends JPanel
add( button1 ) ;
add( button2 ) ;
class C extends JPanel
add( button3 ) ;
add( button4 ) ;
where do i add ActionListeners? how do i pass information between classes? if button1 is clicked -> class A should know it.
i tried to do this in class A: objectOfB.button1 (access button1 directly) - didn't work - why?
if a button1 is clicked i want to remove the jpanel and replace it with another one. how should i do this?
Thank You AllCheck out the java tutorials. There are great examples that show you how to do what you want to do
-
Broadcast Event to all objects
I'd like to broadcast an event to all loaded modules. If I
understand bubbling correctly events can bubble up, but not across.
Lets say that a user logs out of the application. How do I pass
this "event" to all loaded modules.When in doubt, I use the system's root "dispatchEvent and
addEventListener/removeEventListener."
Here's an example:
SystemManager.getSWFRoot(this).dispatchEvent( new
ModulesEvent( ModulesEvent.MODULE_DATA_EVENT) );
...with...
SystemManager.getSWFRoot(this).addEventListener(ModulesEvent.MODULE_DATA_EVENT,
onDataArrival, false, int.MAX_VALUE);
...and...
SystemManager.getSWFRoot(this).removeEventListener(ModulesEvent.MODULE_DATA_EVENT,
onDataArrival); -
Event Bubbling Custom Object not inheriting from control
One of the new things flash flex and xaml have are ways which
the event easily bubbles up to a parent that knows how to handle
the event. Similar to exceptions travel up until someone catches
it.
My goal is to use the frameworks event system on custom
objects. My custom objects are:
ApplicationConfiguration
through composition contains:
SecurityCollection which contains many or no SecurityElements
and
FileSystemCollection.cs which contains many or no
FileSystemElement objects
ect ect basically defining the following xml file with custom
objects.
[code]
<ApplicationConfiguration>
<communication>
<hardwareinterface type="Ethernet">
<ethernet localipaddress="192.168.1.2" localport="5555"
remoteipaddress="192.168.1.1" remoteport="5555" />
<serial baudrate="115200" port="COM1" />
</hardwareinterface>
<timing type="InternalClock" />
</communication>
<filesystem>
<add id="location.scriptfiles" value="c:\\" />
<add id="location.logfiles" value="c:\\" />
<add id="location.configurationfiles" value="c:\\" />
</filesystem>
<security>
<add id="name1" value="secret1" />
<add id="name2" value="secret2" />
</security>
<logging EnableLogging="true"
LogApplicationExceptions="true" LogInvalidMessages="true"
CreateTranscript="true" />
</ApplicationConfiguration>
[/code]
basically these custom objects abstract the xml details of
accessing attributes, writing content out of the higher application
layers.
These custom objects hold the application configuration which
contains the users options. The gui application uses these
parameters across various windows forms, modal dialog boxes ect.
The gui has a modal dialog that allows the user to modify these
parameters during runtime.
basically i manage: load, store, new, edit, delete of these
configuration files using my custom objects.
Where would event propagation help in custom objects like
described above?
ConfigurationSingleton.getInstance().ApplicationConfiguration.CommunicationElement.Hardwar eInterfaceElement.EthernetElement.RemoteIPAddress
=
System.Net.IPAddress.Parse(this.textBoxRemoteEthernetIpAddress.Text);
The EthernetElement should propagate a changed event up to
the parent ApplicationConfiguration which would persist this to the
registry, db, file or whatever backend.
currently this logic is maintained else where. I serialize
the root node which compositely serializing the nested nodes and i
check of the serialization is different from that in the backend
… This tells me if the dom was modified. It works but i would
like an event driven system.
how should i implement bubbling using custom objects?
3 implementation ideas:
1) A simple way is to implement a singleton event manager:
EventManager.RegisterRoutedEvent
http://msdn2.microsoft.com/en-us/library/ms742806.aspx
I like this idea but how can you tell which object is nested
in who… this way the event can be stopped and discontinue
propagation?
2) If i use binders as discussed in Apress’s book:
Event-Based
Programming Taking Events to the Limit
basically a binder connects the events between seperate
objects together… although it would work for my app, I would
like a more generalized approach so i can reuse the event system on
future project.
3) how does flash flex handle this..
objectproxy.as?
http://www.gamejd.com/resource/apollo_alpha1_docs/apiReference/combined/mx/utils/ObjectPro xy.html#getComplexProperty()
>Provides a place for subclasses to override how a complex
property that needs to be either proxied or daisy chained for event
bubbling is managed.
how does these systems all work....? Reflection ?
this way i can simulate this on my own custom classes.
Thanks!I have a strong sensation that the OSMF project is quite dead.
no new submits since 2010, the contact form on the offical OSMF
project website http://www.opensourcemediaframework.com/
returns a PHP error.
and many unanswered questions about OSMF in this forum.
i think it would be wise to not use OSMF if possible, although
I'm also stuck with it since we are utilizing HDS/PHDS
protocols which are utilized in the framework.
otherwise its quite a head-ache.
I'm unable to get to a video element coming from a proxied element
that is being produced via an HDS connection.
and haven't found any solution that works. -
Custom Events and Listeners between classes
I've got a project I've been working on for weeks that I'm
having yet another problem with. I'm trying to learn AS3 which is
why it's taking so long but that's not important for this post.
I wanted to create a custom event class so that I could make
sure the event does not interfere with other "COMPLETE" events that
are being passed between classes. In other words, I have a few
things that need to complete prior to a function being called...
one is some XML being loaded and another is a font loaded. So, I
thought I would create a custom FontLoaded class that extends Event
and make the type something like "FontLoadedEvent.LOADED". That way
I could listen for the XML "Event.COMPLETE" and this font event
also.
Please tell me if I'm going down the wrong path here but I
don't seem to be getting the dispatched event for my new custom
event. Also, how does one detect if it's being dispatched other
than if the eventListener is fired? Any other ways to test
this?You can trace the event to see if it dispatched.
Also, this is not a good case to create a new event. Custom
events are used to store additional information. MouseEvent exists
because Event doesn't have localX, localY, etc. properties. Since
you don't seem to be throwing additional properties, you can use a
regular event.
trace(dispatchEvent(new Event("panelFontsLoaded"));
addEventListener("panelFontsLoaded", onFontsLoaded);
Static consts are used to help debug typos. The event type is
just a string, often stored in a const. -
Difference Between Business Object And Class Object
Hi all,
Can any one tel me the difference between business object and class Object....
Thanks...
..AshishHello Ashish
A business object is a sematic term whereas a class (object) is a technical term.
Business objects are all important objects within R/3 e.g. sales order, customer, invoice, etc.
The business objects are defined in the BOR (transaction SWO1). The have so-called "methods" like
BusinessObject.Create
BusinessObject.GetDetail
BusinessObject.Change
which are implemented (usually) by BAPIs, e.g.:
Business Object = User
User.Create => BAPI_USER_CREATE1
User.GetDetail => BAPI_USER_GET_DETAIL
CONCLUSION: Business Object >< Class (Object)
Regards
Uwe -
Event dispatch between two objects not received
Hi,
In my application there are two objects: one is
myAc:ArrayCollection and the second is a mySprite:Sprite. myAC
stores coordinates and other custom fields of the mySprite objects.
I would like the sprite object to dispatch an event to the
array so that when changes are made to the mySprite object the myAC
can update itself.
In the mySprite object I have added the following code to
dispatch the event.
var e:Event = new Event("spriteMove", true);
dispatchEvent(e);
trace("dispatched");
In the myAC object I have set the following listener
this.addEventListener("spriteMove", spriteMoveHandler, true);
private function spriteMoveHandler( event:Event ):void
trace("recd event");
var sp:Object = event.target;
trace(sp.x);
I do not receive the event in the myAC object.
However, when I set a similar thing between the mySprite
object and one of its subobjects viz. myPoint I am able to receive
the event.
Thanks for the help,
RajuPlease do not duplicate your posts. It can be very confusing when two different persons answer the post in different ways.
-
Hi folks,
Ronny's here again on forums, having particularly 2 (two) questions/problems to resolve:
1) Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place
2) Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true
attached is the .zip file (as3_Countdown Timer_ver 1.0.1_by Ronny Depp.zip) with all flash source files containing:
a) The FLash Source (file: timer_module.fla) - (FLA flash source file - Flash CS3 Professional, Flash Player 9, actionscript 3.0)
b) com.othenticmedia.utils.dateAndTimeManagement package including 2 .as actionscript 3.0 Class files.
i) com.othenticmedia.utils.dateAndTimeManagement.DateAndTimeManager Class in the said package. (file: DateAndTimeManager.as)
ii) com.othenticmedia.utils.dateAndTimeManagement.CountdownTimer Class in the package. (file: CountdownTimer.as)
c) The compiled SWF file version of this Application's blueprint. (file: timer_module.swf).
What i need to confirm is: ........................................................ see the next post of mine. (for Problems need to be Resolved)Problems to Resolve:
Problem#1) - Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place.
Problem#2) - Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true;
Problem#1 Description:
I need to pinpoint the Logical TimeSync Exception, i am still unable to figure out. That is I'm using a webservice in my Application to Synchronize the Time with the actual ET (eastern time) with accomodation of auto-adjustment for EDT GMT-4 (eastern daylight time) & EST GMT-5 (eastern standard time), times. I am using the zipcode: "10012" to pass it to the Web Service in urlRequest object, to retrieve the Current ET eastern time according to EDT & EST time settings for Manhattan/Brooklyn areas or others within New York, NY 10012.
Currently the Web Service is returning accurate date/time based on local EDT GMT-4 daylight time.
Is there some defined set of dates for EDT & EST times for New York region that I can check for to ensure the correct Dates/Times for Eastern Time in New York area ??? I am using NY zipcodes because i am sure to get correct ET values.
The Major Problem Part: is I need to correct the time by 2 seconds or approx. 2 secs, some millisecs.
When I retrieve the Time Value from WebService, it lags behind for 2 seconds as compared to DateObj i create using computer's local time, on my Windows XP Service Pack 2 with Automatic Updates turned-on. And I'm sure about my Windows will be having latest updates for Time Management already installed. I also added the 2 secs. to the TimeSync(ed) Date to make correction to this Date obj.
I call my custom fucntion addSeconds(dateObj:Date, secs:int) to add 2 seconds to the Date by Converting Seconds to Milliseconds.
Please comb through the as code in files attached and Help Me Out !!!
Problem#2 Description:
Secondly I need to Detect the End of Stream state while using FLVPlayback component, an rtmp:// live Stream from FLASH MEDIA SERVER.
I need to Play a YuMe Post-Roll Ad when Steam Finishes/Ends.
Live Broadcast Stream Event starts every night on Wednesdays & Saturdays exactly at 10:59 PM EDT GMT-4.
Live Events only Streams/Broadcasts the stream for 50secs. exactly. When [playback stopped] it plays a PostRoll Ad and after the CountdownTimer again comes back to life. The Next upcoming Event is calculated & the Countdown begins until Next Event's time/date is reached.
Here is the code on the frame 1 on the MainTimeline: (rest of the params like source, volume, skinAutoHide are Set using Property Inspector for FLVPlayback instance on Stage)
//myStream instance of FLVPlayback is on the Stage
myStream.isLive = true;// Frame 1 Actions in the FLA
myStream.addEventListener(VideoEvent.COMPLETE, onEndOfStream);
myStream.addEventListener(VideoEvent.STATE_CHANGE, onState);
myStream.addEventListener(String(VideoError.NO_CONNECTION), onStreamError);
myStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
/*if(myStream.stopped){
trace("tracy: "+myStream.state);
} else if(myStream.state == VideoState.STOPPED){
trace("tracy: "+myStream.state);
function onStreamError(event:VideoError) {
trace(event.code + "\n\t" + event);
function onState(event:VideoEvent) {
trace(event.state + "\n\t" + event.toString());
function onEndOfStream(event:VideoEvent) {
trace(event.state + "\n\t" + event.toString());
function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
//connectStream();
break;
case "NetStream.Play.StreamNotFound":
trace("Stream not found: "/* + myStream.source*/);
break; -
Passing custom events between modules through parent application
I have created a custom event that I want to use to pass a string between two modules. The event looks like this:
package com.mypackage.events
import flash.events.Event;
public class ThumbDeleteEvent extends Event
public static const THUMBS_DELETED:String = "thumbsDeleted";
public var files:String;
public function ThumbDeleteEvent(type:String, files:String)
super(type);
this.files = files;
// Override the inherited clone() method.
override public function clone():Event {
return new ThumbDeleteEvent(type, files);
In one module I dispatch the event like so:
parentApplication.dispatchEvent(new ThumbDeleteEvent("parentApplication.thumbsDeleted", files));
and in another module I listen for the event like so:
public function init():void {
parentApplication.addEventListener("parentApplication.thumbsDeleted", onThumbsDelete);
if I use ThumbsDeleteEvent as the type passed in to the listener function like this:
public function onThumbsDelete(evt:ThumbDeleteEvent):void{
trace("thumb delete event for thumbs: "+evt.files);
I get the following error:
TypeError: Error #1034: Type Coercion failed: cannot convert com.mypackage.events::ThumbDeleteEvent@26748a31 to com.mypackage.events.ThumbDeleteEvent.
if I just use Event as the type passed in to the listener function like this:
public function onThumbsDelete(evt:ThumbDeleteEvent):void{
if(evt is ThumbDeleteEvent){
trace("thumb delete event for thumbs: "+(evt as ThumbDeleteEvent).files);
}else{
var type:XML = describeType(evt);
trace(type.toXMLString());
It works but does not think it is a ThumbDeleteEvent type class (it hits the else statement) the xml output of describe type says its type is:
type name="com.mypackage.events::ThumbDeleteEvent"
What is going on here? If I put a breakpoint in the debugger it says the event is a ThumbDeleteEvent and I can see the files parameter and its right???Sorry I have been trying all sorts of stuff and I cut and pasted the wrong version, I meant to put this:
if I just use Event as the type passed in to the listener function like this:
public function onThumbsDelete(evt:Event):void{
if(evt is ThumbDeleteEvent){
trace("thumb delete event for thumbs: "+(evt as ThumbDeleteEvent).files);
}else{
var type:XML = describeType(evt);
trace(type.toXMLString());
Then it gets passed to the else condition (it does not recognize it as a ThumbDeleteEvent) and this is the output of the trace:
<type name="com.helius.events::ThumbDeleteEvent" base="flash.events::Event" isDynamic="false" isFinal="false" isStatic="false">
<extendsClass type="flash.events::Event"/>
<extendsClass type="Object"/>
<constructor>
<parameter index="1" type="String" optional="false"/>
<parameter index="2" type="String" optional="false"/>
<parameter index="3" type="Boolean" optional="true"/>
<parameter index="4" type="Boolean" optional="true"/>
</constructor>
<variable name="files" type="String"/>
<accessor name="type" access="readonly" type="String" declaredBy="flash.events::Event"/>
<accessor name="bubbles" access="readonly" type="Boolean" declaredBy="flash.events::Event"/>
<accessor name="cancelable" access="readonly" type="Boolean" declaredBy="flash.events::Event"/>
<accessor name="target" access="readonly" type="Object" declaredBy="flash.events::Event"/>
<accessor name="currentTarget" access="readonly" type="Object" declaredBy="flash.events::Event"/>
<accessor name="eventPhase" access="readonly" type="uint" declaredBy="flash.events::Event"/>
<method name="stopImmediatePropagation" declaredBy="flash.events::Event" returnType="void"/>
<method name="preventDefault" declaredBy="flash.events::Event" returnType="void"/>
<method name="isDefaultPrevented" declaredBy="flash.events::Event" returnType="Boolean"/>
<method name="clone" declaredBy="com.helius.events::ThumbDeleteEvent" returnType="flash.events::Event"/>
<method name="toString" declaredBy="flash.events::Event" returnType="String"/>
<method name="formatToString" declaredBy="flash.events::Event" returnType="String">
<parameter index="1" type="String" optional="false"/>
</method>
<method name="stopPropagation" declaredBy="flash.events::Event" returnType="void"/>
</type>
This causes a TypeError:
public function onThumbsDelete(evt:ThumbDeleteEvent)
This causes a null pointer error because myevent is null:
public function onThumbsDelete(evt:Event):void{
var myevent:TumbDeleteEvent = (evt as ThumbDeleteEvent);
var files:String = myevent.files;
Here is what I see when I put a break point in and debug it:
I tried upgrading my event extender as you suggested, that had no effect. I removed the dot notation in the type and it does the exact same thing I.E. dispatching class:
parentApplication.dispatchEvent(new ThumbDeleteEvent("thumbsDeleted", files)); or
parentApplication.dispatchEvent(new ThumbDeleteEvent(ThumbDeleteEvent.THUMBS_DELETED, files));
and receiving class:
parentApplication.addEventListener("thumbsDeleted", onThumbsDelete);
I really appreciate your help, I am baffled by this, I have tried everything I can think of for two days and I am ready to start throwing things. -
Eventing between multiple IViews
I have multiple Dynpage IViews on one page. I raise and receive events between the IViews. I can alert the databag or eventObject values. The problem is when I try and write to the IView that has subxcribed to the event.
ending IView:
/****** store initial client data ******/
EPCM.storeClientData( 'urn:myOwnNameSpace', 'myData', '15' );
EPCM.storeClientData( 'urn:myOwnNameSpace', 'myData2', '10' )
/******* set the user name based off of the selected index for Request For *******/
function setRequest(){
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var ddl = eval(func("Request"));
var selectedIndex = ddl.getIndex();
var name = ddl.getValue(selectedIndex);
EPCM.raiseEvent( 'urn:myOwnNameSpace', 'myRequestFor', name );
Receiving IView:
[code]function myRequestHandler( eventObject ) {
var passedData = eventObject.dataObject;
var temp=EPCM.loadClientData('urn:myOwnNameSpace', 'myData');
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var myTime = eval(func("myTime"));
myTime.setValue(passedData);
EPCM.subscribeEvent( 'urn:myOwnNameSpace', 'myRequestFor', myRequestHandler);code]
The alert has the data passed but the values are not written back to the JAVA htmlb objects.
I did the same thing using JSP DYnpages and it works. I would prefer nto to use the JSP page. Do I have an optionthe problem is not missing the document element value. I have it. I can alert it to the browser. The problem is forcing the value back to the JAVA HTMLB form element within the class.
The problem is closed. I have gone the JSP route which is working.
Message was edited by: Tom Mosseau -
Why we need set the 'Create object xx' between 'class definition' and 'class implementation'??
If i set the 'CREATE OBJECT' under the 'Class implementation' in a report, the system will tell me that: 'Statement is not accessible'.
This is my code:
CLASS lcl_retal DEFINITION.
PUBLIC SECTION.
METHODS constructor.
PRIVATE SECTION.
DATA: lv_car(10) TYPE c VALUE 'CAR',
lv_truck(10) TYPE c VALUE 'TRUCK'.
ENDCLASS. "lcl_retal DEFINITION
CLASS lcl_retal IMPLEMENTATION.
METHOD constructor .
WRITE: lv_car, space, lv_truck.
ENDMETHOD. "print_detaile
ENDCLASS. "lcl_retal IMPLEMENTATION
DATA: lo_retal TYPE REF TO lcl_retal.
CREATE OBJECT lo_retal.
Edited by: YINYAN LU on Sep 2, 2009 9:14 AMClass definition - class implementation is treated by system as declaration part. This is similary considered as DATA, TYPES section.
Every single statement which is not part of declaration/definition is part of program to execute (is automatically embraced to START-OF-SELECTION event). In regular program when you set DATA, TYPES it can both occur in declaration part and in execution part. On the other hand CLASS...ENDCLASS is considered purely as declaration/definition (not executable code itself) so can't be placed in START-OF-SELECTION.
Assuming above, when you place CREATE OBJECT b/w CLASS....DEFINITON - CLASS .... IMPLEMENTATION it is recognized as part of executable code, but is placed within the one not intended to be executed. System can't split this code to declaration/execution part. It must be explicitly pointed. So it must be of strcuture
"------------------------- DECLARATION/DEFINITION ---------------------
CLASS lcl_retal DEFINITION.
PUBLIC SECTION.
METHODS constructor.
PRIVATE SECTION.
DATA: lv_car(10) TYPE c VALUE 'CAR',
lv_truck(10) TYPE c VALUE 'TRUCK'.
ENDCLASS. "lcl_retal DEFINITION
"<- here still part of this block, so no executable statements allowed
CLASS lcl_retal IMPLEMENTATION.
METHOD constructor .
WRITE: lv_car, space, lv_truck.
ENDMETHOD. "print_detaile
ENDCLASS. "lcl_retal IMPLEMENTATION
"---------------------------- EXECUTABLE CODE HERE ---------------
DATA: lo_retal TYPE REF TO lcl_retal.
CREATE OBJECT lo_retal.
Hope now it is clear
Regards
Marcin -
Is there a way to dispatch or bubble events between two pop-up windows?
Hi. I was wondering if there is a way to dispatch custom
events between two or more pop-up windows created using the
PopUpManager?
I understand how to pass an event from one pop-up window to
the main application (or FrontController) by dispatching the event
from Application.application under Cairngorm 2.0.
However, as I understand it, that will only bubble the event
through the Application chain of visual controls and not to the
other pop-up windows created using the PopUpManager.
I tried dispatching the event directly from the pop-up window
itself, but the other pop-ups still does not seem to receive the
event.
It would be nice to be able to do this so that each non-modal
pop-up can have some awareness with each other.
Thank you very much in advance.If you have just 2 pop-ups you can have them each do a
addEventListener on the other, listening for the event (custom or
otherwise).
If you have an unpredicatable number, then you devise
something else. Suppose you have 3 pop-ups, p1, p2, and p3. Let's
say you also have 1 custom event, E1. Any of those pop-ups is
capable of dispatching an E1 event and you want all of them to
receive it.
Create a class that extends EventDispatcher and instantiate
an object of that class. Each pop-up "registers" with that class,
something like:
controller.addEventListener( "E1", handler ); where handler
is a function in the pop-up.
When a pop-up wants to dispatch an E1 event, it does it
through the controller: controller.dispatchEvent( new E1(data) );
This will automatically dispatch that event to all the
pop-ups, including the one that dispatched the event. So a pop-up
will have to examine the event to see if it sent it and perhaps
ignore it. -
What are events. how to create and handle this events.
HI,
By triggering an event, an object or a class announces a change of state, or that a certain state has been achieved.Events link objects or classes more loosely than direct method calls do. Method calls establish precisely when and in which statement sequence the method is called. However, with events, the reaction of the object to the event is determined by the triggering of the event itself.
Events are most often used in GUI implementations.Other external object models, such as COM, ActiveX Controls etc, also provide events.
At the moment of implementation, a class defines its instance events (using the statement EVENTS) and static events (using the statement CLASS-EVENTS)
Classes or their instances that receive a message when an event is triggered at runtime and want to react to this event define event handler methods.
Statement : (CLASS-)METHODS | FOR ALL INSTANCES.
Every object that has defined events has an internal table: the handler table. All objects that have registered for events are entered in this table together with their event handler methods.Objects that have registered themselves for an event that is still live also remain live. The methods of these objects are called when the event is triggered, even if they can no longer be reached using main memory references.
If several objects have registered themselves for an event, then the sequence in which the event handler methods are called is not defined, that is, there is no guaranteed algorithm for the sequence in which the event handler methods are called.
If a new event handler is registered in an event handler method for an event that has just been triggered, then this event handler is added to the end of the sequence and is then also executed when its turn comes.
If an existing event handler is deregistered in an event handler method, then this handler is deleted from the event handler method sequence.
Events are also subject to the visibility concept and can therefore be either public, protected or private. Visibility establishes authorization for event handling :
all users
only users within that class or its subclasses
only users in that class.
Event handler methods also have visibility characteristics. Event handler methods, however, can only have the same visibility or more restricted visibility than the events they refer to.
The visibility of event handler methods establishes authorization for SET-HANDLER statements: SET HANDLER statements can be made
anywhere
in that class and its subclasses
only in that class
Regards,
Balaji Reddy G
**Rewards if answers are useful -
Difference between abap object and function
hi all,
i read the book on abap object of the difference between abap object and classical abap.
i know that there is only 1 instance of a specific function group but somehow i still not so clear why subsequent vehicle cannot use the same function. i also can use the do and loop to call the function? if cannot then why?
hope can get the advice.
thanks
using function *********
function-pool vehicle.
data speed type i value 0.
function accelerate.
speed = speed + 1.
endfunction.
function show_speed.
write speed.
endfunction.
report xx.
start-of-selection.
*vehicle 1
call function 'accelerate'.
call function 'accelerate'.
call function 'show_speed'.
*vehicle 2
*vehicle 3
*****abap object*******
report xx.
data: ov type ref to vehicle,
ov_tab type table of ref to vehicle.
start-of-selection.
do 5 times.
create object ov.
append ov to ov_tab.
enddo.
loop at ov_tab into ov.
do sy-tabix times.
call method ov->accelerate.
enddo.
call method ov->show_speed.
endloop.Hi
Now try this:
REPORT ZTEST_VEHICLEOO .
PARAMETERS: P_CAR TYPE I,
P_READ TYPE I.
* CLASS vehicle DEFINITION
CLASS VEHICLE DEFINITION.
PUBLIC SECTION.
CLASS-DATA: MAX_SPEED TYPE I,
MAX_VEHICLE TYPE I,
NR_VEHICLES TYPE I.
CLASS-METHODS CLASS_CONSTRUCTOR.
METHODS CONSTRUCTOR.
METHODS ACCELERATE.
METHODS SHOW_SPEED.
METHODS GET_SPEED EXPORTING E_SPEED TYPE I.
PRIVATE SECTION.
DATA: SPEED TYPE I,
NR_VEHICLE TYPE I..
ENDCLASS.
* CLASS vehicle IMPLEMENTATION
CLASS VEHICLE IMPLEMENTATION.
METHOD CLASS_CONSTRUCTOR.
NR_VEHICLES = 0.
ENDMETHOD.
METHOD CONSTRUCTOR.
NR_VEHICLES = NR_VEHICLES + 1.
NR_VEHICLE = NR_VEHICLES.
ENDMETHOD.
METHOD ACCELERATE.
SPEED = SPEED + 1.
IF MAX_SPEED < SPEED.
MAX_SPEED = SPEED.
MAX_VEHICLE = NR_VEHICLE.
ENDIF.
ENDMETHOD.
METHOD SHOW_SPEED.
WRITE: / 'Speed of vehicle nr.', NR_VEHICLE, ':', SPEED.
ENDMETHOD.
METHOD GET_SPEED.
E_SPEED = SPEED.
ENDMETHOD.
ENDCLASS.
DATA: OV TYPE REF TO VEHICLE,
OV_TAB TYPE TABLE OF REF TO VEHICLE.
DATA: V_TIMES TYPE I,
FL_ACTION.
DATA: V_SPEED TYPE I.
START-OF-SELECTION.
DO P_CAR TIMES.
CREATE OBJECT OV.
APPEND OV TO OV_TAB.
ENDDO.
LOOP AT OV_TAB INTO OV.
IF FL_ACTION = SPACE.
FL_ACTION = 'X'.
V_TIMES = SY-TABIX * 2.
ELSE.
FL_ACTION = SPACE.
V_TIMES = SY-TABIX - 2.
ENDIF.
DO V_TIMES TIMES.
CALL METHOD OV->ACCELERATE.
ENDDO.
CALL METHOD OV->SHOW_SPEED.
ENDLOOP.
SKIP.
WRITE: / 'Higher speed', VEHICLE=>MAX_SPEED, 'for vehicle nr.',
VEHICLE=>MAX_VEHICLE.
SKIP.
READ TABLE OV_TAB INTO OV INDEX P_READ.
IF SY-SUBRC <> 0.
WRITE: 'No vehicle', P_READ.
ELSE.
CALL METHOD OV->GET_SPEED IMPORTING E_SPEED = V_SPEED.
WRITE: 'Speed of vehicle', P_READ, V_SPEED.
ENDIF.
Try to repeat this using a function group and I think you'll undestand because it'll be very hard to do it.
By only one function group how can u read the data of a certain vehicle?
Yes you can create in the function group an internal table where u store the data of every car: in this way u use the internal table like it was an instance, but you should consider here the example is very simple. Here we have only the speed as characteristic, but really we can have many complex characteristics.
Max -
How to use two activex class objects in same vi
HI
I am using labview to read ECU data from INCA software .INCA providing COMTOOL API(incacom.dll). I am using ACTIVEX for communication between INCA & Labview. My problem is If I have used single activex class object I am able to read Inca version, getting the database path etc. If I have used two activex class in same vi (one to open Inca & other one is to read the folder structure) I am not getting output.I have attached snapshot for referance
Attachments:
activex1.JPG 114 KB
activex2.JPG 107 KBIt wasnt in the first two images you posted, or I couldnt see it anyway! That was the only reason.
Did you try the database block on its own, just to confirm that it is working?
Beginner? Try LabVIEW Basics
Sharing bits of code? Try Snippets or LAVA Code Capture Tool
Have you tried Quick Drop?, Visit QD Community.
Maybe you are looking for
-
How to adjust background format for photos from my albums iOs7
With previous IOs version , when using photos from my albums to make background image , format would have fit itself . But with iOs7 , it stays at the photo's original format and doesn't adjust to screen size .
-
TOBJ entries missing from upgrade dev and test systems
Hi, We are in the process of ECC Upgrade from 4.7 to ECC 6.0 and upgraded our dev and test systems. We missing some SAP defined object entries in TOBJ table from dev and test. Because of this some of the roles getting transport errors if the roles co
-
Good Day All. We want to uninstall Microsoft Endpoint protection from our SCCM clients, now i need the uninstall string for that, but in the Reg you only see the SCCM client uninstall string and not the Endpoint protection, how to i go about to get t
-
Wipe data but keep osx 10.7.5
im selling my imac but the new buyer wants to keep operating system on it and i want to wipe my personal data? thanks
-
I'm working whit Oracle 10g Application Server (comes with JDeveloper). I'm using EJB CMP and when I try deploy my application, I get the following error: 04/08/24 16:19:48 Encountered "IN ( s . servicioPseudonimo )" at line 2, column7. Was expecting