Custom class EventDispatcher

I send a customEvent to a class.  The class extends EventDispatcher, and I can verify that the event didn't actually get distributed.  But he isn't getting picked up by the mxml component or the main application container.  Bubbles is true.  What I'm missing here?

Only the DisplayObjects can use bubbling = when true and alone on the display list.  Bubbles is generally bad practice, with the exception of the input of the user interface events.  Define singletons that other parts of the application can talk directly.

Alex Harui

Flex SDK Developer

Adobe Systems Inc..

Blog: http://blogs.adobe.com/aharui

Tags: Flex

Similar Questions

  • EventDispatcher on custom class

    I tried to create an event dispatcher in a custom data transfer object class. This is a simple class, and I don't know how send an event. I tried that extends the EventDispatcher class, but that doesn't seem to work either. Any help would be greatly appreciated.
    I enclose the application code and the custom class. It should work from what I've read, but I can't do the application to intercept 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 void onTestHandler(event:Event):void {}
    Alert.Show ("send event");
    }
    []] >
    < / mx:Script >
    < mx:Button = "312" x y = '150' label = "Button" click = "{_tester.testEvents ()}" / >
    < / mx:Application >

    CLASS
    package
    {
    import flash.events.EventDispatcher;
    import flash.events.Event;

    SerializableAttribute public class TestClass extends EventDispatcher
    {
    public static const = "test" TEST_ACTION:String

    public function testEvents (): void {}
    dispatchEvent (new Event (TestClass.TEST_ACTION));
    }
    }
    }

    However, I found an alternative, although I still don't understand exactly. If I add the event listener directly to the class in the creationComplete apps (initThis()) as:

    _Tester.addEventListener (TestClass.TEST_ACTION, onTestHandler);

    The application intercepts the event, even if she isn't really enforcement, he is now? This is the class real, right? I'm confused about this.

  • Interpolation in custom class

    I am a newbie in flash/actionscript related. I created a towers of hanoi video clips solution using the motion tweens. It worked great all when the action script containing the creation of Tween existed on what I think is the clip of root (in my FLA file action script window).
    I tried to move the solution of hanoi in a custom class (which extends from EventDispatcher) and now the interpolation "does not. I reinforced with my code with the debugger and added a lot of tracing instructions and I'm sure that all the arguments for the Tween constructor are correct.

    _currentTween = new Tween (_movingDiskMc, "FLF", Regular.easeOut, _movingDiskMc._y, _yMin, _duration);

    Is there something fundamental, that I'm missing? Is the frequency of images, a problem with the custom class? _Duration above value is 5.

    THX

    -Kurt

    Ahhhh... after a further examination found that my "onMotionFinished" event handlers have been called, but in the debugger, the scope is the interpolation my class of Hanoi. Went wrong

    found the discussion in the help topic regarding the scope of event handlers and using things 'suggested strategy' work very well now

  • Unable to make a call to the custom class

    Hi all

    I train to call the custom since the screen as below class, but its not picking up the custom class features and gives the result, I don't know if something is not in the below class or the way I call this method.

    package com.ge.bbcalendar;

    Import net.rim.device.api.ui.Color;
    Import net.rim.device.api.ui.Graphics;
    Import net.rim.device.api.ui.component.LabelField;

    public class TestClass extends {LabelField
    Private boolean brought;
    private string text;
    style long private;

    public {TestClass (String text, long style)

    Super();
    This.Text = text;
    This.style = style;
    }

    protected void onFocus (int direction) {}
    focused = true;
    Invalidate();
    super.onFocus (branch);

    }

    protected void onUnfocus() {}
    concentrate = false;
    Invalidate();
    super.onUnfocus ();
    }

    protected void paint (Graphics graphics) {}
    graphics.setColor (Color.WHITE);
    graphics.setBackgroundColor (0x544E4F);
    If {(targeted)
    graphics.setColor (Color.BLUE);
    }
    Graphics.Clear;
    Super.Paint (Graphics);
    }
    }

    Called as of the screen

    SerializableAttribute public class NativeScreen extends form {}

    final cas15 TestClass = new TestClass("",LabelField.FOCUSABLE);
    }

    What is the problem above?

    I suspect that your problem is the LabelField don't think it has any text to display.

    You really need this, I think

    public TestLabel (String text, long style) {}
    Super (Text, FOCUSABLE);

    ...

  • Failed to instantiate new custom class object - no trace of the stack

    Hello

    I have a little maddening problem. I created a custom class called 'Notification '. When I try to create an instance of the latter, I don't get any stack trace. Here's the class:

    package net.creative.core.util;
    
    import net.rim.device.api.system.Bitmap;
    
    /**
     * These are the notification objects that are created and stored
     * when a push notification is sent.
     * @author Heather
     *
     */
    
    public class Notification {
    
        private String title;
        private String content;
        private Bitmap image = Bitmap.getBitmapResource("appicon.png");
    
        public Notification(){
            title = "Title";
            content = "Content";
        }
    
        public Notification(String _title, String _content){
            title = _title;
            content = _content;
        }
        public Notification(String _title, String _content, Bitmap _image){
            title = _title;
            content = _content;
            image = _image;
        }
        public String getTitle(){
            return title;
        }
        public String getContent(){
            return content;
        }
        public Bitmap getImage(){
            return image;
        }
        public void setTitle(String _title){
            title = _title;
        }
        public void setContent(String _content){
            content = _content;
        }
        public void setImage(Bitmap _image){
            image = _image;
        }
    
    }
    

    I don't think it's a problem, but the screen I have tried to create an instance of in the Notification is in the com.creative.core package. I imported Notification on the screen while... Any ideas?

    Never mind.. just resolved.

  • ClassCastException in the custom class loader

    I created a custom class Leon.

    CCL ClassLoaderDemo = new ClassLoaderDemo(); assume that it works very well
    CLAS class = ccl.loadClass ('com '' ' MyObject');

    com MyObjectSuperClass o1 = (com. MyObjectSuperClass) clas.newInstance ();

    Now I want to get the object responsible for MyObjectSuperClass which is super class if MyObject. But I'm getting the following exception

    Exception in thread "main" java.lang.ClassCastException: com. Com cannot be cast to MyObject. MyObjectSuperClass

    Help, please.

    821458 wrote:
    My requirement is the class MyObject needs to be loaded by my client class loader. If you say that let the superclass (MyObjectSuperClass) be in the class path and let the class system charge charger, then usually it be a problem

    No, it's exactly what you want.

    MyObject loaded by the custom class loader, its super class loaded by the system class loader, I will be able to cast then.

    Yes, you will be able to cast to the upper class, then.

    It is not similar to the statement "MyObject loaded by the class loader and custom class system are different and we cannot throw.

    No, it isn't. your confusion is due to the fact that you don't seem to understand that you can have a class hierarchy that spans the Chargers of classes. This should be obvious because each object hierarchy extends eventually object, which is always in the system class loader. Therefore, you can always convert any instance of any class loader "Object". in the same way, you can have MyObjectClass in your chargers personalized classes and MyObjectSuperClass in the system class loader. You can instantiate an instance of MyObjectClass to aid reflection on your custom class loaders and assign it to a reference of the type MyObjectSuperClass. This is how pretty much any plugin system is implemented (the API is in the 'main' class loader and the implementation is in a nested class or custom ClassLoader).

  • Listen to the event within the custom class

    I created a custom class that publishes on a webpage to authorize a user. How can I listen to an event within the custom class?

    It is my code in my main class.

    var customClass:CustomClass = new CustomClass();

    var testingString = customClass.authorize ("[email protected]", "password");

    the fuction "authorizes" within the customClass looks like this:

    public void 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 trigger an event in my main class once the j_Loader triggers Event.COMPLETE?

    You can raise an event using the dispatchEvent() function.

    In your main class, you assign a listener to the event the CustomClass distributes when there are.

  • create a listener for a custom class?

    I have a custom class that loads a couple of XMLs. I create an instance of this class in another class and I need to know when it is done so that I can then call a function of loading in this class of parent.

    How can I do this?

    pls know me if I need to explain differently.

    Thank you!

    When you create your instance of the class:

    ///////////////////////

    classinstance.addEventListener ("xmlloadingcomplete", f);

    private void f(e:Event):void {}

    //

    }

    ////////////////////

    and in your xml, class loading, loading is complete:

    this.dispatchEvent (new Event ("xmlloadingcomplete"));

  • Passing arguments to a custom class of MC constructor

    I have problems with the Builder for a custom class linked to a MovieClip library.

    I have a MovieClip in my library called circle, which is related to the com.shapes.Circle class. I want the contstructor of class circle to take 2 arguments, xScale and yScale:

    public function Circle (xScale:Number, yScale:Number) End Sub

    However, if I try to call it from code, for example ball circle = new Circle (3.14,2.0); , I always get a 'number of Incorrect arguments. Waiting 0 " error.

    Is it possible to have a custom class linked to a MovieClip that can take arguments, or Flash not allow this? I had asked about this before and thought I figured out, but look at it now, I apparently had not thought of it and has resorted to a workaround sloppy; I'm hoping to fix now.

    Library items cannot have constructor arguments, because the user can drag on the stage and in this way has no way of passing arguments. If you wat to initialize instances, define public void init() where you can add as many arguments as you want.

  • SQLite, from SQLinstructions to a custom class

    I'm working on an AIR of FB app.

    I have a file with a source main.mxml in main.as file.

    My main.as file becomes very swollen with SQLinstructions. I want to switch to a custom class, but I do not know how to proceed.

    I found an example of a package on this page: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/SQLConnectio n.html #begin)

    on a 3rd down.

    The example above, that's exactly what I want to do, but I do not know how to adapt it for use in my file main.as beyond to import the class and instantiate. How can I assign my values in the class file? How to use the class to load up the dataProvider, etc...

    In addition, in the example above, the class extends Sprite. This sounds like it is for a Flash application. I always extend Sprite in Flex 4? I made a couple of simple events, data transmission to the main application with the Flash.Events.Event, so using Sprite causes some confusion.

    In a previous post, Amy suggested using Robotlegs. I think I need to get a handle on the use of Flex before I explore other architectures. I'm just not that sophisticated.

    Thank you

    Kristin

    OK, a small example

    a new package called utilities, then a new called class class actionscript DatabaseManager

    package utilities
    {
         import flash.data.SQLConnection;
         import flash.data.SQLResult;
         import flash.data.SQLStatement;
         import flash.filesystem.File;
    
         import mx.collections.ArrayCollection;
    
         public class DatabaseManager
         {
              private var sqlConnection:SQLConnection;
              private var stm:SQLStatement;
    
              public function DatabaseManager()
              {
    
                   //connect to database
                   sqlConnection = new SQLConnection();
                   sqlConnection.open(File.applicationStorageDirectory.resolvePath("whatever"));
    
                   //create tables if not exist
                   stm = new SQLStatement();
                   stm.sqlConnection = sqlConnection;
                   stm.text = "create your table here";
                   stm.execute();
    
                   //create more tables
                   //...
              }
    
              public function getThings():ArrayCollection
              {
                   stm = new SQLStatement();
                   stm.sqlConnection = sqlConnection;
                   stm.text = "your query";
                   //...
              }
    
              public function addStuff(stuff:Object):int
              {
                   //...
              }
         }
    }
    

    then in your main file, you need to import

    import utilities.DatabaseManager;
    

    instantiate the class, it connects and creates tables

    private var myDB:DatabaseManager = new DatabaseManager();
    

    then to use it

    var listFromDatabase:ArrayCollection = myDB.getThings();
    
    insertid = myDB.addStuff(thingToAdd);
    

    hope that gives you an idea

  • Custom class extends HashMap - error: "does not settings.

    Hi all! This is my first post on the forum, and I chose this card because it seems to be the most active. I'm relatively new to Java, but I'm already deep enough into the language.

    I have a custom class that is declared as follows:

    public class DBFRecord extends HashMap {}

    Methods here, but no constructor

    }

    The idea was to get a custom class of the hash table with a method of extracting more precisely typed values. My understanding is that, because I don't get a constructor for the class, it defaults to the parent constructor, that is, of course, HashMap(). Where I ran into trouble was when I tried to fix a compiler warning that complained a "unchecked put." I read somewhere that this can be corrected by specifying the data type of the card to the instantiation. So, I tried this:

    DBFRecord < String, Object > record = new DBFRecord < String, Object > ();

    and the compiler, instead of being pleased, slapped me with an error:

    "type com.svcon.jdbf.DBFRecord does not settings.

    So, just to prove the point, I tried:

    HashMap < String, Object > record = new HashMap < String, Object > ();

    and it worked perfectly (although of course it has messed up the rest of the royally program.)

    So, my question is this: how we declare a class of the child (if that's the right word) as she accepts the same parameters as the parent?
    public class DBFRecord extends HashMap {
    
    public class DBFRecord extends HashMap {
    
  • How can I implement my custom class "ToolTip?

    I have has created a custom class that extends the ToolTip to style my ToolTips in six different "styles: background color for most."  I can do very well with the Manager of the ToolTip, but he's left heavy and hoped to simplify with a toolTip class that I can style I like.

    Any help is apprecitaed.

    Thank you.

    You can watch to see how our skin to pick up styles.

  • Question: Custom Classes vs. Custom components?

    I notice that I can do many things same using a custom class or a Custom Component.  Can anyone share their experience about the advantages and disadvantages of each?

    Thank you.

    Ultimately, a component is a class...

    C

  • To access instances of a custom class that extend box

    Hello

    Forgive me if I couldn't find an answr my question with various searches in the forum, but I'm not an expert and I can't even find the right words for the search.

    Here's the problem:

    I created a class (called LAlgExpression) which extends the class box. Instances of the class are added in a box, and I tried to access these instances using mouse events.

    Now, I can actually access my custom class instances by using the properties target and currentTarget of the events, but unfortunately they are considered as belonging to the Object class and not to the class LAlgExpression which make it impossible to use all the methods I've defined for LAlgeExpression because the compiler tell me that I am trying to use on an object a method that is not defined for the class Object. What's funny is that when running when I try 'event.target is LAlgExpression' it returns true, but I don't know how to convince the compiler . It's as if the instance that I have on the screen is an object and a LAlgExpression, but the compiler will not let me treat as LAlgExpression, but only as an object and I don't understand why.

    is there a way to force the compiler to consider LAlgExpression, something he sees as an object?

    Thank you very much in advance for your help

    var obj:LAlgExpression = event.target as LAlgExpression;

    or

    var obj:LAlgExpression = LAlgExpression (event.target);

    then call methods on obj and it should go.

    If this post answers your question or assistance, please mark it as such.

    Greg Lafrance - Flex 2 and 3 certified ACE

    www.ChikaraDev.com

    Training Flex and Support Services

  • Object generic casting/conversion of custom class

    I know that the right way to do what I want is to use the ORM and type all my objects in the database that I have, but it's a little late for this approach.

    So, I have an arrayCollection collection that is returned from ColdFusion. I have a custom class, call the MyClass. What is the best way, assuming that the properties match 1-1, to copy all the properties of the generic object in the collection arrayCollection in an instance of myClass with the same properties. I tried "MyClass" and not of chance (that would be nice. I happen to hit on a syntax to use 'foreach' so if you have an example or other suggestions, I would be happy.

    At this point, I add any parameters to the MyClass constructor if there is an object passed, it copies the properties of an instance, but who feels 'dirty' in the sense of duty hardcode this mapping:

    public var GUID:String;
    public var frameName:String;
    public var frameType:String;
    public var helpTitle:String;
    public var helpText:String;
    public var baseMovieGUID:String;
    public var notes: String;
    public var hotspots: ArrayCollection collection;
    public var JSONHotspots:String;
    public var baseMovieURL:String;

    public void MyClass(obj:Object_=_null):void {}
    If (obj! = null) {}
    GUID = obj. GUID;
    frameName = obj.frameName
    frameType = obj.frameType
    helpTitle = obj.helpTitle
    helpText = obj.helpText
    baseMovieGUID = obj.baseMovieGUID
    Notes = obj.notes
    points = hot obj.hotspots
    JSONHotspots = obj. JSONHotspots
    baseMovieURL = obj.baseMovieURL
    }
    }
    }

    Does that help? http://forums.Adobe.com/message/2928367

Maybe you are looking for

  • How to delete stuff on icloud to make more room?

    I tried to reduce the amount of things on icloud (on my iphone 5s and Macbook pro) as I keep notifications saying that my storage is full. I looked at the amount of SPAC SOUL was sating upward and the pictures were the msot so I deleted them on my ph

  • IPhone data stolen 6 obtained by thiet

    Tuesday, January 19, 2016, while driving home from work, my wife was pushed out of his scooter and his bag in hand, containing his iphone 6, with, and stole wallets etc. Fortunately, she had a few bruises and scratches only. The phone is locked with

  • Satellite P500 - AutoPlay message

    I have a Sony memory card in my Satellite P500 dedicated to ReadyBoost. It seems to work very well, but there is a minor irritation. Quite often (= several times a day) an autorun message appears on the screen asking if I want to see the files on the

  • Lenovo k4 "unable to connect to proxy servers.

    Recently I bought lenovo k4 note and I am unable to use mobile dataGoogle chrome has the error "Unable to connect to proxy servers" and other applications do not work as wellI tried different solutions but none of them work so far! Hotspot and WiFi w

  • Caught the Virus, restored to the rear and all very well. Should I upgrade my security?

    virous Hi im andy, yesterday I play and I think I uninstalled a few things including my avg when I was surfing, I was at a trojion virous allerted. I tried to reinstall avg and my computer was blocking saying me it was out of date. I was also alerted