gotoAndPlay multiple movieclips

Im making a gotoandplay function. He plays 2 movieclips at the sametime, but after a few clicks his work stoppages.

is there a way to fix this?

And is it possible to play/stop an object in a movieclip another?

sample

mc_movie. One.addEventListener (MouseEvent.Click, One1);

function one1(e:MouseEvent)

{

mc_movie.gotoAndPlay (100);

mc_button.gotoAndPlay (100);

}

mc_movie. Two.addEventListener (MouseEvent.Click, Two2);

function two2(e:MouseEvent)

{

mc_movie.gotoAndPlay (200);

mc_button.gotoAndPlay (200);

}

mc_movie. Back.addEventListener (MouseEvent.Click, Back);

function back(e:MouseEvent)

{

mc_movie.gotoAndPlay (1);

mc_button.gotoAndPlay (1);

}

If your timeline movement happens to take you far executives where these domestic buttons do not exist, they could lose their event listeners - depends on if they also exist in frameworks where this code does not exist which could be reallocated.

Tags: Adobe Animate

Similar Questions

  • How to drag and drop multiple movieclips at the same time

    Hello world

    I'm a new actonscript 3 and adobe flash CC user and I am building an application but I have been stuck for several days. I have looked everywhere and tried everything I could think of, but I can't yet find a solution to my problem that I thought were pretty basic.

    Basically, let's say I have a rectangle and a circle on the stage. Once I did of the movieclips and assigned an instance name to each of them, I want to be able to perform a drag and drop the Rectangle so that both the rectangle and the circle become movable at the same time.

    For now, I have a mouse down events listener associated with the instance of rectangle, a method startDrag assigned to the rectangle instance and another assigned to the circle. But in this configuration, when I click on and drag the rectangle, only the circle is mobile (only the last line in the code is taken into account).

    I don't know if what I'm trying to achieve is feasible, but any help will be greatly appreciated, thank you!

    The startDrag() method can only work for one object at a time, so in your case the Treaty the last of them, designated the task.  This approach is to temporarily to plant the two objects in a container and then drag the container.

    rectangle.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag);  When I click on the rectangle

    var dragMC:MovieClip = new MovieClip();
    addChild (dragMC);

    function fl_ClickToDrag(event:MouseEvent):void

    {
    dragMC.addChild (rectangle);        move objects in the container
    dragMC.addChild (circle);
    dragMC.startDrag ();
    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop); When I release the mouse button

    function fl_ReleaseToDrop(event:MouseEvent):void

    {
    dragMC.stopDrag ();
    Rectangle.x += dragMC.x;         Adjust the positions of the objects to their new location
    Rectangle.y += dragMC.y;
    Circle.x += dragMC.x;
    Circle.y += dragMC.y
    addChild (rectangle);                 move back to the scene objects
    addChild (circle);
    dragMC.x = dragMC.y = 0;       reset the benchmark for the dragMC
    }

    All this stuff of repositioning in the Drop function is necessary because when you drag the container, the positions of the content are still on their original coordinates inside the container.  So when you drop them they will resume their x / y positions in their new parent, meaning they go back where they were.  Reposition them where they have been trained to take into account the change in the position of the dragMC.

  • Remove the eventlistener for multiple movieclips in a table

    Hi all

    Game scenario:

    I do a crossing road learning alphabet game. In the first level there are 10 alphabets tell of A J (movieclips) stand on one side of the road in a mixed random way. The player must move the alphabets (using the keyboard commands) in alphabetical order, so that it strikes at the entrance of a kindergarten and is removed from the scene.

    Situation-problem:

    If you click on the correct alphabet the player gets a positive score. And if the wrong alphabet is cliked, a negative score is given. This works well for the first alphabet, but, once the first alphabet hits its target and is removed from the scene, it does not work for the next alphabet since removeEventListener to the case the first alphabet code continues to work for the continuous alphabets.

    For eg., once the first alphabet "letA" is removed from the scene, and then when I click on "Letbs" that gives a score to both positive and negative. Positive note, since it is the next alphabet that must be clicked. Negative note, since the "wrongClick" table contains the movieclip 'Letbs', although it was intended for the situation, when "letA" was also present on the stage.

    Code:

    var wrongClick:Array = new Array (Letbs, THG, letD, summer, fall, letG, letH, letI, letJ);

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

    wrongClick [i] .addEventListener (MouseEvent.MOUSE_DOWN, negScore);

    function negScore(e:MouseEvent):void {}

    gameScore += pointsForMiss; showGameScore();

    wrongClick [i] .removeEventListener (MouseEvent.MOUSE_DOWN, negScore);

    }

    }

    Requested solution:

    Can someone please tell me how I can write code that, once an alphabet is removed from the scene, the method addEventListener for above of movieclips is completely removed and a new addEventListener starts to work for the rest of the alphabet which remain on stage.

    thnx in advance

    Kind regards

    Ginette tabriz

    run this code:

    for (var i = 0; i)

    wrongClick [i]. delete EventListener (MouseEvent.MOUSE_DOWN, negScore);

    }

    When the correct letter is clicked.  That is to say, in the correct letter listener function.

  • Referencing of multiple movieclips that have similar names of instance

    I have a player movieclip and six movieclips obstacle with the name of "obs1',"obs2"instances, up to"obs6 ". If the player hits one of the obstacles, the death of variable is set to true. The code I have so far is:

    If (hitTest (_root.obs1) | hitTest (_root.obs2): (_root.obs3) hitTest | hitTest (_root.obs4) | hitT's (_root.obs5) |) {hitTest (_root.obs6))}

    dead = true

    }

    Since if the statement is bad enough as it is, I wanted to know if it was possible to reference all movieclips with instance name 'obs' followed by a digit. In my view, that it's hooks, something like:

    hitTest (_root.obs [i])

    Can someone give me some advice?

    (I use Flash CS3 and ActionScript 2.0)

    for (var i: Number = 1; i<>

    {if (HitTest (_root ["OBS" + i]))}

    dead = true;

    break;

    }

    }

  • multiple movieclips and mutiple event management.

    Hi all

    I have several movieclips (image sequence), which I want to add (click and drag), mouseevent event (left and right arrows) to the keyboard and the zoom event (mouse wheel).

    I have this function for one mc (image sequence).

    Now, if I use this function, I have some problem with the call of the function of the same frame.

    It's

    If click on an other mc in frame 3 say, click on another function, it should continue to frame 3 only, not from the first image again.


    Help, please.

    Thanks in advance.

    I guess that shows the part where you vortag home discovered in a 360-degree mode?

    If so, do a global var on your root timeline:

    var rotationframe:int = 1; at the beginning of the application, all dirffernt images are sitting on frame 1

    You can access this var to anywhere inside any function of your application by calling:

    root.rotationframe

    now in the service which manages the rotation (lets say its your keyboard function) at the end (after you have moved the playback cursor), you ensure that you always set

    root.rotationframe = garage.currentFrame;

    and in the service that manages switching between images write you sth. as

    gotoAndStop (root.rotationframe);

    Be aware, you cannot simply use this code without adapt it to your specific needs.

  • Simplify multiple movieclips early frame masking

    I am trying to simplify my code and save space in my control panel actions.  At the beginning of a new mount, I have several hidden clips (._visible = false) until I call so that they become visible later.

    This framework AS I will condense:

    MC1._visible = false;

    MC2._visible = false;

    Mc3._visible = false;

    ... etc.

    I have about 30 MC # movieclips.  Can anyone show how to shorten the code so all 30 mcs are hidden you enter the picture?  A table perhaps?

    Thank you.

    There is no need of an array, but you use array notation:

    for (var i: Number = 1; i<>

    This ["MC" + i] ._visible = false;

    }

  • a multiple movieclips class

    Hello

    Yet once I fell on the dilemma of having a class on a Movieclip a desire then to use the same class on another clip. He put on another library attached does not work. I tried to use a class that extends my class but that extends a class extended movieclip seems misleading in flash.

    Is there a clean way without reprogramming of my class to do? Or I copy my class several times with a different name?

    TIA

    The class for Content1 was Content1 and its basic ContentFader class. Same Content2 is class: Content2 and the Base of the ContentFader class.

    Then just to mix it up a little. I created a Content1.as file, but none for Content2. Everything works as I expect.

    I guess it's as all y ' All thought that the base class meant something other than what I think he means? If that were the case it should say DisplayObject or actually all the object.

  • Realistic of the random movements of multiple MovieClips

    Hi here is my code:

    30 images/s

    var human = 30;

    hSpeed var = 4;

    for (i=0; i<humans; i++) {
         //attach movieclip with name "human"
         //give it a random x y position (there are now 30 scattered human MCs)
         _root["human"+i].onEnterFrame = function() {
              this._x += random(hSpeed); //Here is the 'random' movement of the Movieclips
              this._x -= random(hSpeed);
              this._y += random(hSpeed);
              this._y -= random(hSpeed);
                   //some more code
         }
    }
    

    Makes the jitter movieclips on, humans don't do that, I can't find a way to make their random movement still smooth, moving in a random direction for a few seconds (preferably a random amout of seconds), then to change direction - I found a way to do it but it does not work on individuals It works on all 30 movieclips, which means that all move in the same direction.

    Don't forget that the movement must be random for each individual movieclip, not all move in the same direction.

    Does anyone know how? Thank you

    If you want to maintain the movement in a random direction for some time, then you're probably better using code interpolation.  Generate interpolations for each object that moves them from their current position to some random in some random delays.  And have a listener that determines when the Tween is complete so that a new Tween is engaged with the new direction and speed (time).

  • detect clicks on multiple movieclips

    Hello

    Thanks for your time, read this.  I'm hard-pressed to find ways to detect clicks on various movieclips that I'm generation.   Basically, I am allowing to set a number any instances of the same clip.   I would like each instance A) be clickable and B) pass the reference to the click handler.

    For example, I have something like this:

    function addMissile() {}

    this.attachMovie ("missile", "missile" + mtop, this.getNextHighestDepth (), {_x:startx, _y:starty});})

    activeMissiles [mtop] = _root ["missile" + mtop];

    .focusEnabled activeMissiles [mtop] = true;

    Selection.setFocus (activeMissiles [mtop])

    MTop ++

    }

    I would like to add a reminder on click for each of these instances of clip.   Grateful if someone can point me in the right direction

    Best regards

    Tom

    You can use:

    function addMissile() {}

    var mc:MovieClip = this.attachMovie ("missile", "missile" + mtop, this.getNextHighestDepth (), {_x:startx, _y:starty});})

    activeMissiles.push (this ["missile" + mtop]);

    or better yet:

    activeMissiles.push (mc);

    mc.focusEnabled = true;

    Selection.setFocus (mc);

    mc.missileIndex = activeMissiles.length - 1;

    mc.onRelease = function() {}

    trace (this ._name + ":" + this.missileIndex);

    }

    }

  • Detection of collision, multiple movieclips, auto collision.

    Here is my code to attach several clips on the stage

    var humans:Number = 90;
    for (i=0; i<humans; i++) {
              mcHuman = attachMovie("mcHuman", "mcHuman"+i, i);
    //blah blah
    }
    

    Whatever happens, it seems impossible to detect collisions between mcHuman and mcHuman...

    Anyone have any ideas?

    Thank you.

    There is probably more code that you realize that there are, but it is up to you to decide.

    Your first not set of loops make sense, just a loop is necessary as you had originally.  This might be a reason for things to go crazy.

    As regards the enterframe function goes, you have an excess of braces in this document, which could also be a reason for things to go crazy.  In addition, if you do not move humans at all (your code does nothing to move as it is), the you do not want or need the function enterframe no more...

    humans var = 90;

    for (i = 0; i

    mcHuman = attachMovie ("mcHuman", "mcHuman" + I, i);

    mcHuman._x = random (Stage.width);

    mcHuman._y = random (Stage.height);

    mcHuman.xTarget = random 20-10;

    mcHuman.yTarget = random 20-10;

    }

    for (i = 0; i

    for (j = 0; j

    If (_root ["mcHuman" + i] .hitTest (_root ["mcHuman" + j])) {}

    trace ("hit!");

    }

    }

    }

  • Multiple MovieClips with the same instance name

    I'm a tutorial of defence tower and part of the code is set up so I can build towers in the video for "grass". I wanted to add patches more 'grass' and gave them all the same instance name so I can be able to place towers on them, but I have the problem that I can only place towers on the first point, I placed and bears the name of the instance of the "grass". I can't place towers on the other patches of grass.

    I removed the name of the instance of the first patch of grass and it let me build towers on the second task, but the second patch only.

    I followed this tutorial: http://www.goofballgames.com/2010/01/31/how-to-build-a-tower-defense-flash-game-part-2-pla five-tours /

    Here's the code for what I believe:

    onClipEvent (load)
    {
    Active = 0;
    }

    onClipEvent (enterFrame)
    {
    If (current == 1)
    {
    setProperty ("", _x, int ((_root._xmouse-10) / 20) * 20 + 20 ");
    setProperty ("", FLF, int ((_root._ymouse-10) / 20) * 20 + 20 ");

    hitTestOnGrassMovieClip = _root.grass.hitTest (_x, FLF, 1);

    If {(hitTestOnGrassMovieClip)
    gotoAndStop (1);
    _root.Ranger.gotoAndStop (1);
    }
    else {}
    gotoAndStop (2);
    _root.Ranger.gotoAndStop (2);
    }

    _root.Ranger._x = _x;
    _root.Ranger._y = FLF;
    _root.Ranger._width = donut _root ["tower_" + round] * 2;
    _root.Ranger._height = donut _root ["tower_" + round] * 2;
    }
    }


    (press)
    {
    hitTestOnGrassMovieClip = _root.grass.hitTest (_x, FLF, 1);
    hitTestOnDeSelectMovieClip = _root.deselect.hitTest (_x, FLF, 1);

    If (hitTestOnGrassMovieClip: hitTestOnDeSelectMovieClip) {}
    If {(hitTestOnGrassMovieClip)
    ++ _root.towerCount;
    _root ["tower_" + round] .duplicateMovieClip ("t" + _root.towerCount, 500 + _root.towerCount);
    a = _root ["t" + _root.towerCount];
    a ._x = _x;
    a ._y = FLF;
    a.active = 1;
    }

    Active = 0;
    setProperty ("", _x, 1000);
    _root.selectedTower = "";
    _root.Ranger._x = 1000;
    _root.Ranger._width = 10;
    _root.Ranger._height = 10;
    }
    }

    1. you cannot use the same instance name for different objects and expect more from a being targeted.  You must assign a unique name, or you can store references to them in an array and use the table to target.

    2. you send AS2 code messages in the forum of AS3.  You should repost in the AS2 forum.  http://forums.Adobe.com/community/Flash/flash_actionscript

  • This code can be shorted out? It's a small function

    Hello

    Oke, here's what I'm trying to do. I have attached multiple movieclips on the stage.
    Now I want when rolling on the gotoAndPlay (2) of movieclips.
    It works, but in order to type this to over 30 clips... is there not a shorter way to do this?

    This is code that I use to use the animated button over and over again.

    This.tegels1.onRollOver = function() {}
    tegels1.gotoAndPlay (2);
    }
    This.tegels2.onRollOver = function() {}
    tegels2.gotoAndPlay (2);
    }
    This.tegels3.onRollOver = function() {}
    tegels3.gotoAndPlay (2);
    }
    This.tegels4.onRollOver = function() {}
    tegels4.gotoAndPlay (2);
    }
    This.tegels5.onRollOver = function() {}
    tegels5.gotoAndPlay (2);
    }
    This.tegels6.onRollOver = function() {}
    tegels6.gotoAndPlay (2);
    }
    This.tegels7.onRollOver = function() {}
    tegels7.gotoAndPlay (2);
    }

    This.tegels8.onRollOver = function() {}
    tegels8.gotoAndPlay (2);
    }

    .. I stopped typing... I should write this to 30.

    Does anyone has an idea to make it be shortened?


    for (i = 1; i == 8; i ++) {}
    var curClip:MovieClip = this ['tegels' + i]
    curClip.ID = i;
    {curClip.onRollOver = function ()}
    this.gotoAndPlay (2);
    }
    }

    That's all. Make sure that all 8 clips exist when this code is executed. And if content externally is loaded then then it will disappear.

    I also added a property ID to each element that it will be easy to perform specific actions based on the interaction with these clips. Suppose that each clip must say a main staple to go to a specific farm, tegels1 go to frame 1, tegels2 image to access 2 and so on. Then you add this to the loop for:

    {curClip.onRelease = function ()}
    mainClip.gotoAndStop (this.ID);
    }

  • How to use the root in flash AS2

    I have a clip within the clip, so I have a button, but how to make the button work on my main timeline, I can jump to another party on the main timeline

    You can use:

    _root.gotoAndPlay (); main timeline

    and

    _parent.gotoAndPlay (); parent movieClip

  • object null reference problem

    Hello all and first of all thanks for reading,

    My problem is this, at my request, I have a textfield located at,.

    This.wholesite_mc.explan_mc.e_mc.cap_talk_txt. Text

    now, normally I can access this text and change it whenever I like using the

    MovieClip (parent).e_mc.cap_talk_txt.text = ""

    and so on

    problem is that I have a help file, which is located in the library and added using addchild().

    When you click on the help icon this function runs

    function helpvisit (): void {}
    btn_help1_mc. Visible = false;
    btn_help1_mc.btn_back_mc.mouseChildren = false;
    btn_help1_mc.btn_replay_mc.mouseChildren = false;
    btn_help1_mc.btn_back_mc.buttonMode = true;
    btn_help1_mc.btn_replay_mc.buttonMode = true;
    btn_help1_mc.btn_back_mc.addEventListener (MouseEvent.CLICK, bclicked);
    btn_help1_mc.btn_replay_mc.addEventListener (MouseEvent.CLICK, rclicked);
    btn_help1_mc.btn_back_mc.addEventListener (MouseEvent.MOUSE_OUT, fighting);
    btn_help1_mc.btn_back_mc.addEventListener (MouseEvent.MOUSE_OVER, bover);
    btn_help1_mc.btn_replay_mc.addEventListener (MouseEvent.MOUSE_OUT, rout);
    btn_help1_mc.btn_replay_mc.addEventListener (MouseEvent.MOUSE_OVER, rover);

    MovieClip (this.parent).e_mc.menubar_full_mc.visible = false;
    jigh10_mc.gotoAndPlay (2);
    MovieClip (this.parent).e_mc.cap_talk_txt.text = "";
    MovieClip (this.parent).e_mc.cap_talk_txt.text = "allows to count the bombs on this piece together!"
    }

    fine so far

    inside the MC aid, there is a clip called jigh10_mc

    and on some images in this example, 247

    I have the following

    MovieClip (parent.parent).e_mc.cap_talk_txt.text = "number of bombs on this piece is ten, you see where it fits on the left?

    Now whenever I run it, everything's fine except that I get an error in the output window saying

    TypeError: Error #1009: cannot access a property or method of a null object reference.

    at::jigh10_mc_92/frame247() [wholesite3_fla.jigh10_mc_92::frame247:1] wholesite3_fla

    I would appreciate any information, that you may have on how to solve this problem.

    ive tried to use functions and counters in jigh10_mc that point to the parent who then replaces the text but I still got the error

    the code seems to run even if I'm not in the help section, as lightning will complain of the same mistake while I'm game section

    Thanks in advance

    fonzio

    When you 'addChild (helpFile)' you can try:

    helpFile.addEventListener (Event.ADDED_TO_STAGE, added);

    added function (e: Event) {}

    trace ("I just added myself to the scene and now I can meet the functions")

    helpFile.removeEventListener (Event.ADDED_TO_STAGE, added);

    do other things now

    }

  • loadClip() with onLoadError()

    In my application using loadClip() to load multiple images and I also use the onLoadError(). I have attached a movieclip inside onLoadError(). Thus, whenever the loadClip() fails it will call the onLoadError(). But if several images loaded fails, the same number of time onLoadError() is called .so multiple movieclip is attached. My requirement is, once that if I get an onLoadError() the loadClip() process should stop.

    Ex:

    for (var i = 0; i < my_array.length; i ++)

    {

    MC = _root.createEmptyMovieClip ("mc" + i, _root.getNextHighestDepth ());

    mcLoader.loadClip (my_array [i], mc);

    }

    objListener.onLoadError = function(Mc:MovieClip)

    {

    _root.attachMovie ("alert_mc", "msgMc", _root.getNextHighestDepth ());

    }

    can someone help me...

    var i: Number = 0;
    loadF();

    function loadF() {}

    MC = _root.createEmptyMovieClip ("mc" + i, _root.getNextHighestDepth ());

    mcLoader.loadClip (my_array [i], mc);

    }

    objListener.onLoadInit = function (.): Void {}

    i ++ ;

    If (i<>

    loadF();

    } else {}

    loading completed without error.

    }

    }

    objListener.onLoadError = function(Mc:MovieClip)

    {

    _root.attachMovie ("alert_mc", "msgMc", _root.getNextHighestDepth ());

    }

