Creating event dispatching in custom class

I have been trying to create an event dispatcher in a custom
data transfer object class. It's a simple class and I don't know
how to make it dispatch an event. I tried extending the
EventDispatcher class but that doesn't appear to work either. Any
help would be greatly appreciated.

I have attached the code for the application and the custom
class. This should work from what I have read, but I can not get
the application to catch the event.
APPLICATION
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
creationComplete="initThis()" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var _tester:TestClass = new TestClass();
private function initThis():void{
addEventListener(TestClass.TEST_ACTION, onTestHandler);
private function onTestHandler(event:Event):void{
Alert.show("Event Dispatched");
]]>
</mx:Script>
<mx:Button x="312" y="150" label="Button"
click="{_tester.testEvents()}"/>
</mx:Application>
CLASS
package
import flash.events.EventDispatcher;
import flash.events.Event;
public class TestClass extends EventDispatcher
public static const TEST_ACTION:String = "test";
public function testEvents():void{
dispatchEvent(new Event(TestClass.TEST_ACTION));
}

Similar Messages

  • Event Dispatch Problem With Classes

    I have a custom Timer class that pops up an inactivity alert
    after 3 minutes. The user can then choose 'yes' if they are still
    editing a record or 'no' if they are done. If they do not respond
    within 2 minutes of the alert it assumes 'no'.
    A 'yes' refreshes the timer and closes the alert.
    A 'no' kicks them out of the edit state in the component that
    the timer is called from.
    The logic of the timer is working fine but it doesn't seem to
    be sending the event to the component that called it so clicking
    'no' (or remaining inactive) does nothing. I feel like I'm missing
    something really simple or just misunderstanding the
    eventDispatcher function. Advice please??
    Code From LockTimer class:
    public class LockTimer extends Sprite
    private var threeMinuteTimer:Timer;
    private var twoMinuteTimer:Timer;
    public function LockTimer()
    // creates a new threeMinute Timer
    threeMinuteTimer = new Timer(1000, 180);
    twoMinuteTimer = new Timer(1000, 120);
    // designates listeners for the interval and completion
    events
    threeMinuteTimer.addEventListener(TimerEvent.TIMER, onTick);
    threeMinuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
    onTimerComplete);
    twoMinuteTimer.addEventListener(TimerEvent.TIMER, onTick);
    twoMinuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
    onTimerCompleteB);
    // starts the timer ticking
    threeMinuteTimer.start();
    public function refresh():void{
    restart(threeMinuteTimer);
    twoMinuteTimer.reset();
    private function onTick(evt:TimerEvent):void{}
    private function onTimerComplete(evt:TimerEvent):void{
    //trace("first timer");
    Alert.show('You have been inactive for several minutes. Are
    you still editing this record?', 'Inactivity Alert',
    Alert.YES|Alert.NO, null, alertListener,null, Alert.YES);
    twoMinuteTimer.start();
    private function onTimerCompleteB(evt:TimerEvent):void{
    //trace('second timer');
    //Alert.show('TIME UP', 'Inactivity Alert', Alert.OK);
    dispatchEvent(new Event("timeUp",true));
    private function restart(tim:Timer):void{
    tim.reset();
    tim.start();
    private function alertListener(eventObj:CloseEvent):void{
    // Check to see if the YES button was pressed.
    if (eventObj.detail==Alert.YES) {
    refresh();
    }else{
    //exit edit mode
    //Alert.show('TIME UP', 'Inactivity Alert', Alert.OK);
    dispatchEvent(new Event("timeUp",true));
    Code From Component:
    private var theTimer:LockTimer;
    private function initializeHandler(event:Event):void{
    addEventListener("timeUp",timeUpHandler);
    private function timeUpHandler(event:Event):void{
    Alert.show('TIME UP', 'Inactivity Alert', Alert.OK);
    //editDone();
    }

    so here is what i had to do to make this work:
    1. I had to attach the listener to theTimer rather than the
    component
    2. I had to initiate the LockTimer constructor outside of the
    function
    3. I had to call the handler initialization function from the
    component MXML
    below is the revised code (with excess cut out)
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HDividedBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="780" height="515" liveDragging="true"
    creationComplete="initializeHandler()">
    <mx:Script>
    <![CDATA[
    import mx.controls.Text;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.controls.Alert;
    import classes.LockTimer;
    public static const millisecondsPerMinute:int = 1000 * 60;
    public static const millisecondsPerHour:int = 1000 * 60 *
    60;
    public static const millisecondsPerDay:int = 1000 * 60 * 60
    * 24;
    //IMPORTANT!!!////////////////
    private var theTimer:LockTimer=new LockTimer();
    private function initializeHandler():void{
    theTimer.addEventListener("timeUp",timeUpHandler);
    private function timeUpHandler(event:Event):void{
    editDone();
    private function refreshLock(theLock:int):void{
    var theTime:Date=new Date();
    if(theLock==1){
    theTimer.refresh();
    theTime.setTime(theTime.getTime() +
    (millisecondsPerMinute*5));
    }else if(theLock==0){
    theTime.setTime(theTime.getTime());
    }else{
    return;
    form1.request.firmlockedTime=String(theTime.valueOf());
    form1.request.firmisLocked=String(theLock);
    private function editIt():void{
    //see if it's being edited
    if(checkLock()){
    //if its being edited send a message
    Alert.show('This record is currently being edited by another
    user. Please try again later.', 'Record Locked',
    mx.controls.Alert.OK);
    }else{
    theTimer.startMe();
    refreshLock(1);
    form1.send();
    currentState="AdminEdit";
    private function editDone():void{
    refreshLock(0);
    form1.send();
    currentState="Admin";
    ]]>
    </mx:Script>
    </mx:HDividedBox>

  • Listening to event within custom class

    I've created a custom class that posts to a web page to authorize a user. How can I listen for an event within the custom class?
    This is my code within my main class.
    var customClass:CustomClass = new CustomClass();
    var testingString = customClass.authorize("[email protected]", "password");
    the fuction "authorize" within the customClass looks like this:
    public function authorize(user:String, password:String):void
      jSession = new URLVariables();
                                  j_Loader = new URLLoader();
                                  jSession.j_username = user;
                                  jSession.j_password = password;
                                  jSend.method = URLRequestMethod.POST;
                                  jSend.data = jSession
                                  j_Loader.load(jSend)
    How can I fire an event within my main class once the j_Loader triggers Event.COMPLETE?

    You can fire an event using the dispatchEvent() function.
    In your main class you assign a listener for the event the CustomClass dispatches after it exists.

  • Sdbmail event dispatcher

    Hello,,
    I try create event dispatcher
    Execution of program "sdbmail "<subject>Test</subject> <body>The database name is $DBNAME$</body> <recipient>monaAexample.com</recipient>"" not allowed
    Execution of program "sdbmail "<subject>Test</subject> <body>The database name is $DBNAME$</body> <recipient>monaAexample.com</recipient>"" not allowed
    A=@
    I don't find sdbmail
    my instalation MAXDB 7.8.02.21
    What I do wrong.
    thanks
    Edited by: Maros Beno on Sep 22, 2011 9:47 AM

    1, see parameter rundirectory
    C:\data\sdb\globaldata\wrk\MAXDB2
    2, cd C:\data\sdb\globaldata\wrk\MAXDB2
    create file  dbm_whitelist.cfg
    3, enter into file dbm_whitelist.cfg
    dbm_configset SDBED_SMTPSENDERAD yourmail
    dbm_configset SDBED_SMTPSERVERS SMTPserverName
    4, change owner file dbm_whitelist.cfg to SDB Operators
    and now I have new message
    Command 'event_dispatcher' has ended and failed with return code -24617.
                              4088 ERR     -24617 DBMSrv   ERR_WHITELIST_PERM: Security attributes of whitelist (C:\data\sdb\globaldata\wrk\MAXDB2\dbm_whitelist.cfg) not okay
    What is wrong now?

  • How to create a ActiveX Object with custom classes

    Hi
    I am trying to create a Active X object for some of the work I have done in Java to be used with VB, but I cannot get the Active X object to generate and it always come up with the following error:
    Exception occurred during event dispatching:
    java.lang.NoClassDefFoundError: uk/co/agena/minerva/model/Model
    at java.lang.Class.getMethods0(Native Method)
    at java.lang.Class.getDeclaredMethods(Unknown Source)
    at java.beans.Introspector$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source)
    at java.beans.Introspector.getTargetEventInfo(Unknown Source)
    at java.beans.Introspector.getBeanInfo(Unknown Source)
    at java.beans.Introspector.getBeanInfo(Unknown Source)
    at sun.beanbox.JarInfo.<init>(Unknown Source)
    at sun.beanbox.JarLoader.createJarInfo(Unknown Source)
    at sun.beanbox.JarLoader.loadJar(Unknown Source)
    at sun.beans.ole.Packager.loadBean(Unknown Source)
    at sun.beans.ole.Packager.generate(Unknown Source)
    at sun.beans.ole.Packager.actionPerformed(Unknown Source)
    at java.awt.Button.processActionEvent(Unknown Source)
    at java.awt.Button.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForComponent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForComponent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    This appears to be beacuse the class uk/co/agena/minerva/model/Model is a custom class which is based on the software I am using. Does anyone know how I can get around this issue. I have tried incluijng those class files for the custom classes within the jar file, but I continue to get the same issue?
    Any help would be gratefully received.
    Thanks
    Angie

    This error is no longer coming up, it is now saying that it has an unsupported class version error. I believe this may be because the class file and library files have been complied under different versions, is there a method to check this?

  • Putting Loader in a custom class: events, returning to main ... asynch challenges

    I'm creating a custom class to retrieve some data using URLoader.
    My code is below, doing this from memory, plz ignore any minor typos.
    The challenge I'm encountering: when my custom class calls the loader, the event handler takes over.  At which point the context of my code leaves the function and it's not clear to me how I then return the data retrieved by the loader.  I sense that I'm breaking the rules of how ActionScript really runs by putting a loader in a separate class; at least, that's my primitive understanding based upon the reading I've done on this.
    So can I do this?  I am trying to create a clean separation of concerns in my program so that my main program doesn't get clogged up with code concerned with retrieving remote data.
    Thanks!
    Main program;
    import bethesda.myLoader;
    var ldr:myLoader = new myLoader;
    var data:String = myLoader.getData("someurl");
    My custom class:
    package bethesda {
         public class myLoader {
              function myLoader(url:String):String {
                   var loader:URLLoader = new URLLoader();
                   var request:URLRequest = new URLRequest(url);
                   loader.addEventListener(Event.COMPLETE, completeHandler);
         function completeHandler(event:Event):void {
              var ld:URLLoader = new URLLoader(event.target);
              data = loader.load(); // here's where I don't know what to do to get the data back to my main program

    I think you are on the right track in abstracting loading from other code.
    Your class may be like that:
    package 
         import flash.events.Event;
         import flash.events.EventDispatcher;
         import flash.net.URLLoader;
         import flash.net.URLRequest;
         public class myLoader extends EventDispatcher
              // declare varaibles in the header
              private var loader:URLLoader;
              private var url:String;
              public function myLoader(url:String)
                  this.url = url;
              public function load():void {
                  var loader:URLLoader = new URLLoader();
                  var request:URLRequest = new URLRequest(url);
                  loader.addEventListener(Event.COMPLETE, completeHandler);
                  loader.load(request);
              private function completeHandler(e:Event):void
                  dispatchEvent(new Event(Event.COMPLETE));
              public function get data():*{
                  return loader.data;
    Although, perhaps the best thing to do would be to make this class extend URLLoader. With the example above you can use the class as following:
    import bethesda.myLoader;
    import flash.events.Event;
    var ldr:myLoader = new myLoader("someurl");
    ldr.addEventListener(Event.COMPLETE, onLoadComplete);
    ldr.load();
    function onLoadComplete(e:Event):void {
         var data:String = ldr.data;

  • Eventhandlers of children of application can not receive custom event dispatched by application

    Hello dear Adobe community,
    hope you can help me with this issue.
    When the application dispatches a custom event, the child uicomponent can only receive the event by using Application.application.addEventListener or systemManager.addEventListener. Simply adding a listener, without application or systemmanager, does not allow the event to be received by the child component.
    I want to be able to use the addEventListener and removeEventListener without SystemManager or Application.application, or could you provide a better workaround? How can I use the addEventListener, do I need to overwrite EventDispatcher, which I wouldnt like to do?
    Just to clarifiy, if i remove the systemManager in front of addEventListener(CustomEventOne.EventOne,sysManHandleCE,false) it will not add it and will not fire. 
    The code below is an example for this problem that the event is not getting fired in the right moment. The mainapplication got only a button with the customEventOne that gets dispatched.
    public
    class MyCanvas extends Canvas{
    public function MyCanvas()
    super();
    width=300;
    height=300;
    addEventListener(FlexEvent.CREATION_COMPLETE,handleCC,false,0,true);
    private function handleCC(event:FlexEvent):void
    removeEventListener(FlexEvent.CREATION_COMPLETE,handleCC);
    addEventListener(CustomEventOne.EventOne,handleCE,false,0,true);
    addEventListener(Event.REMOVED_FROM_STAGE,handleEvt,false,0,true);
    systemManager.addeventListener(CustomEventOne.eventOne,sysManHandleCE,false,0,true);
    private function handleEvt(event:Event):void
    trace("In removed from stage handler");
    systemManager.removeEventListener(CustomEventOne.EventOne,sysManHandleCE);
    trace(hasEventListener(FlexEvent.CREATION_COMPLETE));
    trace(hasEventListener(CustomEventOne.EventOne));
    trace(hasEventListener(Event.REMOVED_FROM_STAGE));
    private function handleCE(event:CustomEventOne):void
    trace("I got it");
    private function sysManHandleCE(event:CustomEventOne):void
    trace("I got it");
    public class CustomEventOne extends Event
    public static const EventOne:String = "EventOne";
    public function CustomEventOne(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
    super(type, bubbles, cancelable);
    override public functionclone():Event
    return newCustomEventOne(type,bubbles,cancelable);
    Thank you in advance,
    Michael

    I think you need to look at event propogation. The object that dispatches an event will be sitting on the display tree. The event propagates up the tree to the roots. Your canvas should be attached to the application, but even then it sits lower in the tree branches than the event dispatcher, so it won't see the event being dispatched because the event is not propagated to the children of the object that dispatches it but to the parent of the object that dispatches it.
    So, your canvas is a child of the application, but dispatching the event from the application means that the canvas doesn't see it because events are notified up the tree using the parent link, not the child links.
    You may wish to investigate how the display list and event propagation works and then the MVC pattern.
    Paul

  • Event-dispatching create'n'showGUI useful for applets?

    I want to create and show the GUI in my applet's init method. Do I still need to wrap my code like this:
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    // create and show gui code
    (The applet is extends the JApplet class.)

    Yes. It is not guaranteed that it is the event dispatch thread that invokes init().
    http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html#thread

  • Trying to make up a Modal Dialog with customized event dispatcher

    Hello everyone.
    I try to make up a ModalDialog class with customized event dispatcher in order to wait an invoker.
    But it fails :-(
    import javafx.event.ActionEvent;
    import javafx.event.Event;
    import javafx.event.EventDispatchChain;
    import javafx.event.EventHandler;
    import javafx.event.EventTarget;
    import javafx.event.EventType;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    import javafx.stage.Window;
    import javafx.stage.WindowEvent;
    import com.sun.javafx.stage.WindowEventDispatcher;
    import java.util.ArrayList;
    public class ModalDialog extends Stage {
      ArrayList<Button> buttons;
      int rc;
      Stage stage;
      Event event;
      EventDispatchChain tail;
      public ModalDialog( Window owner, String title ){
        initModality( Modality.APPLICATION_MODAL );
        initOwner( owner );
        initStyle( StageStyle.UTILITY );
        setTitle( title );
        stage = this;
      public void setContents( Group group, ArrayList<Button> buttons ){
        BorderPane root = new BorderPane();
        Scene scene = new Scene(root);
        setScene(scene);
        root.setCenter( group );
        this.buttons = buttons;
        HBox buttonPane = new HBox();
        buttonPane.setSpacing(10);
        for( int i=0 ; i<buttons.size() ; i++ ){
          buttons.get(i).setOnAction( actionHandler );
        buttonPane.getChildren().setAll( buttons );
        root.setBottom( buttonPane );
      public int show( double screenX, double screenY ){
        setX( screenX ); setY( screenY );
        show();
        MyWindowEventDispatcher dispatcher =  new MyWindowEventDispatcher( stage );
        setEventDispatcher( dispatcher );
        while(true){
          event = dispatcher.dispatchEvent( event, tail );
          EventType<? extends Event> type = event.getEventType();
          if( type==WindowEvent.WINDOW_HIDDEN ){
            break;
        return( rc );
      EventHandler<ActionEvent> actionHandler = new EventHandler<ActionEvent>() {
        public void handle( ActionEvent e ){
          EventTarget src = e.getTarget();
          rc = buttons.indexOf( src );
          stage.hide();
      class MyWindowEventDispatcher extends WindowEventDispatcher {
        public MyWindowEventDispatcher( Window window ){
          super( window );
        public Event dispatchEvent( Event event, EventDispatchChain tail) {
          ModalDialog.this.event = dispatchCapturingEvent( event );
          ModalDialog.this.tail = tail;
          return( event );
    }A sample code to invoke ModalDialog
    import java.util.ArrayList;
    import javax.swing.JOptionPane;
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.stage.Stage;
    import javafx.stage.WindowEvent;
    public class WindowEvent06 extends Application {
      Stage mainStage;
      public void start(Stage stage) throws Exception {
        Group root = new Group();
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("WindowEvent06");
        mainStage = stage;
        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
          public void handle(WindowEvent e){
            ModalDialog dialog = new ModalDialog( mainStage, "Question" );
            Button yes = new Button( "Yes" );
            Button no  = new Button( "No" );
            ArrayList<Button> buttons = new ArrayList<>();
            buttons.add(yes); buttons.add(no);
            Label msg = new Label( "Really Exit ?" );
            Group groupInDialog = new Group();
            groupInDialog.getChildren().add( msg );
            dialog.setContents( groupInDialog, buttons );
            int ans = dialog.show( 300, 300 );
            System.out.println("returned from a modal dialog");
            if( ans == 1 ){
              e.consume(); // this blocks window closing
        stage.show();
      public static void main(String[] args) {
        launch(args);
    }

    Hi,
    The logic what you follows is some what in the right direction but need to have some changes.
    What I would say is, first consume the windowClose event. Then open the dialog box and close the parent accordingly.
    So after refactoring your code.
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    public class ModalDialog extends Stage {
         Stage owner;
         Stage stage;
         BorderPane root;
      public ModalDialog( Stage owner, String title){
        root = new BorderPane();
        stage = this;
        this.owner = owner;
        initModality( Modality.APPLICATION_MODAL );
        initOwner( owner );
        initStyle( StageStyle.UTILITY );
        setTitle( title );
        setContents();
      public void setContents(){
        Scene scene = new Scene(root,150,150);
        setScene(scene);
        Group groupInDialog = new Group();
        groupInDialog.getChildren().add( new Label("Really Exit ?") );
        root.setCenter( groupInDialog );
        Button yes = new Button( "Yes" );
        yes.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent paramT) {
                   stage.close(); // Closing the pop up.
                   owner.close(); // Closing the parent stage also.
        Button no  = new Button( "No" );
        no.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent paramT) {
                   stage.close(); // Closing the pop up only
        HBox buttonPane = new HBox();
        buttonPane.setSpacing(10);
        buttonPane.getChildren().addAll(yes,no);
        root.setBottom(buttonPane);
        stage.show();
    }And the main class to check this implementation is
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    import javafx.stage.WindowEvent;
    public class WindowEvent06 extends Application {
      public void start(final Stage stage) throws Exception {
        Group root = new Group();
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("WindowEvent06");
        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
          public void handle(final WindowEvent e){
             e.consume(); // Consuming the event by default.
             new ModalDialog( stage, "Question");
        stage.show();
      public static void main(String[] args) {
        launch(args);
    }I hope the above code will give you some idea what i mean. :)
    Happy Coding !!
    Regards,
    Sai Pradeep Dandem.
    Edited by: Sai Pradeep Dandem on Jan 20, 2012 4:03 AM

  • Build app with ODT and Oracle UDT - Error while creating custom class

    Hello CShay,
    I am testing you sample code to create UDT with ASP.Net app. It is also published in Oracle magazine.
    The article is also published at following link:
    http://www.oracle.com/technology/oramag/oracle/08-may/o38net.html
    I am able to successfully implement all the steps before "Using Custom Class Wizard". When I right click on any of the object (CUSTOMER_OBJ, PHONELIST_OBJ, and ADDRESS_OBJ) and select Generate Custom Class, I get the following error:
    Oracle custom class wizard.
    Class can be generated only for either C#, VB or Managed C++ projects.
    Am I missing any thing?
    Thanks in advance for your help.

    Yes I confirm that I choose File->New Website.
    I don't see the following option
    File -> New Project, and then under Visual C#, select ASP.NET Web Application
    I am using VS2005 Professional Edition.
    The options I see under Visual C# are:
    If I click on
    Windows tab:
    Windows Application
    Windows Control Library
    Console Application
    Empty Project
    Class Library
    Web Control Library
    Window Servcie
    Crystal Report Application
    and Search Online Templates in My Templates tab.
    Couple of options for Smart Device which also doesn't include ASP.Net
    then Database, Starter kits and Office tabs which also doesn't include ASP.net thing.
    I don't know how did you see that option or you might be using different version of VS (Enterprise).
    But right now I am stuck.
    Please provide me your valuable comments.
    Thanks for your help.

  • How to access MC's textfield created in a custom class?

    I have a custom class which creates a new MC using a library MC. The  library MC contains a dynamic textfield called productName.
    The custom class object gets created fine and is displaying on the  stage. It's also holding custom properties I set as well.
    How do I control the dynamic textfield inside the MC, which is inside  the custom class object?
    My Product.as:
    package {
         import flash.display.MovieClip;
         public class Product extends MovieClip {
             public var prodName:String;
             public var prodCategory:String;
             public var prodQuality:String;
             public function Product():void {
                 var productMC:MovieClip = new cellMC();
                 addChild(productMC);
    My .FLA first frame:
    var myProd1:Product = new Product();
    myProd1.prodCategory = "Heaters";
    myProd1.x = 150;
    myProd1.y = 140;
    addChild(myProd1);
    // THE FOLLOWING DOES NOT WORK
    myProd1.productMC.productName.text = "ABC 123";
    I figure something like this would work, but with lots of variations, still nothing works
    I get errors telling me it can't find productMC.
    UPDATE:
    Using GetByChildName it seems I can access productMC. For example this works:
    myProd1.getChildByName("productMC").visible = false;
    But this does not work:
    myProd1.getChildByName("productMC").getChildByName("productName").text = "dgdhdhdhrgh";
    If I take the textfield out of the library MC, and create it in the class, then this works:
    myProd1.getChildByName("productName").visible = false;
    BUT this does not work:
    myProd1.getChildByName("productName").text = "sdgsgdfsg";

    Hi Otto,
    If I well understood your situation, the solution  might be quite simple.
    Since your Product class is a  MovieClip (and not a Sprite), you could solve your problem many ways  knowing that a MovieClip is a dynamic class.
    But first,  the thing is that you created your productMC object on the fly inside  your Product class.
    So either you correct it like this:
    package {
         import  flash.display.MovieClip;
         public class  Product extends MovieClip {
             public var  prodName:String;
             public var prodCategory:String;
              public var prodQuality:String;
             public var productMC:MovieClip; // *****
             public function  Product():void {
                 productMC = new  cellMC(); // *********
                 addChild(productMC);
    Or use this cheap trick (a MovieClip is a dynamic class):
    package {
         import  flash.display.MovieClip;
         public class  Product extends MovieClip {
             public var  prodName:String;
             public var prodCategory:String;
              public var prodQuality:String;
             public function  Product():void {
                 var productMC:MovieClip = new  cellMC();
                 this.productMC = productMC; // **************
                 addChild(productMC);
    Although it is possible that, for this one, you need to reforce the dynamic property:
    package {
         import  flash.display.MovieClip;
         dynamic public class  Product extends MovieClip {
    I am not sure, but anyway, you will see for yourself.
    Plus, you try to change text to a MovieClip object? Either there is already a TextField in you cellMC object and you are not targeting it, or productMC should be instanciated as a TextField and not a MovieClip. I think you know the answer to that.
    Design Cyboïde
    Designer web Montreal

  • Creating custom classes from a more complex DTD

    Are there any examples of creating more complex custom document types? The sample in the dev. guide and the xml syntax are a good start but not enough.
    If anyone has an example from their own work, I'd appreciate it. You can send them to [email protected]
    Thanks!

    I'm having trouble gaining access to the content of those objects within a multilevel tree structure once the XML file has been loaded into the database. Those attributes off root via an editing tool or jsp/bean are rendered; however, the branched object structures are not. Instead the following is in its place: <MYClASSOBJECT2 RefType="ID">7265<!--ClassObject: MYClASSOBJECT2--><!--Name:Null--></MYClASSOBJECT2>
    Here is some background. All custom classes have been successfully loaded into iFS, including the branching objects, which have been entered as extensions of Document as well as the associated ClassDomain entries. I've read Mark's PencilObject entry of June 23, but I continue to get undesired results. Currently, I am using SimpleXMLRender and am inclined to believe that I will need to customize the renderer for it to recognize the deep structures within my XML. Can you shed any light on my situation? In a nutshell, how do I gain access to the content within my multilevel XML?

  • Create Events in Global Class

    Hi,
    I used this link for create Events in Global Class through SE24.....
    [http://sapabapnotes.blogspot.com/]
    I do same steps as given in this link....but it show some syntax error when i check it...
    Error : "IT_LFA1" is not an internal table - the "OCCURS n" specification is missing...
    Where i define it...
    Plz tell me wat can i do...
    Thanks...
    Edited by: Prince Kumar on Jan 25, 2008 12:25 PM
    Edited by: Prince Kumar on Jan 25, 2008 12:46 PM

    Hi,
    Thanks for reply....
    I create a table type with structure LFA1....
    Plz tell me that in the interface tab....wat i write....
    Plz clear...
    thanks....

  • Creating thread (service)? in storage nodes using my custom classes?

    Is it possible to create one's own thread in a storage node - say, by defining a service with a custom class?
    The service configuration element states
    +"<service-component>      Required      Specifies either the fully qualified class name of the service or the relocatable component name relative to the base Service component. "+
    I have tried specifying my own class (fully qualified class name) here, which is in the classpath and implements com.tangosol.net.InvocationService but it is never loaded, and throws the following exception into my app when it calls CacheFactory.getService(name):
    Exception in thread "main" java.lang.IllegalArgumentException: Unknown service type: Invocation
    at com.tangosol.coherence.component.net.Cluster.ensureService(Cluster.CDB:65)
    at com.tangosol.coherence.component.util.SafeCluster.ensureSafeService(SafeCluster.CDB:14)
    at com.tangosol.coherence.component.util.SafeCluster.ensureService(SafeCluster.CDB:11)
    at com.tangosol.net.DefaultConfigurableCacheFactory.ensureService(DefaultConfigurableCacheFactory.java:808)
    at com.tangosol.net.DefaultConfigurableCacheFactory.ensureService(DefaultConfigurableCacheFactory.java:294)
    at com.tangosol.net.CacheFactory.getService(CacheFactory.java:644)
    Is this the wrong way to do it? Is there another way (other than something ugly like creating a thread in an invocable)?
    Thanks

    Hi
    Can you explain what you are trying to accomplish in more detail? Are you trying to run a background thread on the member that owns the data?
    In any case your really shouldn't be adding new service types or service components in the cluster configuration file. See this thread Re: <service-name> tag in config XML file
    thanks
    Paul

  • Creating custom class instances for XML nodes

    Hi guys,
    I'm trying to load an external XML document in my application
    and create an instance of a custom class for each node in the XML
    based on the value of some of their elements. The instances created
    will eventually end up in a DataGrid by the way. The problem I'm
    having is there seems to be many ways of doing small parts of this
    and I have no idea how to make them all gel. Initially I'm using
    HTTPService to load the XML file but I've seen people just use an
    XML object. Then, after that, I initially set the loaded XML to an
    ArrayCollection but others have used XMLList or XMLListCollection.
    I've no idea what's the best way to do this.
    Eventually, when I've created all of these instances by
    looping over the XML and creating them how will I make them
    bindable to the data grid? I'm guessing I'll have to group them
    somehow...
    Any help would be greatly appreciated. Thanks

    Hey Tracy,
    That is exactly what I was talking about in a previous post
    you replied to
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1344350
    Anyhow, Below is some code I created to do what your saying
    somewhat dynamically. The idea being you can have many different
    object types that you may want to populate with data from XML. In
    my case I am using e4x as the result type from my web services. At
    present I have about 6 different classes that call this function.
    I'd love to get some opinions on the function. Good bad or
    ???? Any improvements etc????
    package . . . .
    import flash.utils.describeType;
    import flash.utils.getDefinitionByName;
    import flash.utils.getQualifiedClassName;
    import mx.utils.ObjectUtil;
    * Utility class to convert xml based Objects to class
    instances.
    * Takes a value object as the destination and an xmlList of
    data
    * Look through all the items in the value object. Note we
    are using classInfo..accessor since
    * our objects are bound all variables become getter /
    setter's or accessors.
    * Also note, we can handle custom objects, arrays and
    arrayCollections.
    * History
    * 03.11.2008 - Steven Rieger : Created class
    public final class XMLToInstance
    public static function xmlToInstance( destinationObject :
    Object, sourceXMLList : XMLList ) : void
    // Get the class definition in XML, from the passed in
    object ( introspection so to speak )
    var classInfo : XML = describeType( destinationObject );
    // Loop through each variable defined in the class.
    for each ( var aVar : XML in classInfo..accessor )
    // If this is String, Number, etc. . . Just copy the data
    into the destination object.
    if( isSimple( aVar.@type ) )
    destinationObject[aVar.@name] = sourceXMLList[aVar.@name];
    else
    // Dynamically create a class of the appropriate type
    var className : String = aVar.@type;
    var ObjectClass : Class = getDefinitionByName( className )
    as Class;
    var newDestObject : Object = Object( new ObjectClass());
    // If this is a custom type
    if( isCustomType( className ) && ObjectClass != null
    // Recursively call itself passing in the custom data type
    and the data to store in it.
    // I haven't tested nested objects more than one level. I
    suppose it should work.
    // Note to self. Check.
    xmlToInstance( newDestObject, sourceXMLList[aVar.@name] );
    else
    // Must be some sort of Array, Array Collection . . .
    if( ObjectClass != null )
    var anXMLList : XMLList = new XMLList(
    sourceXMLList[aVar.@name] );
    for each( var anItem : XML in anXMLList )
    // I'm sure there are more types, just not using any of them
    yet.
    if( newDestObject is Array )
    newDestObject.push( anItem )
    else
    newDestObject.addItem( anItem );
    // Add the data to the destination object. . . .
    destinationObject[aVar.@name] = newDestObject;
    } // end function objectToInstance
    public static function isSimple( dataType : String ) :
    Boolean
    * This function is pretty self explanatory.
    * Check to see if this is a simple data type. Did I miss
    any?
    * History
    * 03.11.2008 - Steven Rieger : Created function
    switch( dataType.toLowerCase() )
    case "number":
    case "string":
    case "boolean":
    return true;
    return false;
    } // end isSimple
    public static function isCustomType( className : String ) :
    Boolean
    * This function is pretty self explanatory.
    * Check to see if this is a custom data type. Add them here
    as you need. . .
    * History
    * 03.11.2008 - Steven Rieger : Created function
    var aClassName : String = className.replace( "::", "."
    ).toLowerCase();
    aClassName = aClassName.substr( aClassName.lastIndexOf( "."
    ) + 1, aClassName.length - aClassName.lastIndexOf( "." ) );
    switch( aClassName )
    case "ndatetimevo":
    case "expenselineitemvo":
    return true;
    return false;
    } // end isCustomType
    } // end class
    } // end package

Maybe you are looking for