controlling multiple instances of a movieclip

Hi all

I'm new to learning Actionscript and I want to control multiple instances of the same movieclip with the same function.

Here's what I've done so far:

import flash.events.Event;

declare and initialize variables

var growthRate:Number = 2;

var minSize:Number = 1;

var maxSize:Number = 25;

var scaleMode:String = 'grow ';

Loop - add enter event listener of rectangle1_mc movie clip and call growShrink function below chassis

rectangle1_mc.addEventListener (Event.ENTER_FRAME, growShrink);

rectangle2_mc.addEventListener (Event.ENTER_FRAME, growShrink);

function growShrink(e:Event):void

{

If (ScaleMode (ScaleMode) == 'growing up')

{

e.Target.Width += growthRate;

e.Target.Height += growthRate;

If (e.target.width > = maxSize)

{

scaleMode = "shrink."

}

}

ElseIf (ScaleMode (ScaleMode) == "shrink")

{

e.Target.Width = growthRate;

e.Target.Height = growthRate;

If (e.target.width < = minSize)

{

scaleMode = "growing."

}

}

}

What is happening is that the two bodies are starting to animate then it shrinks down to nothing and the other ceases to grow. Can you please tell me what I'm doing wrong?

Thank you

LTA

No, they can all share the same listener function.  but, if you want to grow and shrink independently with each other, each of them need their own ScaleMode (ScaleMode) as shown below.

e.Target is the object that receives the mouse event.  who's going to be something on the stage of your movieclip.

e.currentTarget is the object that has the added listener.  If there is a single shape on the stage of this object, you won't notice any difference between e.target and e.currentTarget.  But if there is more than one child, you will see a difference and e.target is almost certainly not what you want.

import flash.events.Event;

declare and initialize variables

var growthRate:Number = 2;

var minSize:Number = 1;

var maxSize:Number = 25;

Loop - add enter event listener of rectangle1_mc movie clip and call growShrink function below chassis

rectangle1_mc.addEventListener (Event.ENTER_FRAME, growShrink);

box1. ScaleMode = "Grow";

rectangle2_mc.addEventListener (Event.ENTER_FRAME, growShrink);

Rectangle2.ScaleMode = "Grow";

function growShrink(e:Event):void

