How to call functions of class Document class side

Main is my doccument class. How can I call the Main.showAlert class of the caller function.


package
{
import flash.display.Sprite;
import flash.events.Event;

SerializableAttribute public class Main extends Sprite
{

public void Main (): void
{
If init() (stage);
of another addEventListener (Event.ADDED_TO_STAGE, init);
}

private void init(e:Event_=_null):void
{
removeEventListener (Event.ADDED_TO_STAGE, init);
entry point
}

public void showAlert() {}

trace ("called")
}

}

}

////

package
{

public class calling
{

public void Caller()
{
Main.showAlert)
}

}

}


////

change your instantiation of the appellant if you switch a display object.

package
{
import flash.display.Sprite;
import flash.events.Event;

SerializableAttribute public class Main extends Sprite
{

public void Main (): void
{
If init() (stage);
of another addEventListener (Event.ADDED_TO_STAGE, init);
}

private void init(e:Event_=_null):void
{
removeEventListener (Event.ADDED_TO_STAGE, init);
entry point
}
 
public void showAlert() {}
  
trace ("called")
}

}

}

////

package
{

import flash.display.MovieClip;

public class calling
{

var mainTL:MovieClip;
public void Caller(mc:MovieClip)
{

mainTL = MovieClip (mc.root);

mainTL.showAlert)
}
 
}

}

////

p.s. Please check the useful/correct.

Tags: Adobe Animate

