How to call a function within a movieclip on the main timeline in CC animate canvas?

Hello world...

In AS3: Function (fnc name: myFunction) inside a Movieclip (mc1). I'll call you timeline mc1.myFunction ();

But how to call AnimateCC canvas?

If you have an instance of MovieClip named "mc" with the following code in to:

This.Fun = function() {}

Alert ("Hey!");

}

You can call this function (increased to 'this' within the MC) using the oon following the main timeline:

var root = this;

this.mc.addEventListener ("click", function() {}

Console.log (root.mc.fun ());

});

Tags: Adobe Animate

Similar Questions

  • Goto frame within a movieclip on the main timeline button

    So what I have is a button (then named) on the main timeline. I have a clip on this framework (on the main timeline) and the clip has 3 images I want to be able to scroll using the "Next" button located on the main timeline. How can I do this?

    Thank you

    assign the movieclip an instance name (in the properties panel - for example, mc) and use:

    Next.addEventListener (MouseEvent.CLICK, f);

    function f(e:MouseEvent):void {}

    mc.nextFrame ();

    }

  • How to target button in movieclip on the main timeline

    Hello!

    I have a few buttons of submenu in a movieclip in the mainline. My first level of navigation in the main timeline. The submenus are grouped into movieclips on the main timeline. I basically used the same code on the main navigation for the navigation sub except the code for the submenus is located in this movie clip. My instruction trace bed button is clicked (which was a quantum leap for me) but I know that I need some kind of code _parent in there so that he knows to go to the label back on the main timeline. Can anyone help? I feel like I'm so close.

    Also is this a correct way to set-up? I couldn't figure out how do it in an image. Any help would be so appreciated. I didn't know that this basic framework would be so difficult.

    Here is the link:

    http://www.sandraschmitt.com/Coclico/index2.html

    Thank you!!
    Sandra

    Here is my code which is on the movieclip submenu:

    Code:
    stop();

    fall.addEventListener(MouseEvent.CLICK, clickSection);
    spring.addEventListener(MouseEvent.CLICK, clickSection);

    function clickSection(evtObj:MouseEvent){
         //trace shows what's happening... in the output window
         trace ("The "+evtObj.target.name+" button was clicked!")
         //go to the section clicked on...
         gotoAndStop(evtObj.target.name);
    }

    One of the reasons that I never won any price for my vision of the design are because I am often... If it works, use it.  There are many ways to approach a design and yours is very good if you understand.  If she was going to smash something, it would have happened now.  Some people don't go to the extreme of having absolutely no code in a file, some even no content library, he wrote everything in files and class not by necessity, but to simply believe that it is the best way, or a challenge to prove their skills...  They have the it.  He participates a practicality with design that allows to make Judgment calls and if you feel that your approach to design is convenient for what you understand or which meets the needs of the project, then you have the right to follow your own path.

    That said... in the case where a person must inherit from your work somewhere down the road, that's when your approach can be victim of judgment... If someone can not follow, either found it difficult to put all the pieces together, or find them, then you become the contact person for the moans fall that follows.  But you're not likely to have to hear about it.  Yet, one day, if you are in a position where you inherit a person guestroom... and start whining about how they did it, you will come to appreciate the reasons to consider how approach you your designs.

  • How can u make a mc in this framework the main timeline is on

    How can u do mc change this frame of the main timeline is on?

    For example


    onClipEvent (enterFrame) {}
    If (_root.mc1.hitTest (this) == true) {}
    Play();
    }
    }

    I want as the mc to play the main script not his own screenplay

    Thank you for your time
    Rbr1234

    address thr main scenario as 'this ._parent.

  • Access a MovieClip in the main timeline of an external class

    Hello


    I've been struggling with the same question for a few days now, and I don't know it can be easily solved - I have just found a way that works for my case


    Basically I have a series of clips on the main timeline, the name "S1B1' to 'S5B8' as a result. I would like to add to a table in a separate category called "BeatArray".


    For the moment, I found no referencing the MovieClips from the separate class file that works, and I tried many different methods (including adding MovieClip (root). before each one and various other things).

    It's probably worth noting that the external class has already extends MovieClip.


    Any help is greatly appreciated!


    See you soon

    When you instantiate the outer class passes a reference to the main timeline and assign it within the class and use it in your targeting.

  • How to call other functions within the ScriptableFunction class

    I am trying to create an extension of javascript class which will record audio, but the problem is that I can't call other methods in the class.

    clear explanation about my problem:

    It's my Scriptable class

    public final class OCNUtilsNamespace extends Scriptable
    {
        VoiceRecord vr;
    
        public OCNUtilsNamespace()
        {
            this.vr = new VoiceRecord();
        }
        public Object getField(String name) throws Exception
        {
            else if(name.equals("VoiceRecorder")){
                return this.vr;
            }
    
            else if (name.equals("stopRecording"))
            {
                this.vr.stopRecording();
                return new String("Stopped Recording");
            }
            else if (name.equals("startRecording"))
            {
                this.vr.startRecording();
                return new String("Started Recording");
            }
            return super.getField(name);
        }
    }
    

    and here's my ScriptableFunction class:

    public class VoiceRecord extends ScriptableFunction {
    
        String status = "start";
        public Object invoke(Object obj, Object[] args) throws Exception{
            if(status.equals("start"))
                return new String("Started Recording");
            if(status.equals("stop"))
                return new String("Stopped Recording");
            return new String("nothing");
        }
    
        public void stopRecording(){
            status = "stop";
            return;
        }
        public void startRecording(){
            status = "start";
            return;
        }
    }
    

    in my javascript every time I call

    alert(OCN.OCNUtils.VoiceRecorder());
    

    I get the response as "recording started"

    but whenever I tried to call

    alert(OCN.OCNUtils.startRecording());
    

    I don't get all respose and the script will stop working at that time here.

    Why is happening like that?

    I'm doing something wrong?

    I did not understand this concept of scriptablefunction anyone please explain what is happening?

    have to apply Runnble to the future because I have to record the sound of the microphone

    I suggest that you simply pass an argument of your javascript in your extension like this:

    public final class OCNUtilsNamespace extends Scriptable
    {
        VoiceRecord vr;
    
        public OCNUtilsNamespace()
        {
            this.vr = new VoiceRecord();
        }
        public Object getField(String name) throws Exception
        {
            if(name.equals("VoiceRecorder")){
                return this.vr;
            }
            return super.getField(name);
        }
    }
    

    and on your class that extends a ScriptableFunction,.

    public Object invoke(Object obj, Object[] args) throws Exception{
    
                   String param = args[0].toString(); // Cast a parameter from your js to a string
    
            if(param.equals("start"))
                return startRecording();
            if(status.equals("stop"))
                return stopRecording();
            return new String("nothing");
        }
    
        public String stopRecording(){
            status = "stop";
            return status;
        }
        public String startRecording(){
            status = "start";
            return status;
        }
    

    Finally, call your extension via javascript like this:

    alert(OCN.OCNUtils.VoiceRecord("start")); // Call the startRecording() on your VoiceRecord class
    alert(OCN.OCNUtils.VoiceRecord("stop")); // Call the stopRecording() on your VoiceRecord class
    

    Hope this helps

  • Go to a function on the main timeline of the timeline of the object

    Hello

    I have an object on the stage, MovieClip, with an animation inside.

    The animation is called from a class file.

    I would like to call for a function, addBubbles, when the animation of the MovieClip is completed.

    The function, addBubbles, is described in the main timeline, in the first picture.

    But I would like to call from inside this MovieClip, and write the code in the last image.

    How should I reference, so it would work?

    Both ways would be to use just...

    MovieClip (root) .addBubbles ();   OR MovieClip (parent) .addBubbles ();

    Another way would be to have the MovieClip to dispatch a custom event for which you have a listener assigned in the main timeline.  This listener in the main storyline would have an event handler function that calls the addBubbles function.

  • Button on the main timeline control movieclip

    Hello

    I have a stop in my main script. At the stop, I have a play of movieclip. In the movieclip, I'll have a video playback. After playing the video, I have a button for the user to continue playing until the end of the movieclip. Once the movieclip is done, I want back the return to a specific image in my main script.

    I can't figure out how to make this work. Anyone have any ideas?

    Thanks in advance,

    Paul

    How much of what you just described in currently working properly?

    If it's just the last step to have the game finished main scenario the movieclip, then you might have an event listener assigned to this movieclip in the main timeline.  When the movieclip ends it can send an event of this listener that can trigger an event handler function in the main timeline to tell the main scenario for continued as planned.

    Another less glamorous but more compact approach might be to have a drive inside / at the end of the movieclip to order the main scenario of an act using something like...

    MovieClip (parent) .gotoAndPlay (whatever);

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

  • How to call a function stored in ADF

    How to call a function stored in the ADF?

    Example of function:

    create or replace

    FUNCTION SF_HELLOWORLD

    (

    NAME IN VARCHAR2

    ) RETURN VARCHAR2 AS

    BEGIN

    DBMS_OUTPUT. ENABLE (500000);

    DBMS_OUTPUT. Put_line (' Hello ' |) NAME | ", YOUR ATTEMPT IS SUCCESSFUL");

    -OUTPUT: = 'Hello'. NAME | ', YOUR ATTEMPT IS SUCCESSFUL;

    RETURN 'Hello'. NAME | ', YOUR ATTEMPT IS SUCCESSFUL;

    END SF_HELLOWORLD;

    ADF Code example:

    try {}

    System.out.println ("* beginning of the code *");

    String sql = "declare VARCHAR2 (2000) WISH;" begin to DESIRE: = SF_HELLOWORLD(:NAME); : WISH: = WISH; end; ";

    CallableStatement st = getDBTransaction () .createCallableStatement (sql, getDBTransaction(). DEFAULT VALUE);

    st.setObject ("NAME", "ABC"); replace the ABC with required param

    st.registerOutParameter ("WISHES", Types.VARCHAR);

    St.Execute ();

    System.out.println ("the output of the function DB is:" + st.getObject ("WISHES"));

    System.out.println ("* end of code *");

    } catch (Exception e) {e.printStackTrace () ;}

  • Calling a function within a symbol?

    Hello

    I am one of these flash devs who try to get edge animate to do what I usually do in Flash, so I could do this the wrong way, but I have a symbol with an "inner" function on my scene, and I want to call this function from the scene.

    I tried to use () .getStage () sym.getComposition ().getSymbol("symbolName").functionName; but it does not work.

    I have no problem handling the symbol itself by calling the . play() or . hide() so I know the path work... someone can show me the proper syntax to call a function within a symbol?

    THX in advance

    Hi Abnesher,

    An important principle to grasp is that symbols (and the stadium is one of them) is located in parallel, despite instances of different symbols, nested one inside the other (and all ultimately nested in the scene).

    The consequence is that from the inside of your nested symbol, you have no direct visibility of the function defined inside the step symbol!

    Inside of the symbol of the step , in the document.compositionReady event handler:

    sym.yourGlobalFunction = function (firstParameter)

    {

    your stuff

    }

    Inside another symbol, in one of its event handlers:

    sym.getComposition () .getStage () .yourGlobalFunction (5);

    Gil

  • How to call a function inside a canvas from the outside?

    Hey,.

    I created a HTML5 Canvas animation with animate CC and also added some bootstrap stuff to the HTML document by hand. To animate CC, on the main timeline, I added a function:

    this.removeObject = function() {}

    Console.log ("withdrawal of object");

    // [...]

    }

    Outside the canvas element, I added a button. When you click on it it must call the function removeObject inside the canvas.

    I tried to access by adding a "= window.parent.canvasTimeline;" Variable in the file CC animate, but it does not work.

    Is it still possible?

    It is of course possible. Just have your code Animate stash a reference to your function in the global scope.

    globalMyAnimateRemoveObjectFunction = this.removeObject;

    Then you can make globalMyAnimateRemoveObjectFunction() from anywhere in the page.

  • How to call a function inside a class?

    Hello, I am starting a delivery service... This function is inside a class.
    In this function, I am referring to another function inside the calss to call a Tween. It never happens in the second function.

    I tried to make an example.

    In the fla file, I have:
    var test: makeMovie = new makeMovie (this);


    You will see a red squere and you can press it. It must run the tween class. I use the delegate bad class?

    My instructions are not clear or you misread the. It works very well with my suggestions as follows:

    And thereby on the main timeline:

    Import makeMovie;

    var Mymovie = new makeMovie (this)

  • How to remove a function on the main timeline in a clip

    How to remove a function which is coded on an image of the main timeline of a clip?  I tried this, but no dice:

    infoGraphicDisparity.addEventListener (MouseEvent.CLICK, fl_ClickToGoToScene);

    function fl_ClickToGoToScene(event:MouseEvent):void

    {

    parent.removeEventListener (Event.ENTER_FRAME, parent ["enterFrameHandler"]);

    MovieClip (this.root) .gotoAndPlay ("disparity");

    }

    It's the event that I am trying to remove:

    stage.addEventListener (Event.ENTER_FRAME, enterFrameHandler);

    any help would be appreciated as always.

    Thank you!

    any image (which runs after enterFrameHandler is defined) in any display in the display list object

    stage.removeEventListener (Event.ENTER_FRAME, MovieClip (root) .enterFrameHandler);

  • How can I access a variable on the main timeline of a movie nested in HTML5 Canvas

    Hello

    This should be pretty simple, but for some reason, it does not work if I have the wrong syntax.

    But I have a movie clip with a bit of code in it.

    It is a timer.

    I want to be able to program the wait time: since the main scenario and that the timer read this variable on the main timeline.

    I implemented the delay var = 1000 on the main timeline, but then I do not seem able or knows how to get this variable in my code in the nested MC. It is quite difficult to find the reference of the paradigm flash timelines on H5 support pages, so I really appreciate the help.

    tl2 var = this;

    TL2. Stop();

    var delay = delayMain;

    var startTime is createjs. Ticker.getTime ();

    createjs. Ticker.addEventListener ("tick", f);

    {function equation

    If (createjs. Ticker.getTime () - startTime > delay) {}

    TL2. Play();

    createjs. Ticker.removeEventListener ("tick", f);

    }

    }

    If you want to get to a variable defined by a feature any at any depth, you can use the window. As:

    Window.Delay = value;

    in a deeply buried movieclip, can be read in any other level of the project.

Maybe you are looking for

  • Disabled Iphone 5s

    My 5s iPhone is disabled and its 'home' button is also broken. I can't connect to iTunes, and I can put it in recovery mode. I don't know what to do.

  • Acer z5600 Wireless Driver

    I had to reinstall Windows 7 on my Acer Z5600 because of a hard disk crash. I downloaded and installed all the drivers except for the wireless drivers. Drivers Realtek gives me an error message saying that the operating system is inaccurate and it do

  • Routine Photosmart 5524 alignment every time I turn on

    My Photosmart 5524 new crosses his routine of alignment, print a page and then it scans whenever I turn on the printer. 1 is this normal? 2. can I pass this waste of paper and ink out and if so, how? Thank you very much.

  • Resource file < C_PsdRsDll > not found!

    I get the following error message when I try to open some applications.  After I click 'OK', the application comes finally to the top. Resource file not found!

  • The Windows operating system upgrade

    Ladies and gentlemen, I live in England and Portugal and I have an Acer laptop in each Country. In Portugal, I have an Aspire 5750 G with Windows 7 Home Premium OS In Português. In England, I just upgraded my OS Pro 8.1 Windows English for Windows 10