{

If (MovieClip (e.currentTarget) .scaleMode is "grow")

{

e.currentTarget.width += growthRate;

e.currentTarget.height += growthRate;

If (e.currentTarget.width > = maxSize)

{

MovieClip (e.currentTarget) .scaleMode = "shrinking."

}

}

ElseIf (MovieClip (e.currentTarget) .scaleMode == "shrink")

{

e.currentTarget.width = growthRate;

e.currentTarget.height = growthRate;

If (e.currentTarget.width<=>

{

MovieClip (e.currentTarget) .scaleMode = 'grow ';

}

}

}

Tags: Adobe Animate

Similar Questions

  • Multiple instances of a Movieclip

    Hello! I'm trying to do a drag and drop game, where I do drag the movieclip even several times...

    can someone help me please? How can I do?

    Thank you!!!

    You will have to create new instances of the movieclip.  To do this, click with the right button on the movieclip in the library and select the link.  In the window that opens select the forActionscript option and movieclip in the library name is where it says 'class'... change it to what you want (classes are normally appointed by a letter uppercase leader)... let's you assign a class name of "MyMC".

    To create a new instance of what you need to do is use:

    var newMC:MyMC = new MyMC();

    addChild (newMC);

    and then you'll have to re-branded some event listeners and whatnot that you need for what you plan to do with it.

  • Impossible to find a solution to control the next dates on multiple instances of the entity.

    Hello

    I have a simple scenario. I have two instances of an entity that match two records of a component of bussiness in Siebel. I need to put a validation that the date of the end of an instance is the eve of the start date of the other.

    Using the functions Nextdate() etc. can be useful within the same instance, but the way to check on multiple instances?

    Any suggestion is welcome.

    If you want to exclude from the last instance, there are two options. You can set a Global attribute to the start date of the last session, for example

    the date of beginning of last session = InstanceMaximum (sessions, the start date of the session)

    ... then use this attribute as a filter in your other rules. If there are some things where you want to run the logic on the same subset of instances (e.g., the subset that excludes the last instance), then it might be useful to create an inferred relationship:

    1. in the properties file, create one-to-many relationship overall to the session. (Relationships that will be deducted must always be on many-to-many.)

    2. give the new relationship a unique and descriptive name for example 'the sessions (excluding the last session) '.

    3. write a membership rule to determine which instances of the entity are part of the new relationship, for example

    the session is a member of the sessions (excluding the last session), if

    start date of the session< the="" start="" date="" of="" the="" latest="">

    4. When you want to redo the subset of instances of logic, use the relationship 'the sessions (excluding the last session)' rather than 'the sessions', for example

    the end dates of the sessions are valid if

    ForAll (sessions (excluding the last session), the session end date is certain)

    Using the cross-entity argument version of my example above, the following rule could be set to TRUE:

    the end dates of the sessions are valid if

    ForAll (sessions (excluding the last session), the session end date is certain)

    Whereas this rule would have the value FALSE:

    the end dates of the sessions are valid if

    ForAll (sessions, the closing date of the session is certain)

    I hope that gives you enough to continue their career with your specific scenario!

    See you soon,.

    Jasmine

  • Firefox does not work for multiple instances of the SAME user account on Windows Multipoint Server 2011

    We have a PC HP of MulitSeat MS6200
    It runs Microsoft Windows MultiPoint Server 2011 (which seems to be a twisted version of Windows 7)
    It is implemented in a laboratory of computer science and students connect you using their account for shared room - IE multiple instances of the same user accounts are currently running on the PC at the same time.
    The first student to run Firefox can work with it without a problem.
    However, when another student try to start firefox they get the following message:
    Firefox is already running but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

    Cannot start Firefox using a profile that is already used by someone else.
    Each Firefox instance needs its own profile or you will get this error message.

    Use-no.-line switch remote control to open another instance of Firefox with its own profile and to different instances of Firefox running concurrently.

  • Multiple instances of VBAI

    I know that we can now acquire multiple cameras in VBAI (thanks!).  However, in my view, what to do so leads to very complex control sequences.  It doesn't look like VBAI has fully embraced parallelism for anything other than the FTP transfer.  What should I do if I have 5 cameras GigE each needs to be raised, and where it is possible that two can be triggered at the same time?  Can I run multiple instances of VBAI on a single PC (hey, it's multi-core)?  I predict that the current response is to use LabVIEW, but VBAI is especially LabVIEW... right?

    I want to retain only the simple, single camera, inspections on the PC.  Running multiple instances of VBAI would allow me to devote an instance for each camera without worrying about what's happening on TSF the other 4 (or more).

    No, I have not tried to do it again.  Currently, I am out of town and away from my vision laboratory.  I thought that if this is possible, it is worth mentioning to the public and if it is not, then, it is worth noting in R & D.  The system I'm imagining would be a future version of a system, we finished just where we had 4 NI Smart Cameras and a GigE camera.  The question is on what to do if all 5 GigE cameras.  Don't worry, we still love the SmartCams!

    On a sequence of validation.

    Dan press

    PrimeTest Automation

    Hey Dan,

    Good question! VBAI supports the acquisition of several cameras, even if they are triggered at the same time. We have a flag in the acquisition stage that allows to specify if you want to wait as the following picture or purchase immediately. Thus, in the case simple two cameras triggered at the same time, you will have an initial state who tried to acquire the camera 1 and if there was a timeout he loop back and try again using the wait for the flag of the next Image. When an image is acquired, you know that the other camera was triggered, so you transisition to another State who acquires the camera 2 with an immediate flag, since we know that the image is already there. You can use the image select to switch between the two images, so it is possible, but not necessarily the cleanest. Even if you had two VBAIs simultaneously, synchronizing is not trivial to make sure you weren't inspect imageN camera1 and imageN + 1 on camera2, but perhaps this would not be the cause of your system. In any case, we don't currently support multiple inspections VBAI operating simultaneously on a system, but it is certainly a feature that we know.

    Thanks for your series of validation,

    Brad

  • Update loop under Vi of hand / run multiple Instances

    Hey everybody,

    If I want to keep my code as modular as possible so that I can see any sub or VI.

    One of the SUB vi is permanently offices incase another output is detected. I don't want to make this mark on the main level because I don't want a huge loop in my main.vi and you won't worry about sending shift register valuse to my Subvi for him to function.

    Essentially, I have designed this subroutine Vi and am now trying to constantly be driven from a main.vi

    This hand is simply.

    Cluster of entry--> Sub VI

    Void VI retains a loop waiting for a change request action. Unfortuantely when I change the vale in main.vi the avlues in Subvi don't update. I guess that makes sense, in C, for example when you call Returns you need to wait until the end of the function call to update. Yet, as Labview is so strongly focused on taking SUB vi to do almost everything for you, I can't imagine labview is not able to update these values. I looked around and the answer seems to be global variables. I really don't want to use the because my application will become very big, but I'll use them if I need to.

    Unforunately, when I tried to use my global variable thing, it didn't work.

    1. global Var = Cluster

    2. it's in the Subvi both the main VI.

    3. when I run my code the global variable is not up-to-date on both front sides when I change one of them. I'm doing something wrong?

    A few comments.

    • You have not included the global variable
    • If you want to run multiple instances of the Subvi in parallel, it must be reentrant.
    • As the Subvi is interactive, it must be configured to display the front panel when it is called, otherwise there is no way to stop it ever.
    • All your time loops needed little expects. They have no need to turn as fast as the CPU allows, all other processes of hunger.
    • "Go to under control" is extremely complex and crawling with weird stuff like an ant farm.
      • The shift register must be initialized to avoid surprises (but you probably don't have it all)
      • Your loop runs one time too many.
      • Avoid the stress points, such as the structure of the case.
      • You can replace this whole thing with for example a table of threshold, no need to loop. (see image below).

    Good luck!

  • Workstation 7 on Win7, multiple instances of the taskbar

    When you run VMWare Workstation 7 on Windows 7, VMWare offers systematically there are multiple instances running.  1 for the application itself and 1 for each tab open in the application, regardless of its status running.  It's very confusing when I usually 5-6 tabs open, but only 1 of them is actually being run.  I know there is an icon on the top of each preview indicating if it is suspended or running, but a quick glance, it is difficult to find a case running.

    Is it possible to have only 1 instance of taskbar or display only the virtual machines running in the taskbar, instead of each of them?

    There is no configuration parameter to control the Aero thumbnails, but we had other requests specifically question that makes it more obvious that VMs are suspended and who are running (since they both show a screenshot and are differentiated only by the icon). It is being investigated for a future version of Workstation.

  • Multiple instances of component loader

    Hi everyone, I'm having some problems with the loading component... I am trying to create multiple instances of dynamic loader, but only the last instance shows. I can not understand how to solve this... I already tried to use duplicateMovieClip and he also didin't work.
    This is the code I use, thanks in advance!


    Thank you to all the world, I found the problem.

    old code:
    createClassObject (mx.controls.Loader, "tempLoader" + i, 1, {contentPath: images [i], scaleContent: true, width: 80 height: 60, _x: ((Stage.width-10)-80), FLF: (I * 70)});

    new code:
    createClassObject (mx.controls.Loader, "tempLoader" + I, I, {contentPath: images [i], scaleContent: true, width: 80 height: 60, _x: ((Stage.width-10)-80), FLF: (I * 70)});

    It was o depth problem

  • How can I hide/show toolbar again operate independently on multiple instances of firefox?

    I run two instances of firefox.exe. One for the left monitor and one for the right. There is a toolbar that I want to see on the right screen, but I don't want to see it on the left screen. This used never to be a problem, but it is now. It seems as if well now why show/hide toolbars are inextricably linked, and by changing or watching a toolbar on a single instance simultaneously causes the exact change even on the other open instance. I'm hoping that it could be a simple solution to this effect in the subject: config, however, I would rather not tamper with these settings until I'm sure that settings with the fix for this particular problem.

    Thank you for your attention and for taking the time to read this post.

    Sincerely;
    DC

    Toolbar settings are common to all windows open in this instance of Firefox.
    I don't know if there is an extension that allows to fix this dependent window, so you can check the website of modules.
    If you can't find one then you would use a second instance with its own profile.

    You can add - no.-distance to the command line to open another instance of Firefox with its own profile and run multiple instances of Firefox at the same time.

  • Question about multiple instances of Thunderbird running at the same time

    I read that when you start Thunderbird by clicking on its icon or the shortcut must only load once, even if you click on it several times. It should be just a window of TB. If I click on the shortcut/TB desktop icon, it behaves like that. I can click several times and that a single TB window will open and be active.

    However, if I run the 'quick launch' TB on my windows 8.1 (or no matter what windows) taskbar, I get mulitple TB windows to open, as much as I want. So if I click on TB icon in the quick launch once, I get a single instance of it. Twice, I get two, and etc. In the quick launch any program behaves like that. He starts programs with a single click and launch again and again.

    Only, I click it once and get an instance which is good and how it should be. But this behavior with the quick launch is ok? It must do this not with Thunderbird? Thank you.

    There is usually no advantage by running multiple instances of Thunderbird, unless specifically do you these race with different profiles. In practice, if they are allowed to use the same profile, the first Thunderbird should should acquire the profile and therefore block the others, although this may not become apparent until you try to salvage something, for example, a message, or to change certain settings.

    Your multiple Thunderbird work successfully? They all show the same mixture of accounts, folders and address books? Can all or part of them save and make changes?

    If this is the expected behavior, (i.e. some "typical" windows) I do not like; He does not play well with profile blocking and I think that lead to problems.

  • running multiple instances of VBAI does not work

    Hello everyone,

    We are 4 common examples of VBAI at the same time. Recently, he had to copy it (because production is doubly).

    With our first system, we have no problems when you try to run multiple instances of VBAI. This time, however, it does not.

    Our system:

    • 4 cams: Allied Manta 201

    • camera is triggered (rising edge) separately, but almost simultaneously.

    • Four port NIC (with the right driver :-))

    • 4 ports and our on-noard port are bridged.

    • computer: intel I5 (4 cores)

    • License to run Vision Builder 2012.

    • Programmed with Vision Builder HAVE 2012.

    • Interface programmed in c# (receives images of the relevant info 4 programs and displays on the screen).

    Action taken:

    • Test with our program that opens 4 instances of VBAI. Result: 1 single instance opens.

    • Removed our bridge a connected our cams on a switch. Result: 1 single instance opens.

    • Open VBAI 4 VBAI-programs directly (but separately). Result: Each program opens and is fully working.

    • Open 2 programs at the same time (with VBAI). Result: Fist opens and is equipped with the work. At the opening of the second program, that we get error messages saying that it is not possible to connect with our camera.

    • The test above was created with:

      1. The cam connected to our network card 4 ports.

      2. The cam connected through a switch.

    • I have also written 4 simple programs (just enter a period followed by image)

    • With these programs, I tried the above test (VBAI 2 hours and run both programs at the same time). Same problem: 1programs starts, the error messages when opening a second program.

    I have the impression that it's a network problem, but what bothers me is that, when the bridge, I don't see a difference with our another computer that works on our original assemblyline. When you work on a referral that our parameters are the same as on a computer that does not have a network card 4 ports. The computer (and liked)) allows us to run multiple instances.

    Any thoughts?

    Any help would be greatly appreciated. I'm sure I'm missing something obvious here, but I don't really see.

    If you need more information about something, let me know.

    With sincere friendships.
    Tom Declercq


  • Multiple Instances of the Application to access the same DAQ hardware

    I have a relatively simple application that reads from a device of data acquisition (OR-9205 connected to NI WLS-9163) wireless.  I would like to run multiple instances of the executable, but I get the error-201105 (resource reserved) as soon as the DAQmx task starts on the second instance.  Each instance tries to acquire different channels of the same DAQ hardware.  Is this a problem with the data acquisition device, or DAQmx in general?  Thank you.

    -Joe

    Hey Joe,

    Unfortunately, you can only one type of access channel with each program.  For example, you might HAVE a program access and another use AO, but you can't have two programs different AI the same access card.  It is common among all of the DAQ hardware to NEITHER.

  • get all the screws in memory on multiple instances of application LabVIEW

    I try to get references to all of the screws in memory on multiple instances of LabVIEW application. Specifically, I'm trying to get the VI Refs screw (and their subVIs in memory) in another Explorer of projects at design time. (The other screws do not work.) For example, if you are only interested in VIs in the current instance of App (read the Project Explorer), you can use the following code:

    However, if you have multiple projects open, how can you get the references VI to the screw in the other project? It seems to me that it would be an another App Ref, but I guess I don't know how to get this reference. I'm assuming that if I could get this reference, I could use it in the same way as above for the list of App.AllVIs.

    Any help/clues would be appreciated. Thank you.

    I just tried the code below.  It runs in a single project; I have also open a second project with more than 300 screws and it opens a reference to each one without any error.  Are you the application instance reference wiring open Reference VI?

  • multiple instances of internet explore in my task manager

    Why are there multiple instances of internet explore in my task manager when I open only one page?

    Hello

    IE uses smaller instances of itself to support tabs and correction of errors and it is normal for IE8. In fact
    It uses far fewer resources as well as the opening of 2 or more instances to access several pages. If you
    Open several tabs, and then still more small instances of Internet Explorer will be opened to support these tabs and error correction.

    So basically, everything is normal.

    Multiple Instances of iexplore.exe run when using Internet Explorer 8
    http://www.Winhelponline.com/blog/multiple-instances-of-iexploreexe-run-when-using-Internet-Explorer-8/

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • How can I play multiple instances of video to classic media player in Windows xp help, that I could do so some time! It has to do with the codec? If yes what codec plays multiple instances?

    How can I play multiple instances of video (no problem reading of 12 movies at the same time, at the opening of the 13th film the problem only starts), the classic use of media player in windows XP? I was able to do all the time! It has to do with the codec?
    If yes what codec plays multiple instances of Media Player Classic in windows XP?
    I get the same problem with VLC all that needs to be checked on preferences is checked in the two VLC & MPC!

    Hello

    Multiple instances of Media Player is not supported in version 7 and greater.

    · What version of Windows Media Player you have installed?

    · Are instances that you are referring to the bodies shipped?

    · You use any third-party software to run multiple instances?

Maybe you are looking for