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

Tags: Adobe Animate

Similar Questions

  • Use the MC button to perform function on the main timeline

    I was wondering how (or if it is possible) to use a button that I have in a clip to perform a function on the main timeline. Specifically, I want the button in the clip to stop on an image of the main timeline. Any suggestions?

    Hello
    _root is the main scenario.
    So if you have your button (say button1) the code would be

    Button1.onRelease = function() {}
    _root.gotoAndStop (20);
    }

    This would prevent the main timeline to frame 20.
    This is for actionscript 2 (flash 8).

    for cs3 (actionscript 3) this would be it

    Button1.addEventListener (MouseEvent.Click, clickHandler);
    function clickHandler(event:MouseEvent):void {}
    _root.gotoAndStop (20);
    }

    Hope this helps
    Alan

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

  • 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 to set a variable in the main timeline of in a symbol?

    Just get started with Animate and coming from Flash, it may be apparent to my question. How do you define a variable for the main timeline of in a symbol?

    I have 24 pairs of clickable elements, each in their own symbols, and 24 of these symbols to sit inside another symbol. I want every 24 to set the global variable even when you click on it. I do not find that this question is anywhere, which makes me think that I can be stuck in a mentality from Flash and approaching the task in a bad way. (However, there are MANY discussions address showing how objects to different levels in the hierarchy.) Which is well covered).

    By the way, how to access a function on the main timeline of in a symbol?

    Adobe should consider putting on foot (or pages) support just for people migration form Flash. In the documents that I've met so far there seems to be a studied effort to refrain from mentioning Flash somehow. I imagine that there are many people out there like me who have a deep background in coding Flash, but start with Animate. We don't need help with most of the basic concepts, but we still have some pretty basic questions on how to achieve certain things in Animate because our knowledge of Flash gets in the way.

    Hi Bill,

    There are a lot of discussions here on the scope, but here's a way to create a global variable:

    code on Stage.compositionReady

    sym.myGlobalVar = 1;

    Then, anywhere in your project, you can check/set this var as follows:

    sym.getComposition () .getStage () .myGlobalVar = 2;

    And here is a way to create a global function:

    code on Stage.compositionReady

    sym.myGlobalFunction = function() {}

    Console.log ('myGlobalFunction');

    }

    Then, anywhere in your project, you can call this function as follows:

    sym.getComposition () .getStage () .myGlobalFunction ();

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

  • Button inside a clip controlling the main timeline

    Hello-

    I have a clip on the main stage - inside that movie clip is a button - I want that button to contol a function on the main timeline.

    example: the Script button

    closeAll_btn.addEventListener (MouseEvent.MOUSE_DOWN, goCloseAll);

    function goCloseAll(e:MouseEvent):void {}


    * do not know what to put here to activate "closeAllOpenMovieClips" on the main stage *


    }

    example: main stadium Timeline Script

    function closeAllOpenMovieClips (): void {}
    trek_mc.gotoAndStop (1);
    lost_arts_mc.gotoAndStop (1);
    rain_mc.gotoAndStop (1);
    vintage_mc.gotoAndStop (1);
    }


    do not know if I need a script more on chronology of main stadium that comes "from function."

    Thank you - Ben L

    If the button is in part 2, then the event listener so that it must be well on frame 2... or you could make the button visible/invisible betrween frames 1 and 2).

    But if you want to head back to your original approach...

    closeAll_btn.addEventListener (MouseEvent.MOUSE_DOWN, goCloseAll);

    function goCloseAll(e:MouseEvent):void {}

    MovieClip (root) .closeAllOpenMovieClips ();

    }

  • Go to the next section in the main timeline of a class

    I am trying to go to the next section in the main scenario of a class with no luck.

    I have a clip called winner_mc that is created in the document class.


    winner_mc is related to the winning class.

    The winner class creates a clip called nextlevel_mc which is linked to the Nextlevel class.

    Then when I click on the movieclip nextlevel_mc I want to go to the next section on the main timeline.

    I tried this for the Nextlevel class:

    package  {
         
         import flash.display.MovieClip;
         import flash.events.MouseEvent;
         
         public class Nextlevel extends MovieClip {
              
              
              public function Nextlevel() {
                   this.addEventListener(MouseEvent.MOUSE_UP, goNextLevel);
              }
              
              public function goNextLevel(e:MouseEvent):void {
                   MovieClip(root).nextFrame(); //also tried parent instead of root
              }
         }
         
    }
    
    

    Can't seem to get this to work. Would be very grateful for help. Thank you.

    apply nextFrame() to this (cast as a movieclip) and see what happens.

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

  • Recovery of file names on the main timeline in classes

    I have the following code on the main timeline. I have soundLoad_mc assigned to the SoundChgUrl class.

    soundLoad_mc.mp3URL = "climbing.mp3";
    soundLoad_mc.swfName = "journey.swf";

    The code below is from SoundChgUrl. The import of mp3URL works. That nomswf does not work - it, throw "1119: access nomswf property possibly not defined through a reference with static type classes: SoundChgUrl.» It's not logical for me.

    package classes
    {
    import flash.display.MovieClip;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    import flash.events.Event;
    import flash.media.Sound;
    import flash.media.SoundChannel;

    SerializableAttribute public class SoundChgUrl extends MovieClip
    {
    public var _mp3URL:String;
    public var _swfName:String;

    private var sound: Sound = new Sound();
    private var channel: SoundChannel = new SoundChannel();

    public void SoundChgUrl()
    {
    sound.addEventListener (Event.COMPLETE, soundLoaded);
    }

    public function set mp3URL(value:String):void
    {
    _mp3URL = value;
    Sound.load() (new URLRequest (_mp3URL));
    _swfName = "journey.swf";
    }

    public function set swfName(value:String):void
    {
    _swfName = value;
    }

    private void soundLoaded(event:Event):void
    {
    sound.removeEventListener (Event.COMPLETE, soundLoaded);
    channel = sound.play().
    channel.addEventListener (Event.SOUND_COMPLETE, changeURL);
    }

    private void changeURL(event:Event):void
    {
    Channel.Stop ();
    navigateToURL (_swfName, "_parent");
    channel.removeEventListener (Event.SOUND_COMPLETE, changeURL);
    }
    }
    }

    Click file/publish settings/flash and check "permit debugging".  Repeat the test.

    then copy and paste the full error message and highlight the line of code mentioned in the problematic error message.

  • Calling a function in the main sequence of a loaded swf file

    I know this is probably a very basic question, but I loaded a SWF file in another film. Now, I want to call a function in the main SWF file. Is it possible to do? Otherwise, I have a custom class where I could put the function, but I was not able to understand how to call it from the SWF loaded either. Can I somehow associate the class with the main movie, or...?

    Nevermind - I did something very stupid and was not calling the function as a method of a clip. I was just calling checkTarget (event) and not event.currentTarget.checkTarget (event); that seems to work.

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

    });

  • Using CS4 Flach and action script 2.0 how to move a specific frame in the main timeline when a movie clip instance come at the end of his chronology?

    Using CS4 Flach and action script 2.0 how to move a specific frame in the main timeline when a movie clip instance come at the end of his chronology?

    code on the last frame of your movieclip instance:

    _root.gotoAndStop ('whatever_frame');  will work unless this swf is loaded into another swf.  in this case, you must use a relative path to the main timeline (for example, _parent or _parent._parent etc.).

  • Is it possible to get a reference to the main timeline in an external class?

    Hello
    After spending over 2 hours on google on how to access the pit of the main timeline an external class
    I have not found any solution.

    Anyone know how to the main script in an external class to access?
    And you can see a movieclip (the name of the instance) of a clip that is drawn on the scene and not
    place dynamically with addChild in an external class?

    I hope to hear from anyone.

    I discovered a solution. Don't know if it's good, but it works for me.

    What you have to do is on your movie fla on any keyframe:
    Hello from the var: YourExternalClass = new YourExternalClass ();
    hello.someFunction (this);

    and in your external class, make a public service:

    public void someFunction (mainTimeLine): void {}
    trace (mainTimeLine);
    mainTimeLine.getChildByName("instancenameofyourmovieclip").alpha =. 5;
    mainTimeLine.getChildByName("instancenameofyourmovieclip").rotation = 30;
    }

    See you soon!

  • Toolbox for CreateJS: how to control the main timeline from outside the canvas.

    Hey everybody,

    I'm currently doing something simple, but my animation film breaks whenever I try to change my code. I created a basic animation in Flash where an object moves from the left side of the canvas, to the right and then loops of the last frame of the first image. Nothing else. The animation is simply placed on the main timeline. I exported the animation with the Toolbox for CreateJS through the extension of the Flash and animation series as it should. I'm trying to start and stop (reboot of the first image) the animation with the mouse on and off mouse events. I want that the events to fire when wriggling over/stop a div outside the animation canvas tag. Is this possible with CreateJS? I'm trying to find a way to control the main timeline without being inside the canvas tag.

    HTML example:

    http://www.thephotoncore.com/testing/example_test.html

    Example Code:

    < id article 'container' = >

    < canvas id = "canvas" width = "550" height = "400" style = "background-color: #cccccc" > < / canvas >

    < section id = "animation_control" >

    < p > hover over to start and stop animation. < /p >

    < / section >

    < / section >

    Thanks again for the help!

    -DJ

    Hi DjPhantasy5,

    All the clips on the scene are children of the scene,

    So now the "mouseover" all clips on the stage could be stopped with stop and on the "mouseout/mouseouthandler()" all the children could be restarted with gotoAndPlay like this:

    function Stop()

    {

    If (stage & stage.children)

    {

    var t = stage.children.length;

    for (i = 0; i< l;="">

    {

    child var = stage.children [i];

    If ('stop' in child)

    Child.Stop ();

    }

    }

    }

    function Restart()

    {

    If (stage & stage.children)

    {

    var t = stage.children.length;

    for (i = 0; i< l;="">

    {

    child var = stage.children [i];

    If ("gotoAndPlay" children)

    child.gotoAndPlay (0);

    }

    }

    }

    See http://www.liauw.nl/forums/adobe/djfantasy5/index.html

    But it is also possible to expose "ball1", for example, by adding it to the document.

    This can be done by adding the code for "ball1" as follows:

    / * js

    document.ball1 = this;

    */

    Then stop the animation would look like:

    function Stop()

    {

    If ('ball1' in the document)

    document.ball1.stop ();

    }

    etc.

    Have fun!

    Ronald

Maybe you are looking for

  • New e-mail notifications does not.

    In recent weeks I get no alerts, tray icon or the same sounds so I haven't changed any settings. I have been using Thunderbird for years and this machine for over a year, and yet I've had no problems until recently. I looked through the boards and th

  • Re: Satellite P850-12 x "pop" noise is in the left hand speaker

    You can, or that you have perhaps not seen my other problem with this laptop, which resulted in a replacement unit. Now for the replacement, I got it for a week and everything was perfect until last night when I started to hear a cracking sound from

  • Need to constantly force quit Safari

    Hello I have problems with Safari which has occurred recently. Sometimes starts with being unable to get into any entry box whether the site or the address bar of Safari. However then get the Beachball of doom, and need to quit smoking, then force qu

  • HP Pavilion Windows 8.1 DVD drive problems

    My HP Pavilion Notebook PC (ENERGY STAR) product 15-n230us # F5W29UA, has problems with the DVD player.  I went to the Device Manager and found the following error code: Windows cannot load the driver for this hardware device. The driver may be corru

  • How to use a date such as 'Today' in a function without listening for the moment on that date?

    I create a todo list. I know I shouldn't but I'm so stuck on this point that I really want to know the answer. At the bottom of my table, I have a footer line in which I want to show the total number of tasks to be accomplished today and every time t