Maybe you are looking for

  • Operating system not found on Toshiba NB250

    Hi all I have bouth Toshiba NB250 with legal Windows 7 Starter. 2 days ago I was on the internet my Nooteboom gel and I decide to reboot. I restart and OMG - there was only a black screen with cursor flashing after then it shows me that "the operatin

  • No screws daqmx in labview 2014 64 bit

    Hello I have daqmx 14.0 installed on my Win 64 bit PC and LabVIEW 2014 SP1 32 bit. Today I installed LV 2014 64-bit on my PC and I don't see any DaqMX screws under the section i/o measure. And when I opened my project compiled in 32-bit LV 2014 then

  • install RAM in HP Pavilion 15 - p055TX

    I want to install another module of RAM of 4 GB.  You have all the instructions on how to do (written or video). Thank you.

  • UNIDENIFED VISTA 64-BIT AND LOCAL ACCESS NETWORK

    I can connect to the e wireless network but it will not identify the network and it also mentions that the default gateway is offline, when I run the connectivity test. Can anyone help?

  • How to disable the right click menu of office options in windows 7 64 bit PC?

    On right-clicking on the icon/file on the desktop, we get several options such as open, open with, cut, copy, delete, rename, scan with etc.; There's also the uninstalled software options - such as video to convert. Scan with NPAV. I want to know how