controlling multiple symbols in as2

I do pacman in as2 for fun, and I was wondering how to get several pellet mc' hittest to work. I tried to make a loop for which went through each of the balls by number i.e. pellet [i] in a loop with each ball in number pellet1 pellet2 pellet3 so on... I tried to put in the first frame of the FLA in an enter frame function just by itself.

Y at - there anytway for a loop to work like that or do would be another way to you reccomnd each pellet?

Code:

with (_root) {}
for (i = 0; i > = 3; i ++) {}
If (pacman.hitTest (ball [i])) {}
Ball [i] ._x = - 5;
score += 10;
}
}
}

This ["ball" + i]

Tags: Adobe Animate

Similar Questions

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

    }

    }

    }

  • best practices for the structure of the code control multiple devices in a sequence-step 2

    I have a question about code architecture and to get multiple devices controlled and synchronized for an experience. It is an 'architecture' - type application, so I hope for some suggestions on how to proceed.

    I run an experience in which I order 2 NI PCI-6733. I will soon add a Tektronix AFG 3022 B and have long been turned off the opportunity to rewrite my code labview from the ground upward. I inherited from a previous search, and although functional, I want to make it easier to modify and divide into sub - VI and these. Link to the current program (labview 8.6.1) is here if you do not want to see the code that is currently used and Subvi is in a zip file. The current version of experience consists of one stage, all writing the data for PCI cards is saved for the end. I need to change that in my configuration again well.

    The new experience consists of 2 steps. The first will take place (loop an array of output for PCI cards) until he heard a 'real' another computer (connected via TCP). When you do that, it should go to step 2 and run a sequence (usually 10 ^ 5 timeunits of length, where the unit of time is 0.1 ms) which refers to two PCI, the AFG 3022 B cards and with the flexibility to add more devices in the future.

    The most popular would be structural advice. How to organize the screw, if it's good to use a VI 'master' that would control the two sub - VI phase 1 and 2, etc...  Feel free to ask for more details if it helps clarify my question. Thank you!

    Such programs typically use a kind of State machine.  You will find many tutorials on LabVIEW state machines in these forums or forums of LAVA.  If you do a rewrite, I also recommend that consider you the LabVIEW classes.  They help modularize your code and do more reusable subparts.  You can end up with less to maintain, accordingly.

    You can also consider TestStand.  It was designed to perform sequences of tests, so can make your life easier.  It would be also exaggerated gross.

    Let us know if you encounter any problems with the machinery of State or classes.

  • is bindElementAction to multiple symbols?

    I am very new on board animate and jquery, so maybe that's a stupid question but I can't understand the syntax to include multiple objects in a 'bindElementAction '.

    For example, if I want to add a 'click' to a single object, the generated code is

    Symbol.bindElementAction (compID, NomSymbole, "${_option1}", "click", function (sym, e) {})

    things here

    });

    But I take a multiple choice quiz, so I want to be able to apply the same actions to the four symbols option (option 1, option 2, etc.) at once, without having to copy and paste the block preceding three times.

    If your buttons are in a symbol that you use the correct scope:

    {sym.getSymbol("question").$("__choice1__").bind ('click', function ()}

    CODE HERE

    });

    {sym.getSymbol("question").$("__choice2__").bind ('click', function ()}

    CODE HERE

    });

    {sym.getSymbol("question").$("__choice3__").bind ('click', function ()}

    CODE HERE

    });

    {sym.getSymbol("question").$("__choice4__").bind ('click', function ()}

    CODE HERE

    });

  • Control a symbol by a button inside the symbol

    I hope that this explanation makes sense:

    I have a file with buttons on the main stage that control symbols.

    (buttons are circles labeled 1876 and 1877)

    The symbols just move a PNG on and off the stage.

    For example, the two circles called 1876 and 1877 are PNG files to create buttons that control two different symbols.

    Symbols of moving the image of dashboard on and off the stage.

    In the Bulletin Board image is an X, I'm hoping to put a button on top of the side to close the symbol.

    scoreboard1.jpg

    The code I use to move the symbols on the stage and is:

    var = sym.getVariable ("current") courses;

    If (current! = "") {}

    sym.getSymbol (current) ("out") .play;

    sym.getSymbol("syboard1876").play ("in");

    }

    else {}

    sym.getSymbol("syboard1876").play ("shortIn");

    }

    sym.setVariable ("current", "syboard1876");

    syboard1876 is the png of green card.

    No idea how I can get the symbol to move off the stage by pressing on it?

    And that I'll be able to have several buttons under the symbol (which are hidden under the b = green card when it is visible)?

    This is the original tutorial that I adapted the EEG of the animation to work so far.

    Tutorial: Relying on the independent symbol a calendar «Adobe Edge leading Team Blog»

    Now, I just need to find a way to give the user the possibility to use the X to close the symbol.

    Any suggestions?

    1. you could use $each () with jquery in compositionReady
    2. If not you need to go back to the stage with sym.getComposition () .getStage () or
    3. You can use this in compositionReady

    function useButtons (element) {}

    {sym. $(element) .bind ("Click", Function ()}

    SYM.$('image').Attr('src','images/'+element+'.PNG'). CSS({"Opacity":1.00});)  This is an example of code - I used the same name for the buttons and image names.

    });

    }

    Add here the names of button

    ["," "," "] .forEach (useButtons);

  • Click on the multiple symbols to trigger an action.

    Hello

    I create a list of interactive control which requires that all of the check boxes on a page to check. On each page there is a list of boxes that need to be verified and master list on the side. Once you have checked all the boxes (symbols) on the page, the box of coresponding to the page in the main list would also get a check. Somehow, I need to connect all of the checkboxes in the list so that once they are all checked, the correct area in the main list would get a check.

    Screen Shot 2014-03-28 at 10.43.23 AM.png

    So far I put it in place so that every page is a symbol, use the next and previous buttons and I have created symbols that function as check boxes.

    Thank you in advance for any help you can offer.

    B.

    Ok. I got that it works like a charm. Thanks for your help!

    Here is a link:

    http://dev.speakdesign.com/Sage/13-03599/checklist.html

  • Control multiple LEDS with PWM

    I'm designing an application that sequencely 6 LEDs, lights each LED operaters in periods of 10 ms, and then are the rest of the time. To control the intensity of the LED in the 10 ms period I want to use a PWM signal.

    Any suggestions?

    Hello kjschmidt,

    I made a simple example to illustrate what is happening.

    Please let me know if everything is understood from this example.

    I tried any document that seems to require an explanation.

    Any attached Code is provided as is. It has not been tested or validated as a product for use in a deployed application or system, or for use in dangerous environments. You assume all risk for use of the Code and the use of the Code is subject to the license terms of Sample Code which can be found at: http://ni.com/samplecodelicense

  • The linker error multiple symbol definitions

    Hello

    I brought a DAQmx project based on Linux to LabWindows CVI 2012 PXI. After completing all the requirements of the conversion and compile successfully, I'm getting tons of the following linker errors for different modules files (just stick

    a subset of these here):

    Several definitions of symbol '_PtrToPtr64' in modules X and Y

    Several definitions of symbol '_Ptr64ToPtr' in modules Z and Y

    Several definitions of symbol '_HandleToHandle64' in modules X and Y

    Several definitions for the "_HEAP_MAKE_TAG_FLAGS" symbol in the modules X and Y

    Several definitions for the symbol '_TpInitializeCallbackEnviron' in modules X and Y

    .....

    I found this message: http://forums.ni.com/t5/LabWindows-CVI/CVI2010-clang-link-errors-with-Windows-SDK/td-p/1425690

    that points to a known issue in CVI 2010. However workaround (allowing the C99 compilation option) is already defined in my project, so this solution does not apply.

    Any idea what could cause these symbols windows.h get redefined?

    Thank you

    Some of the Windows SDK functions, can have the same name as the functions of LabWIndows/CVI. Is your Windows.h file before all the other header files? See the following article for more information: http://digital.ni.com/public.nsf/websearch/69C82671913CAA4986256E9400676E17?OpenDocument

  • Control multiple devices using the PCI-8430/8

    Hello

    We have a few questions about the control of several equipment in series with the PCI-8430/8. I'm sorry if here is not the right place to post these questions.

    The goal is to control flow valve 6 magnetometers at the same time, each magnetometer has a RS 232 interface and baud rate of 300 to 72800 (in general, we use 9600).  Task includes the issue a few commands to config and continually read data of magnetometers in the defined format.

    Software platform: WINDOWS XP/32, C/C++

    (1) is it feasible with the PCI-8430/8? What is the highest baud rate, if all six magnetometers are running simultaneously?

    (2) are there similar to our task example codes? I found a C:.../National Instruments\NI-VISA\Examples\C\Serial\RdWrtSrl.c but I don't know if it's the right thing first (I have some experiences on programming via DAQmx DIO, but not with serial number).

    Thanks a lot for your time!

    Kunyan

    Hi eLions,

    (1) the baudrate on each channel, each channel can support max flow.

    (2) the USB-232/4 is only a single USB port that breaks in 4-port series.

  • Exchange multiple symbols at once on a layer

    Hello

    I often just copy a sequence of images that already have the interpolation I want and it uses 4 instances of a symbol.

    When I copy and paste images on another layer, I just want to change the symbol, but I need to select a time and sharing the symbol.

    Is anyway to have a layer to modify all instances of one symbol to another at the same time?

    Thank you

    Babs

    If it is a motion tween, you can click on any pair of interpolation and swap symbol. If it's a classic tween, you can edit several images, marker will all, select all (lock other layers first) and then make an Exchange at once.

  • Controlling multiple virtual machines on multiple hosts?

    Hello

    My apologies for what will clearly be a newbish question because I just started using PowerCLI yesterday. I have 6 servers hosts with 10 virtual machines on each and every VM with a snapshot.

    I created a script for

    (1) connect to Host #1

    (2) to reset all 10 VMS to the snapshot (a)

    (3) power on all virtual machines (simultaneously)

    (4) connect to the host #2... Rinse and repeat at host #6.

    It takes a little more than 5 minutes. I'm sure that this process will speed up if I find the answers below:

    Two questions:

    There's a way to connect to all servers at the same time, so can I have step #3 works on all servers host 6.

    -Is it possible to have the step #2 run simultaneously on each host to save on time?

    Thank you very much!

    With the Connect-VIServer cmdlet, you can connect to several servers in vSphere.

    Only condition is that you can use the same credentials, or this UNIQUE authentication is implemented.

    When you switch to view "multiple" with the Set-PowerCLIConfiguration cmdlet, you can run cmdlets against all those servers at the same time.

    You can now do a 'Get - VM"which will return all the virtual machines on all connected servers vSphere.

  • Control a symbol from another timeline specific condition symbol scenario

    Hello! I have 8 animated symbol that plays on clicking them on the main stage and I want to, for example, if the symbol 1 animation is complete and I click on side 3, symbol 3 forward and symbol 1 plays on the back and vice versa like this: http://www.framefarm.net/eugenio/edge/example/example.html

    Help, please!

    as I told you before http://forums.adobe.com/thread/1224255?tstart=0 , you have to do what I said in this post

    I looked at your project and you just copy paste my sample code to your project and therefore, I saw he did not work for you

    You must change the value of width and height with yours and check the symbol names and match them with your because EA use JS and JS is Case Sensitive

    and if your symbol name is Symbol_1 and you use symbol_1 it would not work, and if you do what I said carefully that you can create your own dynamic menu, I can create this menu you is very easy for me, but I want to help you by yourself to learn how to work the border...

    I'll try my best to help you create your menu, if you have a problem let me know

    Zaxist

  • The main time line control Movieclip symbol.

    I am new to AS3. So what I did, is to create 3 buttons on the main timeline, each button will be goto a framelabel/keyframe. Presents all works, however in this picture-key, I have a symbol with a FLV video integrated in it. I want to push a button on the main timeline, goto that keyframe and the film plays. So far it works, the problem is I want to stop the movie when I slect a different button. If I select a different button, the film continues to play and if I hit this same but go back t the film, then the film begins to play and I have 2 bodies playing at the same time. I tried to get here, but I can't seem to find anything like what I'm doing.Untitled-2.jpg

    So here is the main scenario, I have 3 buttons on the layer of the menu and the content of separte on each of the 3 images to label points.

    Untitled-3.jpg

    As you can see I have a video flv embedded in a symbol (type Movie Clip), so when I select button 2 he goes and plays the movie, but when I select key 1 or 3 to change the setting up, the film continues to play in the background, (I can hear the audio), was hoping someone can tell me how to add code to stop this When I select another button below is my code that I have now,

    Untitled-4.jpgUntitled-5.jpg

    Here you can see that the video is embedded in the movieclip. I do this because I want to have only 1 file, I don't want an external file. I am trying to create a mobile app, so I want only 1 file.

    Any help is greatly appreciated.

    use:

    Stop();

    var point: point;

    btn_page1.addEventListener (MouseEvent.CLICK, onPage1);
    btn_page2.addEventListener (MouseEvent.CLICK, onPage2);
    btn_page3.addEventListener (MouseEvent.CLICK, onPage3);

    function onPage1(event:MouseEvent):void
    {

    removedotF();

    gotoAndStop ("page1");
    }
    function onPage2(event:MouseEvent):void
    {
    gotoAndStop ("page2");
    dot = new Dot;

    addChild (dot);
    dot.x = 10;
    dot.y = 10;
    }

    function removedotF (): void {}

    {if (dot)}

    dot. Stop();

    removeChild (dot);

    dot = null

    }

    }

    function onPage3(event:MouseEvent):void
    {

    removedotF();

    gotoAndStop ("page3");
    }

    p.s. Please check the useful/correct.

  • control multiple instrument via one rs232 port

    How can I connect rs232 port unique to several temperature controller that has a different address for each. is this possible?

    moshez wrote:
    How can I connect rs232 port unique to several temperature controller that has a different address for each. is this possible?

    I did it with these. Knowing what the switch is in the on position is important in order to send the bit to the correct address. Difficult but doable.

  • Dynamic action - control multiple non-null

    Hello

    I have a requirement that only if the two elements (P3_ITEM1 and P3_ITEM2) are not null, then the button should display.

    When I create a dynamic as action below

    Event = > release button

    Items = > P3_ITEM1, P3_ITEM2

    State = > is not null

    Show the button with a false action as well.  The sample is here https://apex.oracle.com/pls/apex/f?p=62495:3:

    But in this case, the condition does not work as I want. If one element is not null indicates the button. If I give Expression Javascript as a condition with $V ("P3_ITEM1")! = null & & $V ("P3_ITEM2")! = null is also not working.

    Can someone help me with this.

    Thank you.

    Hi Benjamin-Oracle,

    Jeremiah-Oracle wrote:

    I have a requirement that only if the two elements (P3_ITEM1 and P3_ITEM2) are not null, then the button should display.

    When I create a dynamic as action below

    Event-online unlock key

    Elements-online P3_ITEM1, P3_ITEM2

    Condition => is not null

    Show the button with a false action as well.  The sample is here https://apex.oracle.com/pls/apex/f?p=62495:3:

    But in this case, the condition does not work as I want. If one element is not null indicates the button. If I give Expression Javascript as a condition with $V ("P3_ITEM1")! = null & $V ("P3_ITEM2")! = null also does not work.

    Try with Condition = Javascript and JavaScript Expression Expression as:

    ($("#P3_ITEM1").val().length > 0 && $("#P3_ITEM2").val().length > 0)
    

    Kind regards

    Kiran

Maybe you are looking for

  • Always full of storage

    I have a problem with my storage is always full even though I deleted almost all applications including whatsapp and also reset the settings, nothing has worked with me

  • Satellite A110-275: digital recording of cassettes

    I have a Sat Pro A110-275. Nothing else added. Can someone tell me how I can use it to record tapes to a digital format? What should I buy material additionl / software? See you soon Kilfinnan

  • No connection between the computer and the digital camera.

    Tried to download from camera to the computer. After I connect my digital camera to the computer using the usb cable, said digital camera looking for a connection. I never get a guess that the cause I can't go any further. What I am doing wrong. I lo

  • Can not get on the net via wifi apt, dns error msg

    Howdy, hey i cant get on the net with any browser through my wifi apt. I can very well with any other wifi in the range but my wifi apt has the best signal. I get a msg of DNS server and tried everything that the computer recommended to fix. Why this

  • I have a HP with installed Win7 Pro workstataion laptop refurbished 32-bit

    I have a workstation with installed HP Win7 Pro laptop refurbished 32-bit hard disk main. I plan to buy a second new HD and install a Win 7 64 bit for having so a dual boot. I had planned out the first HD, plug the new HD and install Win7 64 bit of m