Calling a variable in an instance name

Maybe I am far off here, but I'm hoping someone can help.
Basically I'm creating a question with 4 answers (i.e. a,b,c,d).
I have my question working fine, but I'm having a problem adding a check mark beside the answers once the user clicks the submit button.
I've created four instances of my check mark; rightAns1_mc, rightAns2_mc, rightAns3_mc, rightAns4_mc.  I've set them all to _invisible = false;
I've also set up a variable; nCheck:Number = 0; and when the user clicks one the radial buttons I have the variable change (i.e. if they click A, it set to nCheck = 1; if they click B, it sets to nCheck = 2; etc)
So in my if statement for the submit button I figured I could have rightAns(nCheck)_mc._visible = true;
This completely breaks everything. Like I said, I'm probably far off here. If I am what should I do differently, and if I'm close what am I doing wrong?

use array notation to coerce flash to resolve strings to objects:
this["rightAns"+nCheck+"_mc"]._visible=true;

Similar Messages

  • Using a variable in an instance name

    Hey all,
    Simple question:
    I'm trying to use a variable to call on different instance names:
    var picCaller:uint=2;
    material_mc.addChild(pic_""+picCaller+"");
    The code in red is the issue in question.  In this example, I'm trying to add a child called "pic_2", with the number two called from the variable "picCaller"
    Any assistance is greatly appreciated.
    Thanks!

    Just for context, here is what I'm trying to do:
    I have jpegs in my library and I want to add them to the stage when they're needed, so just to add one image, here is the code I have:
    var pic_1=new pic1(0,0);
    var image_1:Bitmap=new Bitmap(pic_1);
    material_mc.addChild(image_1);
    I want to put the above into a loop so that I dont have to repeat those three lines for every image in my library like so:
    var pic_1=new pic1(0,0);
    var image_1:Bitmap=new Bitmap(pic_1);
    var pic_2=new pic2(0,0);
    var image_2:Bitmap=new Bitmap(pic_2);
    var pic_3=new pic3(0,0);
    var image_3:Bitmap=new Bitmap(pic_3);
    var pic_4=new pic4(0,0);
    var image_4:Bitmap=new Bitmap(pic_4);
    var pic_5=new pic5(0,0);
    var image_5:Bitmap=new Bitmap(pic_5);
    var pic_6=new pic6(0,0);
    var image_6:Bitmap=new Bitmap(pic_6);
    var pic_7=new pic7(0,0);
    var image_7:Bitmap=new Bitmap(pic_7);
    the variable "picNum" is the total amount of images that in the library, each one exported as "pic1", "pic2", "pic3" respectively.
    var picNum:uint=7;
    var picCaller:uint=1;
    var  picMC:MovieClip = new MovieClip();
    picMC=this["pic_"+picCaller];
    for (var  i:int = 1; i <= picNum; i=i+1)
         var "pic_"+i = new image_i(0,   0);
         var image:Bitmap = new Bitmap("pic_"+i);
    Thanks so much for your help.

  • Reference a movieclip by a variable containing its instance name?

    There are some movie clip instances on the stage (not
    dynamically created at run time). Now, I want to do this:
    use a variable to hold a instance name at runtime. then use
    this variable to reference the movie clip it points to.
    Problem: suppose this variable is named "mc_ref". it fails to
    use "_root.mc_ref" to refer to the movie clip by the name that
    mc_ref contains. it seems in this case flash takes "mc_ref" as
    instance name and thus looks for any child by that name. since
    mc_ref itself is not a name, this will not work.
    is there something like MovieClipbyInstanceName function for
    this? Any thoughts? Thanks!

    you're confused. the variable's name and the movieclip's name
    should not be the same.
    the following are correct ways to reference movieclips in
    flash:

  • Variable Reference of Instance Name

    While I have had no problems with bracket evaluation of
    constants and number variables, I don't know the coding convention
    for brack evaluation of a string.
    I get an undefined for oBtnName
    oBtnName = new Object;
    oBtnName = this["mcWing" + aWingColor[nIdx] + "Btn"];
    where aWingColor is an array of strings. So I tried setting
    aWingColor[nIdx] to variable thinking the inside array brackets
    were goofing this up:
    oBtnName = new Object;
    var sWingColor:String = aWingColor[nIdx];
    oBtnName = this["mcWing" + sWingColor + "Btn"];
    trace (sWingColor + " " + oBtnName._name );
    returns Pink undefined
    and interactive debug is showing oBtnName as undefined as
    well.
    So, then I tried this
    oBtnName = this["mcWing" + sWingColor._value + "Btn"];
    and then this
    oBtnName = this["mcWing" + "[sWingColor]" + "Btn"];
    and so on and so on. . . .

    Isn't
    this["mcWing" + aWingColor[nIdx] + "Btn"]=new Object()
    the same as
    var oBtnName:Object = new Object;
    oBtnName = this["mcWing" + aWingColor[nWingRollIdx] + "Btn"];
    I am doing this to shorten the reference name
    Here is the rest of the code
    mcWingPinkBtn.onRollOut = function () {
    clearInterval(nInterval);
    nWingRollIdx = 1;
    nInterval = setInterval(fFadeOutWing, 1);
    function fFadeOutWing():Void {
    var oBtnName:Object = new Object;
    oBtnName = this["mcWing" + aWingColor[nWingRollIdx] +
    "Btn"];
    oBtnName._alpha -= nAlphaIncrement;
    ----oBtnName is undefined here so the following if doesn't
    work -----
    if(oBtnName._alpha <= nAlphaStart) {
    oBtnName._alpha = nAlphaStart;
    clearInterval(nInterval);
    updateAfterEvent();

  • Calling a variable by 2 names

    Some times I want to call a variable by an indexed name.
    for (int i= 0; i <5; i++)
    array[i] = from;
    from[0] contains the number of names
    from[1] contains the number o people
    from[2] contains the number of dogs
    from[3] contains the number of cats
    from[4] contains the number of birds
    In other parts of the program, to make it more understandable, I want to refer to numOfBirds rather than from[4]. countOfBirdies = numOfBirdsIs there a way to set up the name equivalence in Java?
    Thank you                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    zscipio wrote:
    I am interested is satisfying both concepts as it is possible in some other languages. One simple way is to introduce named indexes, like
    public class NumberOf {
       private NumberOf(){} // private constructor to prevent instantiation
       public static final int NAMES = 0;
       public static final int PEOPLE = 1;
       public static final int DOGS = 2;
       public static final int CATS = 3;
       public static final int BIRDS = 4
       public static final int SIZE = 5; // number of constants
    }Now you can do,
    for (int i= 0; i <NumberOf.SIZE; i++) {
       array[i] = from;
    countOfBirdies = array[NumberOf.BIRDS];It's probably not exactly what you wanted but at least you're using symbolic names rather than naked indexes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Convert integer to instance name?

    I have 40 movieclips, with the instance names p[1-40] (for example, p14 or p32). I want them all to do something in order, so I'm using a 'for' loop. In simplified psuedo-code, it looks like:
    for 40 {
         variable = variable + 1
         p[variable]
    How do I use p[variable] as an instance name?
    Thank you in advance!

    var mc:MovieClip;
    var totalMovieClips:Number = 40;
    for(var i:Number = 1; i<=totalMovieClips; i++){
              mc = new MovieClip();
              mc.graphics.beginFill(0xFF00FF, 0.7);
              mc.graphics.drawRoundRect(0, 0, 50, 50, 10, 10);
              addChild(mc)
              mc.name = "mc" + i;
              //trace(mc.name);
              mc.x = i * (mc.width+5);
              mc.addEventListener(MouseEvent.CLICK, onCLick);
    function onCLick(evt:MouseEvent){
              trace(evt.target.name); // Do something write what the button wants actions to do

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

  • Pass symbol instance name to variable

    Hi all,
    I'm trying to figure out how to pass the instance name (ID) of a clicked object to a variable so I can navigate to a label on the timeline with the same name.
    So far I've tried different variations of:
    sym.getSymbol() //logs as "undefined"
    sym.getSymbolTypeName // logs the symbol name in the library, not the instance
    Any ideas?
    Thanks
    -Dave

    Sweet!
    That worked - Thanks! I ended up combining both your suggestions. on the button symbol i have
    sym.getComposition().getStage().onClick(e.target.id);
    and then after compositionReady I added a function to split out the second name and logged it to test;
    sym.onClick = function(targetId){
              var names = targetId.split("_");
              console.log(names[1]);
    Works perfectly! - Although it would be nice if the EA team could fix that functionality in future releases so e.target.id gives you just the id for the selected symbol. I would think if you can write something like getSymbol("mySymbol") it should be just as easy to get that name without all the extra (Stage...etc)
    Thanks again!
    -David

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

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

  • Simple math and a variable in an mc instance name

    i have several movie clips with instance names in the format
    of screened1, screened2, screened3, and so on. i am trying to
    reference a movie clip as shown below, but it's not working. what
    am i doing wrong? how do i fix it?
    this.screened[numOfItems-8].transform.matrix = F1toP0;
    the transform, matrix and all of that works fine. but when i
    add the information between [ ] to make reference to the movie clip
    instance name, no go. numOfItems is a number, and when run trace on
    it.... it does return a value in the output.

    right on. my favorite flash genius. thanks again!

  • How can we use variables for instance name?

    I'm using 9 textbox in my stage. Names are similar, only difference is the last character. (s1_0, s1_1, s1_2, ...). I'm trying to use these textbox in a loop. But I couldn't find the right typing... s1_[i], s1_(i) or s1_{i} gives error.
      s1_0.text=0
      s1_1.text=0
      s1_2.text=0
      s1_3.text=0
      s1_4.text=0
      s1_5.text=0
      s1_6.text=0
      s1_7.text=0
    how can make the shortest typing for this issue?

    yes, its working, thank you very much...
    I tried array operator but the word "this"..
    what does it means ? when I delete this word, it gives error. how does flash know that it is a instance name?

  • Which file decide instance name in RAC 10g ?

    Which file decide instance name in RAC 10g ?
    How does RAC know which instance should start from which machine?
    Thanks.

    The spfile is NOT the correct answer, actually.
    1. The instance name for any Oracle instance, whether in a RAC or not, is derived from the value for the ORACLE_SID parameter which is in force at the time the startup command is issued. If you were to:
    export ORACLE_SID=SALES
    sqlplus / as sysdba
    startup...you would just have created an instance called SALES.
    2. The spfile (or init.ora if you're not using an spfile) contains a parameter called INSTANCE_NAME. That defaults to whatever ORACLE_SID is set to as an environment variable when the instance is started, hence point 1 above. But you can force an instance to acquire a non-SID name by deliberately setting it to something different. That's unusual to do, though, except in a RAC context where you want to subvert the default load balancing mechanism.
    2b. The spfile (or init.ora) also contains a parameter called DB_NAME -but that is the name of the database, not the name of the instance, and is therefore irrelevant for the purposes of working out how instances get their names,
    3. Neither of the above answers has got anything to do with RAC knowing what instance runs on which machine. That is the job of the Oracle Cluster Registry file (OCR), for which you have to provide about 100MB of space on a shared hard drive during the RAC installation itself.
    You populate that file by running DBCA to create your RAC instances (and DBCA then automatically updates the OCR to record the fact that it created instance X1 on Node A and X2 on Node B, and therefore that's what will happen in the future unless you change things).
    Or you can update the OCR yourself by using the SRVCTL utility. You'd do something like: srvctl add instance -d DB1 -i X3 -n C (add an instance called X3 to run on Node C as part of database DB1).
    A little more details about the OCR is available in Section 13 of this article, for example: http://www.dizwell.com/prod/node/26?page=0%2C5

  • Call method from another class instance

    Forgive me if I don't make sense, I'm relatively new to Java and still not up on all the lingo.
    So here's what I want to do... This is probably easier explained with code:
    ParentClass.java
    public class ParentClass {
         public static void main(String[] args)
              ChildClass1 child1 = new ChildClass1();
              ChildClass2 child2 = new ChildClass2();
              System.out.println("ParentClass");
              System.out.println(child1.getText());
              System.out.println(child2.getText());
    ChildClass1.javapublic class ChildClass1 {
         private String text = "ChildClass1";
         public ChildClass1()
              System.out.println("ChildClass1 Constructor");
         public String getText()
         { return text; }
    }ChildClass2.java is identical to ChildClass1, except the 1's replaced with 2's etc.
    I need to be able to call getText() in ChildClass1 from ChildClass2, and eventually methods in the ParentClass class.
    As I understand, if I make the ChildClass's extend the ParentClass, every new instance of the ChildClass will create a new instance of the ParentClass. What I need though, is one instance of ParentClass with it's eventual variables etc. set, and then have the two classes defined within, able to talk to each other and the methods in the ParentClass.
    How does one go about doing this? Does that even make sense?
    Thanks, Savage

    You may need to read thru the information provided on this page to understand how to create objects: http://java.sun.com/docs/books/tutorial/java/data/objectcreation.html
    I'd also suggest you read the tutorial available at: http://java.sun.com/docs/books/tutorial/java/index.html
    Regarding how you call a method belonging to another class you could do it in the foll. ways depending on whether the method is static or not - a static method may be called using the class name followed by a dot and the static method name while a non-static method would require you to create an instance of the class and then use that instance name followed by a dot and the method name. All said and done i'd still suggest you read thru the complete Java programming tutorial to get a good grounding on all these concepts and fundamentals of the language if you are looking to master the technology.
    Thanks
    John Morrison

  • Display Database Instance Name in the System Message

    Greetings,
    I am looking for a way to display the database instance name on each page in the Application Builder. Using the System Message would work for me and I can hard code the instance name, but I was wondering if there is a variable that I can specify that will accomplish the same thing.
    Thanks a lot,
    Larry

    Hi Tony,
    I did find that plug-in during my investigation. Some of the plugins sound interesting but I hesitate to anything to the base APEX install since I am not sure if this will affect supportability from Oracle if something goes wrong later on. Do you know if these plug-ins can be installed/deinstalled without affecting the base APEX install? There is also something called ApexLib which looks interesting. Do people use this? Any idea if it is still supported? I checked the forums and noticed there is not much recent activity. I wonder if it has been abandoned.
    Hi Ashish,
    I do have the application displaying the current environment. I set it up using Page 0 as you suggested. It works great. In fact, I have set up an 'About' page that grabs information from the WWV_FLOWS table which will display information about the current application. Here is my query:
    SELECT ALIAS
         , AUTHENTICATION
         , CREATED_BY
         , to_char(CREATED_ON,'mm/dd/yyyy hh24:mi:ss')
         , DATE_FORMAT
         , DISPLAY_ID
         , FLOW_VERSION
         , ID
         , LAST_UPDATED_BY
         , to_char(LAST_UPDATED_ON,'mm/dd/yyyy hh24:mi:ss')
         , NAME
         , OWNER
         , PUBLIC_USER
      FROM apex_040000.wwv_flows
    where ID = :APP_ID;
    select substr(global_name || '.' ,1,instr(global_name || '.' ,'.') -1)
      into :P999_DATABASE
    from global_name;I use GLOBAL_NAME to get the database SID instead of v$instance so I don't have to grant special privileges on v$instance.
    If you find a way to grab the database SID from a query and put it in the System Message field, please let me know. In the interim, I have hard coded this in the System Message field.
    <span style="padding:10px 20px 10px 20px; font-weight:bolder ;font-size:1.2em; background:#D96E1C;color:white">Development: TheInstanceName</span>Not exactly what I want, but it will get the job done.
    Thanks for all your help,
    Larry

Maybe you are looking for