Similar Questions

  • How to call the library classes threw xml

    In my flash library has "MC."

    var XML = < m c = 'MC' > < / m >

    How to call MC class threw xml.

    It's a little cryptic, but I think you mean like this:

    import flash.utils.getDefinitionByName;
    import flash.display.MovieClip;
    
    var xml:XML = ;
    
    var classRef:Class = getDefinitionByName(xml.@c) as Class;
    var movieclip:MovieClip = new classRef() as MovieClip;
    addChild(movieclip);
    

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.UK/

  • How to call functions of document class?

    I m biggner in as3

    I jst do document class (employee.as) and I do a few functions

    public void account() {}
    trace ("this is an accountant");
    }
    public void designer()
    {
    trace ("this is a Designer")
    }
    public void programmer()
    {
    trace ("this is a programmer")
    }

    in another class (empData.as) I would like to call these functions

    I try this way to m...

    public void empData() {}
    var anuj:employee = new employee();
    var vijay:employee = new employee();
    var amit:employee = new employee()

    ;
    Anuj.Account ();
    Vijay.Designer ();
    Amit.programmer ();
    }

    but nothing tracing...

    You can see(6KB) the source file location

    http://sites.Google.com/site/amit0shakya/home/callclassfunctions

    Thanks for help

    [email protected]

    Yes Amit you are right you can class number n

    classes for example var classA: class1 = new class1()

    classB:class2 = new class2()

    and so on...

  • How to call function befor curret line change _ jdeveloper 11g

    Dear all

    I need call a few rows of curret befor functions has changed.

    How can I do?

    Kind regards.

    If you are talking about an af:table, you can use the property selectionListener to do something when the selection changes.

    John

  • How to call function of a process Page PL\SQL Javasrcipt

    Hello

    I have a javascript function say - function1 () defined in the Page header.
    I have a page PL\SQL process after the header.

    How can I call the javascript function - function1 () - of PL\SQL Page process.

    Thank you
    Deepak

    Hi Michael,

    I have a page PL\SQL process after the header.

    Since it's after the header (in the rendering phase) process, I think that this will call the JS? Please correct me if I'm wrong :-)

    See you soon,.
    Hari

  • How to call a function in another function?

    When I press a button, I want a series of functions to be performed one after the other (they contain interpolations, but its not relevant) , all of them waiting for the previous must be filled. I want to put the series of functions within a function, so I can simply call this function to run all others. Animations work well, but I don't know how to call functions of in another function. It would also be necessary each function to wait until the previous one is complete, to run. This is a clear example of what I need to do:

    boton.onPress = animate;

    Function animate () {}

    Animation1 (onComplete: animation2);

    animation2 (onComplete: animation3);

    animation3;

    }

    Function () {Tween 1} animation1;

    Function () {Tween 2} animation2.

    Function animation3 () {Tween 3};

    any suggestions?

    which isn't really make sense unless you're tweening or do something of asynchronous (such as loading a file).

    Function b (): Void {}

    C() ;

    D() ;  C() executed when this line runs

    }

  • How to call the function

    Hello

    How to call functions defined by the user in the select statement.
    I have to concat all the result of columns, though kindly help me.

    When I run after sql statement


    SELECT orgin_pos. «, » || the sender | «, » || consigneename | «, » || vesselname | «, » || travelno | «, » || POS | «, » || ETD | «, » ||
    ETA | «, » || NOP | «, » || grossweight | «, » || CCube | «, » || ccontainer | «, » || CSize. «, » || CType | «, » || Goh | «, » || HBL | «, » ||
    get_sea_report (hbl) linername | «, » || CompanyName AS overseasagent
    OF vietanam_report_view_bd



    -of cluase not found where expected error is coming.
    Kindly help me.

    concerning
    Prakash P
    Handle:  808542
    Status Level:  Newbie
    Registered:  Nov 8, 2010
    Total Posts:  69
    Total Questions:  48 (45 unresolved)  
    
  • Calling functions / set variables in loaded SWF

    You know how you can create a Movieclip object, add a function or a variable, and then call this function or change this variable to the SWF file that includes? I want to be able to do it, only with SWFs that are loaded at run time.

    My "main" SWF is just something the type of menu. The user clicks a button in my HAND. SWF and the HAND. SWF and then load the SWF associated with this button, using the AS 3.0 method Loader () - URLRequest () - addChild () that everyone always asks questions on prescribed.

    It works very well. But now I have a few custom and other objects (ie., not only the channels) in my HAND. SWF I want power sharing with the loaded SWF files. preferably, I'd use a function of the type of accessor (ie., LoadedSWF.GiveMeTheCoolObject (MyCoolObject)); Although at this point, I'm willing to hack the object itself (ie., LoadedSWF.CoolObject.CoolField = MyCoolObject.CoolField ;) if that's what it takes.

    I tried to call the functions and setting the fields, but the AS 3.0 compiler doesn't care for this kind of nonsense on its objects defined by the generically. Also note that, at runtime, a call to LoadedSWF.hasOwnObject ("GiveMeTheCoolObject") returns true.

    So my colleagues big brain, what is the magic?

    In advance, thank you for the help!
    Scott

    Kglad,

    Quote:
    Posted by: kglad
    the error message, seems, your function expects a member of the class MyCoolObject, correct?
    and MyCoolObject is not an instance of this class. so, you have to fix that. That is to say, create a member of this class, and use this class as a parameter of the function member.

    Heh, that's what the error message says all right. But the object IS actually an object of class MyCoolObject. I looked at this thing for hours and MyCoolObject IS an instance of this class. I tried different combinations of casting (including the cast on an object and passing that) but had no luck whatsoever.

    So I googled this particular runtime error message ("Error #1034: has no Type constraint: cannot convert '" ") and found a ton of links to other people with a similar problem. As a general rule, the problem was just as you say, someone passes a button as a string, that kinda thing. But a guy had a problem with an object that it has derived from the event class. Once the hours spent trying to make it work, he has tried to override clone() of the base class method and got it to work:

    http://www.assertTrue.com/articles/2006/10/14/custom-events-in-ActionScript-3-0

    As for my project, I took a long, hard look at the overall architecture of my project and decided it would be better if all the 'real work' is held in the HAND. SWF file. This approach would solve some other problems, and it makes sense in a mindset of "separating the display of data.

    If (and this is the interesting part) I changed the API for the LOADED. SWF to accept the pairs of strings (ie., LoadedSWF.AddToDisplay (String Name, String Data)) rather than accept MyCoolObj. Ran and Viola, now we work without any throw exceptions in. After this moment of glory, I created a couple of other APIs that comes from base classes (a type int, the other a type function) agreed and was happily on my way.

    On this basis, I understand while passing another base class objects (IE, the derived class) to load MovieClips via custom function API is... perhaps not so simple you'd expect. In the grand scheme of things well, not a big deal: as far as I'm concerned AS3 rocks.

    Kglad, thanks again for all the help: your comments on how this was the big push that I needed to get through the last barrier of this project.

    For those who read this topic for the ' how to call functions or set variables in a loaded SWF file?

    The short answer is cast to the SWF file that is loaded as a MovieClip content object and then call the function or change the variable:

    Load the SWF file (you saw this code a million times)
    var LoadedSWFObj:Loader = new Loader();
    var MyURL:URLRequest = new URLRequest("LoadThisSWF.SWF");
    LoadedSWFObj.load (MyURL);

    It is within your Event.COMPLETE Manager:

    Cast as a MovieClip object and work with it.
    var LoadedSWF:MovieClip = LoadedSWFObj.content as MovieClip;

    or another way to perform a cast:
    var LoadedSWF:MovieClip = MovieClip (LoadedSWFObj.content);

    Call yer function:
    LoadedSWF.CallMe ();

  • calling functions from c ++ JavaScript

    It seems to me that only the functions Q_SLOT can be called from an external javascript file. For example

    ButtonID.Clicked () works, while buttonid.isEnabled () does not work. How to call functions like this from javascript?

    Hello
    "Buttonid.enabled" work? (enabled is a property)

    It should also be possible to call the functions marked Q_INVOKABLE.

  • Calling functions PHP FB

    I have a project where I need to call specific PHP functions, but I'm having some trouble.

    I can call and execute PHP script, but not an individual function.

    How to call functions that exist within a PHP script?

    You can use AMFPHP. Here is an article that leads to an explanation of pdf:

    http://blogs.Adobe.com/mikepotter/2006/02/flex_and_php_us.html

    or you can google.

  • How to call a function in class library?

    Hi all

    Anyone know how to call a function in a library project?

    I have to call using a resource file in a library of a CLDC project project.

    So I write a simple test library and tried to access a function in my CLDC application.

    I tested with 2 following projects.

    1. a library project: TivitFirm

    Sorry I can't answer this from the point of view of the eclipse, I use JDE.  But I suspect that the approaches are similar, even if the detail is different, so maybe this will help you.

    In JDE, you have two options:

    (a) use a jar

    (b) create a dependent project

    (a) I usually use a jar.  So to do this I have a workspace is the library, I compile this, then in my project that uses it, I add the jar to build settings

    (b) in this case, you have two projects in the space of a job, and you say the main project that it is dependent on the library project.

    I hope this helps.

  • functions in the document class when the main timeline reached a framework

    Hello

    I have 3 functions in my document class main I want to run when the main timeline reaches a specific frame number.

    How do I do that?

    See the code and comments

    public void mainClass()

    {

    //stage declaraction

    stage.align = StageAlign.TOP_LEFT;

    stage.scaleMode = StageScaleMode.NO_SCALE;

    stage.addEventListener (Event.RESIZE, stageResized);

    wrap these next 3 lines in an if statement so maintimeline currentframe = x

    position().

    loadXml();

    initArrowButtons();

    slideTimer = new Timer (timer_delay);

    slideTimer.addEventListener (TimerEvent.TIMER, nextSlide);

    }

    You can always know what the current picture is by reading currentFrame peoperty:

    public function mainClass() {     addEventListener(Event.ENTER_FRAME, onEnterFrame);}
    
    private function onEnterFrame(e:Event):void {     switch(currentFrame) {          case 1;              frame1Function();          break;
    
              case 2:              frame2Function();          break;
    
              // etc.}
    
  • Function in class call

    How to call a function in classes?

    I have a primary class ("ChordLib.as") that contains a function that manages the options for the TileList component, which includes the prescription of a custom cell renderer class, "MyRenderer".  I want to be able to call a function in the primary "ChordLib.as" class of the class 'MyRenderer.as '.  Here's the function "ChordLib" that refers to the class "MyRenderer". There may be a way here to pass the reference of the primary class in "MyRenderer"?

    // SET CHORD LIST  //////////////////////////////////////////

    public void setChordList(song:int):void {}

    var dpChords:DataProvider = new DataProvider();

    var i: uint;

    determine the set of rope

    If (song ==-1) {}

    activeChords = allChords;

    } else {}

    activeChords = songChordSets [song];

    }

    fill with dataProvider

    for (i = 0; i < activeChords.length; i ++) {}

    var TT = activeChords [i];

    dpChords.addItem ({label: tt, source: ChordBar, data:, scaleContent:true});})

    }

    chordList.dataProvider = dpChords;

    chordList.columnWidth = 70;

    chordList.rowHeight = 30;

    chordList.direction = ScrollBarDirection.VERTICAL;

    chordList.setStyle ("contentPadding", 5);

    chordList.setRendererStyle ("imagePadding", 0);

    chordList.scrollPolicy = ScrollPolicy.ON;

    Set style for labels

    chordList.setRendererStyle ("textFormat", textFormat1);

    set the background skin

    chordList.setStyle ("skin", lightBackground);

    define cell converter

    chordList.setStyle ("cellRenderer", MyRenderer);

    }

    This last line ("chordList.setStyle ("cellRenderer", MyRenderer)'); refers to this custom class, which includes event listeners:

    package {}

    Import fl.controls.listClasses.ICellRenderer;

    Import fl.controls.listClasses.ImageCell;

    import flash.events. *;

    public class that extends myrenderer ImageCell implements ICellRenderer {}

         

    public void MyRenderer() {}

              

    this.buttonMode = true;

              

    Drop skin condition skin even static background

    setStyle ("upSkin", lightBackground);

    setStyle ("downSkin", lightBackground);

    setStyle ("overSkin", lightBackground);

              

    setStyle ("selectedUpSkin", lightBackground);

    setStyle ("selectedDownSkin", lightBackground);

    setStyle ("selectedOverSkin", lightBackground);

    turn off background of text by setting to 0

    setStyle ("textOverlayAlpha", 0);

    setStyle ("textPadding", 7);

              

    / / event listeners

    this.addEventListener (MouseEvent.CLICK, clickHandler);

    this.addEventListener (MouseEvent.MOUSE_OVER, mouseOverHandler);

    this.addEventListener (MouseEvent.MOUSE_OUT, mouseOutHandler);

         }

         

    / / EVENTS

    private void clickHandler(event:MouseEvent):void {}

         }

    private void mouseOverHandler(event:MouseEvent):void {}

         }

    private void mouseOutHandler(event:MouseEvent):void {}

         }

    }

    }

    I want to insert calls to functions that are in the main class (which contains the first feature listed here), "ChordLib.as".

    How can I do this?

    For classified call a function from another ClassB (or instance of it) he should be aware of two facts: 1) that ClassB exists and 2) that ClassB has a special function.

    Another approach might be to establish a communication between classes by the events.

    You explanation, it is not clear what you want to accomplish. Do you need to call a function on the class itself or by an instance of this class?

    So old - you must create a static function and just call it:

    inside ClassB:

    public static void classBFunction()

    ClassA can call it:

    ClassB.classBFunction)

    If you call the function on an instance - you, of course, need to instantiate the class and then call the function.

    Say you have inside ClassB

    public void classBAnotherFunction() - Note that there is no static Word

    There is an other fork here: either you instantiate the ClassB inside the ClassA or you pass a reference to the instance of ClassB in ClassA

  • calls to functions from class to class

    How to call a function that is in one class from another class? My first class creates instances of a second class. The second class is emerging. I want it so that if a user clicks an instance of the second class, first class will know which instance of the second class was clicked. I try to use a clickHandler inside the second class that then calls the function (do) in the first class, but I get this error:

    1180: call to a method may not set of doubts.

    Here is a very simplified version of what I have in progress:


    This works! Using a single object to pass parameters is a great way to do it...!

    Thank you!!!

  • Which is the best way for a function called identify the class name of the appellant.

    Which is the best way for a function called identify the class name of the appellant.

    (1) sun.reflect.Reflection using the function call
                    Class caller = Reflection.getCallerClass(2);
                    System.out.println("Caller Class Name ::"+caller.getName());
    Trace of function called battery 2) analysis of current threads
                    StackTraceElement[] stElements=Thread.currentThread().getStackTrace();
                    System.out.println("Caller Class Name ::"+stElements[3].getClassName());
    Y at - it all the other ways to achieve the same. What is the best way?
    Called function does accept no argument, I don't want the arguments of function calling function called t.

    Help, please.

    With greetings
    Paul

    798185 wrote:
    Which is the best way for a function called identify the class name of the appellant.

    Y at - it all the other ways to achieve the same.

    SecurityManager

        // 0 is the anonymous SecurityManager class
        // 1 is this class (also works in static context)
        // 2 is calling class
        static Class getClass(int i) {
            return new SecurityManager() {
                protected Class[] getClassContext() {
                    return super.getClassContext();
                }
            }.getClassContext();} 
    

Maybe you are looking for