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:

Similar Messages

  • Any way to for a class instance to ask what its instance name is?

    Hey. I have a class which needs to create a movie clip on the
    stage. Since each instance of the class will only ever have 1 movie
    clip on the stage at a time, it seems reasonable that I have the
    instance create a movie clip with its own name, prefixed with "mc_"
    or something of the sort.
    Here's where I don't know quite what to do... How do I get at
    this information? For instance, when you a dealing with an XMLNode,
    you can simply use...
    the_answer = xmlNodeInstance.nodeName;
    ...I know the analogy fails, but hopefully you know what I'm
    looking for.
    Thanks!

    hu....
    and when you create your movie clip, (assuming you don't just
    build it at authoring time) you specify an instance id through the
    createEmptyMovieClip function....
    taking a cue from this, I'm guessing that my answer is to
    change the structure of what I'm doing a little... instantiate my
    object with an instance name as a parameter given to the Class
    Constructor... that way the class can have it's own name on file.
    I guess my only concern there is how do I keep the "name"
    variable from being just completely arbitrary...?
    I guess I'm getting away from application (becaust I don't
    know when I'd do this...) and into theory.... but for instance,
    let's say I create my class like this:
    var instanceReference:mySuperCoolClass = new
    mySuperCoolClass("instanceName");
    So. I have my class instance... ideally, the class would
    exist on the stage as "instanceName", with "instanceReference"
    being another way to reference the instance. That would be ideal...
    but how do I make that happen? Because in the scenario of what I've
    just done, I see the class instance existing on the stage as
    "instanceReference", and I've just passed it a fun, but meaningless
    bit of data called "instanceName"...
    I suppose I could have the class go back to "_parent" and
    create it's own object.... but here again I'm getting into
    territory that feels a lot like i have no idea what I'm doing...
    haha!
    I guess I have enough info to get back to coding for now...
    But I'm deffinately open to more tips... I feel like I'm still
    missing how a lot of this works.
    (I'm at that awkward place where I can easily explain what
    OOP is, but I'm far from experienced in how to implement it... I've
    only written about half a dozen classes so far... so I still have a
    lot to learn. Thanks for your patience, all of you!)

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

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

  • I need to delete a variable containing a movie clip class and recreate it with a different movie clip class

    Hello,
    I am creating a program that is going to help students learn to read. In my project are pages of text with each word having a button that when pressed will display a movieclip presentation about that word (its pronounciation and spelling etc..). In the project I am working on now I have over 450 unique presentations of words to deal with. I don't want to have all of these hundreds of movie clips on the stage and tell them one at a time to stop and rewind and then have one play each time a word button is pressed. That seems to be very inefficient to me. So I want to do this with some code in Actionscript 3.
    I know I can dynamically add movieclips to the stage using addChild(movieclipname) and remove them using removeChild(movieclipname) but there is a problem. I have hundreds of unique movieclips and I don't want to have to manage hundreds of variables containing the indivudual movieclip instancess. It is a real pain having to figure out what instance is still on the stage before i delete it.
    In Adobe Director all I have to do is this:
    on mousedown me
         sprite(me.spritenum).member = member("somenewmember:)
    end
    and that was it
    But if I do this in actionscript 3:
    removeChild(some_mc)
    some_mc still exists in memory. And I have to know exactly what variable it is to remove or else the movie will fail with an error. If I try to be brutish about it and try to implicitly remove all 450 movieclip instance variables from the stage I will get at least 449 errors.
    What I want to do is this:
    removeChild(some_mc)
    some_mc = void //or //delete some_mc
    var some_mc:MovieClip = new someother_mc();
    addChild(some_mc)
    but this doesn't work
    How am I going to remove one of 450 movie clips and add a new totally different movie clip without the code knowing exactly what the last movie clip was? I suppose if could remove a child from the stage based on a string name then I could hold that name in a variable for later disposal.Can I do this?
    Thanks for any help you can give me. I am new to actionscript.

    Hey I think I may have a solution:
    //begin code
    var myMC:MovieClip = new ball();
    var starMC:MovieClip = new star();
    var youpresseeditMC:MovieClip = new youpresseedit();
    starMC.name = "star";
    myMC.name = "ball";
    youpresseeditMC.name = "youpresseedit"
    addChild(myMC);
    box.addEventListener(MouseEvent.MOUSE_DOWN, replaceball);
    press_BTN.addEventListener(MouseEvent.MOUSE_DOWN, replaceballwithtext);
    function replaceball(event:MouseEvent):void {
        trace(myMC.name)
        removeChild(myMC);
        myMC = starMC;
        addChild(myMC);
        trace(myMC.name)
    function replaceballwithtext(event:MouseEvent):void {
        trace(myMC.name)
        removeChild(myMC);
        myMC = youpresseeditMC;
        addChild(myMC);
        trace(myMC.name)
    ///end code
    This works. I see the ball object replaced  by the star and I am able to do this by manipulating just myMC. Is there anything I should be concerned with in this approach?
    Thanks for your help

  • Mine is an old IPod, 30 GB, Mod:  A1136.  I can´t find reference on the IPod page to download its manual or do an update on it.  Can anyone please help?

    Mine is an old IPod, 30 GB, Mod:  A1136.  I can´t find reference on the IPod page to download its manual or do an update on it.  Can anyone please help?

    Hello Ramirongo,
    If you are trying to update your iPod, then all you need to do is have the latest version of iTunes installed and plug it in. It will check of any updates if they are available and update your iPod. I have also provided the User Guide for your model of iPod as well. 
    iPod Features Guide 
    http://manuals.info.apple.com/MANUALS/0/MA186/en_US/iPod_Late_2006_Features_Guid e.pdf
    Update your iPhone, iPad, or iPod touch iOS software
    http://support.apple.com/kb/ht4623
    Regards,
    -Norm G.  

  • REP-1213:  Field F_1 references column EMPNO at a frequency below its group

    Hii guys
    My goal is to display my desired database column where ever i want to on the report layout.For this Purpose
    I ran the following query
    1.SELECT * FROM EMP WHERE EMPNO='7369' in the Data Model.
    2.I then created a field in layout view and gave field source as EMPNO
    3.On Report Run following error was encountered.
    REP-1213: Field F_1 references column EMPNO at a frequency below its group
    Kindly help me in fixing this problem
    Regards
    Fahad Hameed

    dsegard
    Thanks for the tip.I fixed that and now i feel i've some control over my layout.
    How can i apply an image as a water mark throughout my report ??
    Regards
    Fahad Hameed

  • Cannot insert field or paste in existing Local Variable (container of booleans)

    Cannot insert field or paste in existing Local Variable (container of booleans)...  TestStand 4.1.
    This is very strange, especially since I have done it before. 
    The "paste" and "insert field" selections are greyed out and disabled from the right-click menu.  I have tried everything I could imagine, and searched various combinations of posts.  I am sure it is something redicoulously simple, bu I cannot find the redicule to solve this annoying issue.
    The local variable is a container of booleans.  It has 90 elements and I need to add one more.  I cannot edit / rename or do anything with this Local.  Must be karma (for thos who know me in the LabVIEW forum).  Usually, you right click, insert field and it's there..  Not this one..
    Has anyone seen this before?  Closing and re-opening TestStand did not change anything.  There is a matching cluster in LabVIEW which feeds the local in TestStand.
    It is a container of custm data type.  The Edit Flags are ok (edit is allowed).  Can't think of any other valuable info..
    Solved!
    Go to Solution.

    I should correct an erratum in my original post.. 
    Since I am not the original author of the code, I am not sure it is a custom container.  As a matter of fact, I don't think it is.
    It does not appear in the custom data types.  So it must be a Local.
    I will attempt to clarify what I am dealing with...  (TestStand 4.1)
    Maybe pictures are worth thousands of words.
    As with typical TestStand projects, there are various variables:  Locals, Parameters, FileGlobals, etc..  Nothing odd here.
    The one I am concerned about is the Options_Present which is a container of booleans.
    I am sure I have edited this one before.  Although I seem to recall that it was automatic after changing the cluster in LabVIEW.
    Within the Locals, the  2 that are underligned in red do not allow to edit anything (change name, add, delete, paste).
    Trying to Insert Field or paste are not possible.
    Attachments:
    Variables.PNG ‏8 KB
    Locals.PNG ‏28 KB
    cannotInsert.PNG ‏9 KB

  • Revisiting: Referencing a MovieClip using a variable

    This is a problem I thought I understood and was addressed in a previous thread (http://forums.adobe.com/thread/441458?tstart=0), but I have a new situation where the old solution isn't working.
    I have 3 instances on a "nested" movie clip. Their instance names are: b1, b2, and b3. When I trace these movieclips from the main timeline, I get:
    trace(b1); // result = _level0.slide_mc.newMC.b1
    trace(b2); // result = _level0.slide_mc.newMC.b2
    trace(b2); // result = _level0.slide_mc.newMC.b3
    From the main timeline, I want to fade up these movieclips using tween, but I need to do this by building the instance name in a variable:
         var myInstance:String = "slide_mc.newMC.b"+ instanceNumber //(instanceNumber is equal to 1, 2, or 3)
    Now, I thought using the variable in this manner would work:
         new Tween (this[myInstance], "_alpha", None.easeNone, 0, 100, .5, true);
    ...but it doesn't.
    I've checked trying to use the actual movie clip instance:
         new Tween (this.slide_mc.newMC.b1, "_alpha", None.easeNone, 0, 100, .5, true);
    ...and it works fine. What am I not getting here?
    Thanks.

    A string of instance names cannot be treated the same way.  Each bracketed string is evaluated as an individual object/instance.  So you would need to use...
    new Tween (this.slide_mc.newMC["b" +  instanceNumber], "_alpha", None.easeNone, 0, 100, .5, true);
    An alternative would be to use...
    var myInstance:Object = this.slide_mc.newMC.["b"+ instanceNumber];
    new Tween (myInstance, "_alpha", None.easeNone, 0, 100, .5, true);

  • Field F_1 references column colname at a frequency below its group.

    Hi
    I have 2 queries in my report. One for Summary section and one for detail section. The detail is nothing but details of the summary section on the top.
    I created a repeating frame for the detail and have set the source to the 2nd query -that is for the detail section.
    However, when I add a field and set the source to a column from query I get the following error:
    Field F_1 references column <colname> at a frequency below its group.
    What am I doing wrong here?
    Ant help appreciated.
    Thx!

    Hi
    If that was the case then it wouldnt be like summary and detail as I specified in earlier posts. It is not 1:1.
    Another thing I was tryng to accomplish was that in the detail section, I need the country and then the cities and rest of the details specific to that country below it. This way I want the categorization by country.
    Example:
    Country: USA
    New York
    San Francisco
    Chicago
    Boston
    Country: Canada
    Toronto
    Montreal
    Halifax
    What I am getting right now is:
    Country: Canada
    Toronto
    Country: Canada
    Montreal
    Country: Canada
    Halifax
    and so on
    Each of these cities within Canada occur in different repeating frames. I want one frame per country.
    How may I accomplish that?
    Again, Query1 = Selects distinct countries on a specific criteria
    Query 2: Selects details for all the countries selected in query 1
    Thx!
    Message was edited by:
    b~o~s~t~o~n

  • Get the instance names of clips attached to a movieclip

    I want to get the instance names of all the cmovieclips that
    are attached to a movieclip.
    Is there a simple way to do this.
    I imagine this is something that can be done with AS3 but can
    it be done with AS2?
    regards J

    you're welcome.
    FYI: a for...in loop loops through all the accesible
    properties (in the broadest sense of the meaning, includes
    methods/functions and variables etc). Each time it finds one it (in
    this case) assigns the property name to the variable 'unknown'
    the code inside the loop just checks
    a) is it a property that references a movieclip instance and
    b) is it the same property name as the movieclip instance's
    _name property (this is to avoid listing additional references to
    the same movieclip instance that may be set up as variables in your
    McA's scope).
    I just read that and I'm wondering if it actually will help
    you understand... its quite complicated to describe,sorry...
    although its simple to understand once you get used to it. To learn
    you should experiment with a few for.. in loops on different
    objects and see what trace outputs you get.

  • How to use variables in logical file name definition FILE

    Hi Friends,
    How can I use variables in logical file name definition (tcode FILE). The requirement is to pass value in these variables (based on selection criteria), and use it as part of file name. You quick response will be highly appreciated.
    Thanks,
    Kuldeep Joshi

    Hi,
    Thanks for your reply.
    In detail, the scenario is like I have created an Open Hub. Its working fine. Now I am planning to execute this open hub using process chain and for that I have to define the file output on application server along with logical file name (using tcode FILE). The logical file name contains two variables (defined in FILE) i.e. z_dept and z_fiscperiod.
    Filter value in DTP ( I will read these values from Ztable using routine )
    Dept = R&D
    Fisc period = 004/2009
    Variables defined in tcode FILE:
    z_dept for Dept
    z_fiscperiod for Fiscal Period
    Logical file name : <z_dept>_<z_fiscperiod>.csv
    Now the challenge is to populate filter values in these two variables so that the filter value can be used for naming the output file.
    My last option is to read/update SAP standard table used for storing variable values (i.e. PARAMVALUE)
    Please let me know if you can help me in this issue OR is there any standard method/FM to populate value in these variables
    Thanks,
    Kuldeep

  • How do i reference a movie clip instance name from inside child movie clips.

    I have a label I am referencing form a movie clip inside the movie clip which contains the "label_2."
    Here is the code I used:
    MovieClip(parent.parent).gotoAndPlay("return_2");
    Now I need to reference a instance name of a movie clip in side the same scene.
    What would the code be?

    You should probably start by reading the docs and/or google:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html
    http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9 b90204-7fca.html
    http://www.google.com/search?hl=en&q=AS3+events
    Once you got the basics down, look into creating/using your own custom events:
    http://www.google.com/search?hl=en&q=AS3++custom+events
    http://www.adobe.com/devnet/actionscript/articles/event_handling_as3.html
    Event dispatching and event handling is one of the most important things about ActionScript. The sooner you get into them, the better.

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

  • How to solve 'Microsoft.Advertising.WinRT.UI.winmd' contains duplicate type names.

    Hi,
    I am developing windows store 8.1 app. I need to perform unit testing of my app . When I add the project (to be tested) to unit test
    library project by using Add reference I am getting these errors:
    Error
    5
     The .winmd file 'Microsoft.Advertising.WinRT.UI.winmd' contains duplicate type names. Type 'Microsoft.Advertising.WinRT.UI.AdControl'
    is already registered with the in-process server 'CLRHost.dll'.
    UnitTestLibrary
    Error
    6
     The .winmd file 'Microsoft.Advertising.WinRT.UI.winmd' contains duplicate type names. Type 'Microsoft.Advertising.WinRT.UI.AdSettingsFlyout'
    is already registered with the in-process server 'CLRHost.dll'.
    UnitTestLibrary
    Error
    7
     The .winmd file 'Microsoft.Advertising.WinRT.UI.winmd' contains duplicate type names. Type 
    I found a blog here . I tried it but i coudn't see the xml file in this path C:\Program
    Files (x86)\Microsoft SDKs\Windows\v8.0\ExtensionSDKs\MSAdvertisingXaml\6.1\SDKManifest.xml
    I found the file in C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\MSAdvertisingXaml\8.1 . But when i tried to update it is displaying an access denied  message  

    Hi Alok,
    Thank you for posting in MSDN forum.
    Based on your issue, to check if the issue is related to the specified unit test or the VS IDE issue. I suggest you can refer the following document to re-create a simple new unit test with windows store app and then add the windows store app as reference
    to the Unit test project check this issue.
    https://msdn.microsoft.com/en-us/library/windows/apps/jj159318.aspx
    (1)If you did not get same error message in the new unit test project, I doubt that maybe you did not reference the windows store app successfully. So please refer the above document to reference it again check this issue.
    If you still could not reference successfully, please share me the mainly code for the windows store and unit test project.
    Or you could share me your solution include the reference project and unit test project.
    You could upload your sample to the OneDrive and then copy link here.
    (2) If you get same error message in the new unit test, I suggest you could try to repair or re-install the VS IDE and then check this issue again.
    Hope it help you!
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • HT204291 Apple TV no longer shows up in Airplay on my iPad but still works on my iPhone

    Up until the last few days i could watch using my iPad stuff on my Apple Tv in the family room. Today, on both iPads i can no longer connect. I am running the latest versions of software on the mac, itunes and ipad, and apple tv. This is a bit frustr

  • #MULTIVALUE error in WEBI crosstab

    Hello Experts, I am using cross tab in a webi report and I get multivalue error in WEBI When I select the table property "Avoid Duplicate row aggregation", I get the below result As you can see, that in the first image, the Actual cost is calculated

  • How to embed image in email

    Before iCloud I could attach a small image or pdf in my email and the recipient could see it in the body of their email. Now with iCloud all I can seem to do is attach a file as an icon. How can I embed an image now?

  • Is it possible to provide a custom user interface in Formscentral?

    I am new to formscentral and am attempting to transition a city of of pen and paper and into the 21st centrury filling out vehicle accident reports in formscentral.  I have gotten everything to work properly with one exception- how can a user interfa

  • Creating sub menus,  help needed.

    Hi, I created a simple little app which is menu based, everything works fine but i want to add a new menu after selecting one of the main menu items. I can't seem to get this running and I'm totally confused. If someone could give me a little help wi