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.

Tags: Adobe Animate

Similar Questions

  • To access the event listeners in the custom class

    I am a construction and film using the classes customized for the first time. I built a custom class and bound a clip in my film for her so that the color of the text in the video will change when he is overthrown. I have 10 occurrences of this clip in the film, so it saves me a lot of code. Instead of writing 10 to ROLL_OVER event listeners and 10 more for ROLL_OUT (as I have done in the past), one for each instance of the clip on the scene, I wrote now event listeners and the corresponding functions in the custom class. So far, so good, everything works fine. When I ride above and outside on one of the 10 instances of the clip on the stage it changes color. See code attached.

    However, according to what is happening in the film, that I sometimes need to turn off the headphones of events on one or more video clips. So, I wrote the code in the movie itself to remove event listeners of the instance of the clip that I need to disable. See code attached.

    But, alas, it does not work.

    I get this error:
    ReferenceError: Error #1065: Variable turnWhite is not defined.

    I thought that by the 'public' method in the custom class, I would be able to call from the film, but I do not. Any help or advice would be greatly appreciated. Thank you very much.

    Ned, thanks for your help. I was able to understand. Your code has been helpful, and I've used something similar to what you suggested.

  • 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);

    ...

  • 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).

  • Properties of the label and the custom class

    I want to do the following persistent: < mx:Label useHandCursor = "true" buttonMode = "true" mouseChildren = "false" / >

    I tried to create a custom class that extends the class Label, but we can't get the syntax right.

    protected override?

    buttonMode = true;

    I don't think I want to replace a function.  It seems to me that I want to override a property or attribute of the Label class.

    Can someone give me advice?

    Hello

    As you Lable with the default property {useHandCursor = "true" buttonMode = "true" mouseChildren = "false"}

    I extend the label, you can do it directly in the constructor by setting

    -Custom label class-

    package
    {
    Import mx.controls.Label;

    SerializableAttribute public class CusLbl extends Label
    {
    public void CusLbl()
    {
    Super();
    super.buttonMode = true;
    super.useHandCursor = true;
    super.mouseChildren = false;
    }
           
    }
    }

    --------------------------------------------------------------------------------

    You can use directly in the application or in any other container with the default property;

    See attached the file if necessary.

    Regarding

    Virat Patel

  • To access the properties of the custom class

    Hello again! Nevermind, I got display list order because it has me even more trouble :)

    I have several items stacked from the other (boxes) and you want to calculate the height of all the underlying boxes for each box. Each box is an instance of a "Kiste"-custom class that has a property "hoehe" (height). "." Usually, I can access this property from anywhere and it works fine. But in the following case, it won't. The alles.getChildAt(j-1) works fine with all other assets, but not with custom properties that I defined in my class?

    OK, get it myself... Type cast!

  • Best way to insert data into instances of the custom class

    Hello.

    I have created a custom class (mySuperClass) in an .as file, defined constructor methods, properties, and the get/set. Now in the main .fla I must declare a large number of instances of this class and complete each property. The 'proper' method, I guess, would be to:

    var super1:mySuperClass = new SuperClass();
    super1.setProperty1 ( value1_1);
    super1.setProperty2 ( value1_2);
    ...
    super1.setPropertyN ( value1_N);

    ...
    var superM:mySuperClass = new SuperClass();
    superM.setProperty1 ( valueM_1);
    ...
    superM.setProperty1 ( valueM_N);

    However, with large quantities of variables and information that share the same basic characteristics, I feel always attempted to do through a cycle of dethrone. In that case, I'd probably build tables with the properties to complete.

    So I want to know is how would you guys do it? Are there other ways to do it?

    Thanks in advance.

    Well, the example is based on an object that has a datamodel and which can be any object of course. Now, assuming that the data come Let's say an xml file, I would use a function as the code to generate a collection of objects.
    Edit: so the StoreItem instances are created on the fly and saved in the collection

  • Iterate through the custom Classes?

    Hello

    Suggests, I have a class with public properties as

    Class person {}

    public var address: String;

    public var name: String;

    public var fathername:String;

    etc etc.

    }

    Now I want to iterate over them in a simple way as

    for {(var clé: string en personne)}

    trace ("property is" + key + "and the value is" + person [key]);

    }

    But does not allow it to do with the AS3 Classes

    Now, I want you guys to suggest me what would be the simple and best way to iterate over them, because I don't want to do so much if (else) about it.

    Thank you

    You can try using the describeType() method:

    http://livedocs.Adobe.com/Flash/9.0/ActionScriptLangRefV3/Flash/utils/package.html#describ eType ()

  • Extend the custom class

    I made the transition to AS3 two years ago, but I always carry with me old habits AS2. Could someone please help me understand how to extend a custom correctly class.

    I have a bad habit to put most of my code in a file .as (Document class), but I use some custom time classes. I am tring to understand, this is how I would extend to a class of this type:

    public class ClipDragger {}

    private var _clip:MovieClip;

    public void ClipDragger(clip:MovieClip) {}

    _clip = clip;

    _clip.buttonMode = true;

    _clip.addEventListener (MouseEvent.MOUSE_DOWN, drag);

    _clip.stage.addEventListener (MouseEvent.MOUSE_UP, drop);

    }

    private void drag(event:MouseEvent) {}

    _clip.parent.SetChildIndex (_clip, _clip.parent.numChildren - 1);

    _clip.StartDrag ();

    }

    private void drop(event:MouseEvent) {}

    _clip.stopDrag ();

    }

    }

    For example, I would like to add a MOUSE_MOVE listener and also add actions in drag.

    Could someone guide me in the right direction please?

    package {}

    import flash.display.MovieClip

    SerializableAttribute public class ClipDraggerExtension extends ClipDragger {}

    private var _clip:MovieClip

    public void ClipDraggerExtension(clip:MovieClip) {}

    Super (clip);

    _clip = clip;

    }

    add whatever.

    replace all what

    }

    }

  • AppModuleImpl methods of the class returns the custom class types, not called.

    Hi all

    Methods of the class AppModuleImpl custom types of class, not called when you access through back links.

    OperationBinding operationBinding = bindings.getOperationBinding("getInstanceNameO"); where 'getInstanceNameO' is a method AppModuleImpl returns a class serializable type.

    Any help will be appreciated.

    OI_testBean.goInstanceName_methodCallNew (OI_testBean.Java:99): this line is the call of method appmoduleimpl: OperationBinding operationBinding = bindings.getOperationBinding("getInstanceNameO");

    Looks like 'bindings' is null.

    How to retrieve variable 'bindings '?

    Where is the OI_testBean.goInstanceName_methodCallNew () method called?

    If this method is called from the method call activity, you create pageDef in his name and add getInstanceNameO

    Dario

  • Error found in the custom class

    Hello

    I get an error from line 7 (public service below - 1046: Type was not found or is not a constant of compilation: DisplayObjectContainer):

    ----------------------------------------------------------------------

    package
    {

    public class traceDisplayList
    {

    public void traceDisplayList(kontainer:DisplayObjectContainer,_indentString:String=""):void
    {
    var child: DisplayObject;
    for (var i: uint = 0; i < kontainer.numChildren; i ++)
    {
    child = kontainer.getChildAt (i);
    trace (indentString, Child, Child.Name);
    If (kontainer.getChildAt (i) is DisplayObjectContainer)
    {
    traceDisplayList (DisplayObjectContainer (child), indentString + "");
    }
    }
    }

    }

    }

    Any idea?  I see no error on my part.

    Kind regards

    Ron

    This error message is misleading, but you have twisted code.  Try:

    package
    {
    import flash.display.DisplayObjectContainer;
    import flash.display.DisplayObject;
    public class traceDisplayList
    {

    public void traceDisplayList(kontainer:DisplayObjectContainer,_indentString:String=""):void
    {
    traceF (kontainer, indentString);

    }

    private void traceF(kontainer:DisplayObjectContainer,indentString:String=""):void {}

      var child:DisplayObject;            for (var i:uint = 0; i < kontainer.numChildren; i++)            {                child = kontainer.getChildAt(i);                trace(indentString,child,child.name);                if (kontainer.getChildAt(i) is DisplayObjectContainer)                {                    traceF(DisplayObjectContainer(child),indentString + "");                }            }
    

    }

    }

    }

  • Custom with the custom event handling/propagation class

    Hello

    I m trying to figure out, how we could extend a custom class so that other classes could enter the headphones to this custom class

    and will be informed by raising an event in this custom class.

    I can´t find any documentation about it. The post of oracle on the management of the event to

    http://docs.Oracle.com/JavaFX/2/events/jfxpub-events.htm

    doing business only about the event target and the string of events.

    But to my understanding, I need to know how this custom class could be extended to be an EventSource?

    I could extend my node, scene or window class to get all the things in the event by legacy, but I think that

    that is not the right way? Not everything is a node

    As indicated in the article

    If your control or element of your control is not a subclass of Window , Scene , or Node , you need to implement the EventTarget interface for this control or element.

    I must apply EventTarget and its method

    @Override
        public EventDispatchChain buildEventDispatchChain(EventDispatchChain edc) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    

    But it is a target? And the source?

    I m a bit confused.

    Help would be great for a beginner, some shooting events

    THX

    Inge

    Would what type of event you like fire? Perhaps using the framework of the event in javafx.event is more you need. What if all you want to do is to inform listeners that some State has changed, you should consider using javafx.beans.Observable or one of the classes implementing this interface.

  • Create the custom handler class touch

    Hi all! I have a problem that seems easy enough to fix, but I'm doing it with reusable code, which is to do something I do not understand yet. I googled this continually and read dozens of articles and I'm still just as lost than when I started. I hope that human life can help me to make sense.

    I have a clip on the stage. When you press this clip, I want to play a certain slice of another clip for as long it is being touched. (This is a map of the United States, that display the name of each State that he's in a hurry).

    I COULD write 50 different functions, each to call a different image of the film displayName, or I could write my own custom event which would be able to receive every key event a string variable and then say displayName that frame to play.

    So basically, I have, for example:

    alaskaMovieClip

    displayNameMovieClip

    When you press alaskaMovieClip, I want to address to the string of the 'Alaska' variable to a touch custom event class, which will then a bunch of stuff as well execute displayNameMovieClip.gotoAndStop ('Alaska').

    1 is it possible?

    2. how? I'm if confused about how custom touch events are created and executed, I've read dozens of articles, and they have just the code that I do not understand. This tutorial should I be looking for that could help me?

    Thank you!!!
    Amber

    One way is to store a public var (say var state = "AZ"; for example) in your puzzleAZ. So you'd just:

    puzzleAZ.addEventListener(TouchEvent.TOUCH_BEGIN, unitTapHandler);
    
    function unitTapHandler (e:TouchEvent): void {
        e.target.gotoAndStop("Over");
        nameDisplay.gotoAndStop(e.target.state); // e.target.state is "AZ"
    }
    

    The other way is to let your MovieClip to send a custom event (which holds the 'State' var) Touch to start the event. Then the mother (or the main timeline or the document class) listen to the custom of your MovieClip event.

    // custom event
    package {
        import flash.events.Event;
    
        public class UnitTapEvent extends Event {
    
            public static const TAPPED:String = "tapped";
            public var state:String;
    
            public function UnitTapEvent(type:String, state:String):void {
                super(type);
                this.state = state;
            }
    
        }
    }
    
  • Customize the process of downloading files by replacing the UploadedFileProcessor class

    12.1.3 Jdev

    Hello

    I have an af:inputFile on the page and want to customize the file loading process by replacing the class org.apache.myfaces.trinidad.webapp.UploadedFileProcessor together with the < downloaded-file-processor > element in the config.xml configuration file - Trinity.  This is because we want to save the file directly on the database rather than store them in temporary storage.  No samples of writing a custom class?

    I understand in the custom class, it must implement the UploadFileProcessor interface and override the method:

    processFile (object request, file UploadedFile)

    What is the motion of object?  And how to treat?

    All advice is appreciated.

    Thank you

    -Mina

    Thanks Timo.  Excellent suggestions!  I found the class that implements UploadedFileProcessor is org.apache.myfaces.trinidadinternal.config.upload.CompositeUploadedFileProcessorImpl.java

    Thank you

    -Mina

  • 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.

Maybe you are looking for

  • Battery Lenovo G70-80

    I bought a brand 'new' Lenovo G70-80 from BestBuy a couple of weeks. I never noticed until last night, but battery does not charge even if the adapter is plugged. Someone else has the same problem and if so, were you able to get a replacement for you

  • Cannot delete files from 0 KB Word 2003 "cannot read the source file or disk.

    Original title: how remove the files from Word 2003 0 Kb which can not be read - file cleaner empty and an empty folder solvent do not work - "cannot read the source file or disc! I have a number of Word 2003 files that I'm unable to delete, since th

  • Why my computer restarts after plugging it down?

    I initially went to the top and recovery and disable auto-start upward but when I stopped him I get a blue screen that talks about a computer error has a stop code to the the low stop: 0x0000007e (0xc0000005, 0xf7599ab9, 0xb3909914 0xb3909610) it res

  • problems with re - install software roxio creator 9

    I had roxio creator 9 downloaded correctly, then a few weeks ago I started receiving messages that the certificate file is missing or damaged. not knowing exactly what it was just totally uninstalled the whole program i. now, I'm trying to re - insta

  • Error NET HELPMSG 3521 while checking the Update Service was stopped and the error code "8024000".

    Original title: error NET HELPMSG 3521 while checking the Update Service was stopped. Windows Vista. 32-bit, SP1 and 2 Long story short, I tried to fix my problem of update windows since the beginning of July 2011.  My computer does not stop when you