AS 3:calling all instance names with similarities

As the title suggests I am looking to RegExp as a means to
find similiarities between diffferent movieclip instance names. I
have many clips that have an instance name that begins with "step"
that reside on the maintimeline. The logic written out should be:
If a movielcip exists on the timeline, whats its name, does
it have this string within its instance name, if so do this.
Unfortunately my code does not accomplish this quite
yet.

I'd think this would be the same in 3, but in 2 you'd use
array access
notation like so:
var myIndex = 3;
this["step_" + myIndex].moveUp();
this would call moveUp within step_3. You can interate
myIndex in a loop, of
course, to call the function in a group all at one time.
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

Similar Messages

  • Good practice to initalize all instance variables with type String to emptr

    Is it a good practice to initalize all instance variables with
    type String to emptry string?
    #1 approach:
    public class A
    { private String name = "";
    private String address ="";
    //etc...
    rather than
    #2 approach:
    public class A
    { private String name;
    private String address;
    //etc...
    When I read Java books, the examples don't usually do #1 approach.
    The problem is if we don't initialize to empty string, when we call
    the getter method of that instance variable, it will return null.
    Please advise. Thanks!!

    Please advise. Thanks!!It depends on your coding style. If you can avoid lots of checks for null Strings in the rest of the code then why not initialize to "".
    You have the same situation when a method returns an array. If you under circumstances return a null array reference then you have to always check for this special case, but if you return a zero length array instead you have no special case. All loops will just run 0 iterations and everything will work fine.
    So in general I guess the return of zero objects instead of null references really boils down to whether it simplicates the rest of your code by removing lots of extra checks for the special null case. This usage is especially favourable in the zero length array case. See Effective Java by Bloch, item 27.

  • Get All instance names in the stage

    hi,
    is there any way to get all instance name of the objects presents on the stage ? trace them for example
    thank you

    thank you, it's the correct answer but i still can't solve my problem ,
    the thing is that am using a code from http://www.freeactionscript.com that make enemie follow the player, but i need to do some modification, i need to detect collision between enemies so they will not get the one into the other and the thing that i cannot found their instance name, even when i used your function i only get "player_mc : _level0.player_mc" at the output,
    here is the code, i will be really greatful if you can find a way to help me solve this problem .
    ps :
    am trying to write my own code that make enemie follow the player, coz this one looks very complicated
    thank you
    the code :
    * Game Enemy AI Behavior - Run Away & Follow Player
    * Version:           1.0
    * Author:           Philip Radvan
    * URL:                     http://www.freeactionscript.com
    var enemiesArray:Array = new Array();
    var radians:Number = 180/Math.PI;
    createEnemies(5, "typeA", "e1");
    createEnemies(5, "typeB", "e2");
    createEnemies(5, "typeC", "e3");
    // createEnemies(number of enemies, behavior)
    // use ex: createEnemies(10, "slow", "myLinkedMovieClip);
    function createEnemies(enemyAmount:Number, enemyBehavior:String, enemyLibraryClip:String):Void
              //run a for loop based on the amount of enemies
              for(var i = 0; i < enemyAmount; i++)
                        //set temporary variable that will hold the new enemy attributes
                        var tempEnemy:MovieClip = _root.attachMovie(enemyLibraryClip, "enemy"+_root.getNextHighestDepth(),_root.getNextHighestDepth())
                        //give new enemy a random x/y position based on stage width/height
                        tempEnemy._x = random(Stage.width);
                        tempEnemy._y = random(Stage.height);
                        tempEnemy._rotation = random(360);
                        //set enemy behavior
                        if(enemyBehavior == "typeA")
                                  //define enemy characteristics
                                  tempEnemy.speed = 1
                                  tempEnemy.turnRate = .05
                                  tempEnemy.agroRange = 200;
                                  tempEnemy.mode = "follow"
                        else if(enemyBehavior == "typeB")
                                  //define enemy characteristics
                                  tempEnemy.speed = 4
                                  tempEnemy.turnRate = .5
                                  tempEnemy.agroRange = 200;
                                  tempEnemy.mode = "follow"
                        else if(enemyBehavior == "typeC")
                                  //define enemy characteristics
                                  tempEnemy.speed = 1
                                  tempEnemy.turnRate = .2
                                  tempEnemy.agroRange = 100;
                                  tempEnemy.mode = "run"
                        //define variables that are used to calculate following
                        //*don't change these*
                        tempEnemy.distanceX = 0;
                        tempEnemy.distanceY = 0;
                        tempEnemy.distanceTotal = 0;
                        tempEnemy.moveDistanceX = 0;
                        tempEnemy.moveDistanceY = 0;
                        tempEnemy.moveX = 0;
                        tempEnemy.moveY = 0;
                        tempEnemy.totalmove = 0;
                        //add new enemy to array
                        enemiesArray.push(tempEnemy)
    //Update enemies function
    function updateEnemies():Void {
              //run a for loop based on the amount of enemies
              for(var i = 0; i < enemiesArray.length; i++)
                        //set temporary variable that will hold the new enemy attributes
                        var tempEnemy:MovieClip = enemiesArray[i];
                        //run follow function with temporary enemy as the follower
                        updatePosition(tempEnemy, player_mc);
    // updatePosition(follower, target)
    // use ex: updatePosition(myEnemyMovieClip, playerMovieClip)
    function updatePosition(follower:MovieClip, target:MovieClip) {
              //calculate distance between follower and target
              follower.distanceX = target._x-follower._x;
              follower.distanceY = target._y-follower._y;
              //get total distance as one number
              follower.distanceTotal = Math.sqrt(follower.distanceX * follower.distanceX + follower.distanceY * follower.distanceY);
              //check if target is within agro range
              if(follower.distanceTotal <= follower.agroRange){
                        //calculate how much to move
                        follower.moveDistanceX = follower.turnRate * follower.distanceX / follower.distanceTotal;
                        follower.moveDistanceY = follower.turnRate * follower.distanceY / follower.distanceTotal;
                        //increase current speed
                        follower.moveX += follower.moveDistanceX;
                        follower.moveY += follower.moveDistanceY;
                        //get total move distance
                        follower.totalmove = Math.sqrt(follower.moveX * follower.moveX + follower.moveY * follower.moveY);
                        //apply easing
                        follower.moveX = follower.speed * follower.moveX / follower.totalmove;
                        follower.moveY = follower.speed * follower.moveY / follower.totalmove;
                        //move & rotate follower
                        if(follower.mode == "follow")
                                  follower._x += follower.moveX;
                                  follower._y += follower.moveY;
                                  follower._rotation = Math.atan2(follower.moveY, follower.moveX) * radians;
                        else if(follower.mode == "run")
                                  follower._x -= follower.moveX;
                                  follower._y -= follower.moveY;
                                  follower._rotation = (Math.atan2(follower.moveY, follower.moveX) * radians)+180;
    //onEnterFrame that executes the updatePosition updateEnemies every frame
    _root.onEnterFrame = function(){
              updateEnemies();
    //start/stop drag for player_mc
    player_mc.onPress = function(){
              startDrag(this);
    player_mc.onRelease = function(){
              stopDrag();

  • Call all instances of a symbol

    Hej,
    i need to place 10 different kinds of symbols, a hundred times each on my stage. Theses symbols have the same shape, but different colors. I need to filter them out in a tiny top-menu.
    So, if i click e.g. on a red circle, i want all non red symbols to set there opacity to 0.5.
    It could be simple if i place all red symbols into a container "$color-symbols" and set the opacity to them. But that is not possible, because I need to place each symbol manually. And if they are childs of another symbol, drag and drop is horrible.
    Now i am wondering if it is possible to call all symbols on stage that are instances of a symbol in my library.
    And is there a nice way to call "all-other-colors" instead of
    sym.$("color-1").animate({opacity:0.5},500);
    sym.$("color-9").animate({opacity:0.5},500);
    sym.$("my-own-color").animate({opacity:1},500);
    on every button on stage?

    Thanks for your help,
    i use the classes to specify a target url for each symbol.
    For Example:
    I have three red symbols and three blue symbols.
    The classes for the red-ones are:
    33451, 56789 and 45678
    for the blue ones:
    983, 4, 1002
    Inside of my symbols i have a script:
    var names = (e.target.id).split("_");
    var page = names[2];
    var link = "http://www.url.no/subpage/"+page;
    window.open(link, "_self");
    If i find another way to put a specific ID (and it must be a number) on to each Instance, i could use the way you describe.
    Because your idea is to use the class-names, there is no way to call all instances of a given symbol?
    Is it possible to use wildcards for my array?
    So i could name them "red-33451#1", "red-56789#2", "red-45678#3". And cut out everything between "-" and "#".
    But remember that i need to place a few hundreds of them, which isn't fun. And if i need to insert one later or if i delete another one, i need to verify all my functions.

  • Hello, I have deleted my hotmail account and it deleted all the names with my contacts. Is there anyway this can be fixed?

    Hello, I have deleted my hotmail account and it deleted all the names with my contacts. Is there anyway this can be fixed?

    Yeah, add the Hotmail mail account back to the device.  It sounds like your missing contacts were synced to your Hotmail account.

  • Required Powershell command to gather all vm names with snapshot created on them.

    Required Powershell command to gather all vm names with snapshot created on them.
    ADS/DNS/DHCP/RIS/GROUP POLICY/PowerShell/VMware/Esxi/Storage.

    Required Powershell command to gather all vm names with snapshot created on them.
    It is not related to Active Directory, more like it is a virtualization question and PowerShell. But I beleive this could help for VMWare:
    Get-VM | Get-snapshot | FT VM,Name
    Or refer to these articles:
    Get a List of Virtual Machines by Using PowerShell
    Using PowerShell to get a list Virtual Machine
    Snapshots in VMware ESXi 4.1
    Mahdi Tehrani   |  
      |  
    www.mahditehrani.ir
    Please click on Propose As Answer or to mark this post as
    and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.
    How to query members of 'Local Administrators' group in all computers?

  • Get current SQL instance name with PowerShell

    Hi all,
    I'm preparing SQL agent job that will backup all jobs on SQL server. Main step is PoswerShell script. I want that job to be universal for all servers. The first parameter that I need to send to script is instancename.
    I want to use variable as InctanceName parameter. So, when I run this job on particular server this variable must get current SQL instance name.
    I can use $env:computername for default instances but I cannot use it with named instances or with clustered instances. Some solutions like using 'HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL' keys won't work because of number of
    instanses can be running on one machine.
    How to get only current SQL instance name?

    Hi, 
    Thank you for your answers.
    I found this solution:
    $serverInstance = "$(ESCAPE_DQUOTE(SRVR))"
    Working perfect.

  • Referring to instance names with variables

    I have the following problem. I have two movie clips with the
    instance
    names inst01 and inst02.
    I have the code :
    _root.inst01._alpha += 10;
    Now sometimes I would like it to be for "inst01" and others
    "inst02".
    Is there a way that I can just say set a variable like :
    currentinst = "inst01"
    or
    currentinst = "inst02"
    And then write the code as:
    _root.currentinst._alpha += 10;
    Would this work, how would Flash know whether "currentinst"
    was an
    instance name or a variable name?
    THANK!
    Tim

    Thanks!
    I had actually just figured it out, I have to use the array
    brackets,
    thanks so much!
    In article <ess33h$d73$[email protected]>, "David
    Stiller"
    <[email protected]> wrote:
    > Tim,
    >
    > > Is there a way that I can just say set a variable
    like :
    > >
    > > currentinst = "inst01"
    > > or
    > > currentinst = "inst02"
    >
    > There is.
    >
    > > And then write the code as:
    > > _root.currentinst._alpha += 10;
    >
    > The problem with that, as is, is that the variable
    currentint currently
    > refers to a string, and the String class has no such
    property as _alpha.
    > You need to "translate" that string into an actual
    object reference, and
    > there are two ways I know of to do that, both described
    here.
    >
    >
    http://www.quip.net/blog/2006/flash/actionscript-20/reference-objects-dynamically
    >
    >
    > David Stiller
    > Adobe Community Expert
    > Dev blog,
    http://www.quip.net/blog/
    > "Luck is the residue of good design."

  • Firefox profiles aren't very useful - all instances open with same one

    I am running Linux: LMDE Cinnamon Edition - 64 bit
    I am using firefox version Mozilla Firefox 31.0
    I wish to have two instances of FF running. One with my standard, personal settings and a second instance that ONLY connects to Facebook and will stop data leaking between the two. I can acheive this by opening Facebook in another browser (e.g. Chrome or Opera).
    I checked the ProfileManager under Firefox and created a second profile called "FB".
    I can run firefox -p FB and it will open an instance of FF with none of my personal settings available - that's what I was hoping for.
    However, if I run a second instance of FF - for example from the command line as firefox -p default it loads with the same profile as the first instance I opened, not the new profile as specified in the command.
    I can only select the profile if there are no prior firefox instances running under my user-id. The first instance defines which profile is used for all subsequent executions - no matter which profile I specify on the command line. Even running firefox -ProfileManager will start with the first-specified profile, not the profile manager.

    Hello,
    If you want to run multiple instances of Firefox, you need to add a -no-remote parameter to the command.
    For example:
    * firefox -P -no-remote
    Please see:
    * http://kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile

  • Instance names with Oracle Parrallel Server (OPS)

    Hi. I was "reviewing" an Oracle 8 OPS implementation and I noticed that the instances on both nodes have the same name. In another word, the instance on node 1 is named I1 and the instance on node 2 is named I1. While the system appears to work, during a failure of one instance, both instances fail. Does this make sense? Has anyone else had a similar experience? Does anyone know of the possible effect of having the same name.
    The clients are weblogic applications using the thin-driver.
    Any help you can give me would be appreciated.

    Hi,
    While the system appears to work, during a failure of one instance, both instances fail. Does this make sense?As per OPS architecture point of view,both instance should be have different name.
    and failure of one instance doesn't effect on other availability and other should be up and running ,that is the true menaing of high availabilty in OPS.
    again check ur configuration,verify ur parameters in init.ora file is configure properly or not.
    also check alert log files of both instance.and put different name of each instance.
    **instance_number should be different on both instance
    Kuljeet

  • All instances names on one NETWORK

    How i see all oracle instances which are present on my network domain.
    is there any command for CMD.
    Thanks

    Don't expect to find a single command to track your network, and you should specify if you are talking about unix or windows. You should have privileges to get connected to the target host and issue a netstat command to find if there is a listener currently working there:
    netstat -b -a
    TCP alpha:1521 alpha.us.oracle.com:0 LISTENING 3644 [TNSLSNR.exe]
    This will let you know where the listener is working and in case you have more than one listener, any additional ports. You will have to find each Oracle Home and execute the lsnrctl services or lsnrctl status command. This will show you the currently working instances, but in case instances are down the only way to find out will be to directly go to each Oracle Home and find out if there are the configuration files, such as init* or spfile* and find out if they are still active.
    ~ Madrid
    http://hrivera99.blogspot.com/

  • Find All Instances Scripting

    Hello, I was wondering if there was a way to programatically use the Find All Instances function with scripting?  At the moment my work around is very slow but works.  
    I have a reference to a VI and I have my project open, I then want to find all the places that this VI is used.  At the moment I get all VIs in Memory (Application >> All VIs in Memory), then for each VI I get all SubVIs on the block diagram (Traverse References).  Then for each subVI in each VI in memory, I get the path to the VI and compare it to the path of the VI I want to find.
    As one can imagine this takes too long.  Especially when I can right click my VI's Icon and say Find all Instances and get all 6 instances seemingly instantly.  I searched for a while and couldn't figure out if this was possible or how to do it.  Thanks.
    Attached is my attempt, which just counts the number of times the search VI is called.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Solved!
    Go to Solution.
    Attachments:
    Find All Instances Slow.vi ‏20 KB

    Well that was easy, not sure why I didn't think of that.  In any case I made a new VI that does what you mention and it indeed works much faster.  Attached is the improved version in case someone was interested.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    Find All Instances Faster.vi ‏19 KB

  • Button using changing Instance Names

    I have multiple button using the same button from my library.
    I have given the all instance name and if I put that instance name
    in from of my addEventListener the button works fine. However, I
    have a lot of buttons on the stage so I want to be able to write
    some thing the will get the instance name on roll over and place
    that in front of the event listener. I am trying to avoid writing a
    line of code for each button. Can this be done?

    you should start here:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
    go to packages->statements, keywords, & directives
    you can't just ask what a for loop is. it shows you haven't
    done any investigation at all as that is a very basic programming
    construct. you need to learn some basics before you ask people what
    to do. if you have trouble with a particular topic or getting
    something to work, that's what this is for, but it's not to teach
    you the language. there's way too much to learn and too many people
    asking. get a good actionscript book and it will take you through
    the basics.
    i recommend:
    O'reilly Essential Actionscript 3
    good luck

  • Adding a variable an instance name

    i have a variable that is my flash movie is retreiving (well,
    hopefully....i'm having troubles with the
    loadVariables)....anyweezer, the variable is named "id". i would
    like to add the value of this variable to then end of a text string
    and then use it as reference to an instance name.
    for example, i have movie clip with an instance name of
    TTMO110333. if the ID variable had a value of 110333, how could i
    use that in actionscript to allow me to refer to the latter part of
    the instance name with the variable?
    something to the effect of....
    on(rollOver) {
    this."TTMO"+id._visible = true;
    }

    thanks for your help, but neither solution is working for me.
    i think it may be because i'm using this in a function for a movie
    clip, to make it act as a button. i am also having problems getting
    getURL() to open a blank page inside a function for a movie clip
    like this as well. is there something i need to do differently if
    i'm trying to apply this to a movie clip? here's my AS....
    this.loadVariables("linkCCdisplay.php","POST"); //this gets 3
    variables: url1, title1, and id1
    TTbutton1.onRelease = function() {
    TTbutton1.getURL(url1, _blank);
    }; //the "blank in this doesn't work, it goes to the url,
    just not in a new window
    TTMO110333._visible = false; //this refers to a movie clip
    that is on the same stage with an instance name of TTMO110333
    myInterval = setInterval (TTMO,15);
    function TTMO () {
    TTMO110333._x -= (TTMO110333._x - _xmouse)/10;
    TTMO110333._y -= (TTMO110333._y - _ymouse)/10-2;
    TTbutton1.onRollOver = function() {
    this["TTMO"+id1]._visible = true;
    } //this refers to a movie clip with an instance name of
    TTbutton1, i would like to make the clip visible only while the
    mouse is over the movie clip i'm trying to get to act as a button
    any ideas on how to solve these problems? thanks again for
    your time.

  • Accessing a movieclip instance created with AS.

    If I attach a new movie clip and give it a name by concatenating the instance name with a variable number (such as "myMovie + myVar" so that I get "myMovie1", "myMovie2", etc.), how do I then access the resulting instance in order to assign properties? MyMovie + myVar._x = 500 not surprisingly doesn't work. I presume I need to assign the value to a string variable, and then somehow assign that variable as the instance name of the movieclip?
    Thanks.

    that's incorrect syntax and contains a typo.  try:
    var myVar:Number = 1;
    this.attachMovie("Square_mc","Square_mc"+myVar,this.getNextHighestDepth()) ;
    this["Square_mc"+myVar]._x = 300;

Maybe you are looking for