Dynamic MovieClip reference

Okay, how does one reference a MovieClip instance dynamically in AS 3.0?
Example, I create a new instance of a "marker" MovieClip class that inherently has within it a series of embedded MovieClips labeled: "m1", "m2", "m3" etc ... and I want to be able to dynamically reference those embedded MCs.  I used to do this all the time in AS 2.0, and can't recall how to do it in AS 3.0.
I know it is something like this:
number = 1;
marker = new StaticMarker();
var thisMarker = this.marker.m[number];
thisMarker.visible = true;

Try:
var thisMarker:MovieClip = this.marker["m"+number];

Similar Messages

  • LV2012 crashes when opening LV2010 project containing OOP and dynamic FPGA references

    I have a project that was written under LV2010 and has no problems that I am aware of. This project contains OOP and dynamic FPGA references. I am trying to upgrade this project to LV2012. When opening this project under LV2012 (or any subVI containing OOP) I get an error message, as shown in the attached screenshot. Has anyone else observed this problem? I haven't found any relevant postings on this forum yet.
    My project is quite large, with many accessors.
    Thank you for any assistance you can offer.
    Attachments:
    LV2012_Crash.PNG ‏22 KB

    Thank you for your response, but the Discussion Forums link that you provided refers to a problem that occurs when exiting a running executable. My problem is different. I am simply opening up a LV2010 project using LV2012. No running of my program is involved.
    Anyway, after several days of work, I narrowed down the cause of the LabVIEW crash. My code contained a Disable structure, and within that Disable structure there was a subVI that had an unwired object terminal (set to dynamic dispatch). Deleting the subVI in the Disable structure eliminated the LabVIEW crashing. Weird behavior.

  • Accessing Dynamic Movieclip Children

    There is a lot of code that I have but here is snippet to get to the point.  I have created a Movicelip called via actionscript called "McButton".  Then I created 10 MovieClips within that MovieClip ("McDot0", "mcDot1", etc).  I need to know how to access mcButton.mcDot3 to change its color when button3 (mc already on stage) is clicked but can not figure it out.
    I have tried both of these below but it does not work:
    mcButton.mcDot3.transform.colorTransform = cityColor;
    getChildByName("mcButton").getChildByName("mcDot3").transform.colorTransform = cityColor;
    This is the code below that I have used to create the Dynamic Movieclips:
    var button:Container = new Container();
    button.name = "mcButton";
    this.addChild(button);
    for (var a:int = 0; a < 10; a++) {
         var dot:Dot = new Dot();
          dot.name = "mcDot" + a;
        MovieClip(getChildByName("mcButton")).addChild(dot);
    Can someone please help me see the light.
    Thanks

    In order to change a color using color transform, first you must create a new ColorTransform object and than assign it to transform.colorTransform property.
    i,e,
    var cityColor: ColorTransform = new ColorTransform();
    getChildByName("mcButton").getChildByName("mcDot3").transform.colorTransform = cityColor

  • Dynamic Symbol Reference Problem

    I have 24 separate symbols (or buttons) all grouped into a parent symbol. Each button sets the same variable (selectedyear) to the main timeline. Patterned after similar things I've done in Flash, the sequence of actions should be:
    (1) Send the previously selected button to its unselected state (or frame)
    (2) Set the variable selectedyear (on the main timeline) to its new value
    (3) Send the clicked button to its selected frame
    To do this the button reference has to be dynamic. The button instance names are "_1789", "_1793", "_1803", etc. Here's the code I've used, placed on an element (PNG) inside the button symbol:
    sym.getComposition().getStage().getSymbol("yearselector").getSymbol("_"+sym.getComposition ().getStage().selectedyear).stop("unselected");
    sym.getComposition().getStage().selectedyear = "1793";
    sym.stop("selected");
    It isn't working.
    This command does return the expected string, "_1793", for instance:
    console.log("_"+sym.getComposition().getStage().selectedyear);
    Hard-coding the target instance name however works where the dynamic, concatenated reference fails:
    sym.getComposition().getStage().getSymbol("yearselector").getSymbol("_1789").stop("unselec ted");
    I've also tried passing four-digit strings ("1789", etc.) to a function on the main timeline, which also fails unless the instance name is hard-coded:
    sym.changeyear = function(clickedyear){
        sym.getComposition().getStage().getSymbol("yearselector").getSymbol("_"+selectedyear).sto p("unselected");
        sym.getComposition().getStage().getSymbol("yearselector").getSymbol("_"+clickedyear).stop ("selected");
        selectedyear=clickedyear;
    What am I doing wrong?
    Bill

    Setting the symbol name to a variable before referencing the symbol worked, a.jones.LargeAnimal. Something about the concatenation within the object reference was breaking it. Instead of this function:
    sym.changeyear = function(clickedyear){
         sym.getComposition().getStage().getSymbol("yearselector").getSymbol(" _"+selectedyear).stop("unselected");
         sym.getComposition().getStage().getSymbol("yearselector").getSymbol(" _"+clickedyear).stop("selected");
         selectedyear=clickedyear;
    I now set the concatenated symbol name to a variable first as in your example:
    sym.changeyear = function(clickedyear){
         sym.getComposition().getStage().getSymbol("yearselector").getSymbol(selectedyear).stop("u nselected");
         clickedyear="_"+clickedyear;
         sym.getComposition().getStage().getSymbol("yearselector").getSymbol(clickedyear).stop("se lected");
         selectedyear=clickedyear;
    I now recall running into something like this in ActionScript. Even though logically the code should have worked either way, on rare occasions I'd have to pull some operation out of a complex reference and set it to a variable first to make the reference work.
    Iterating through the array would probably have worked as well, but this solution took less effort. Thanks for the help, guys!

  • Dynamic movieclip duplication

    Hi Everyone,
    I am working on dynamic duplication of movieclip when the button is pressed one by one.
    In that movieclip there are two buttons ok and cancel.
    Here is the piece of code:
    var new_panel:please_wait = new please_wait;
    click_btn.addEventListener(MouseEvent.MOUSE_DOWN, generate);
    function generate(e:MouseEvent):void{
        new_panel = new please_wait;
        addChild(new_panel);
        new_panel.addEventListener(MouseEvent.MOUSE_OVER , over_evt);
        new_panel.addEventListener(MouseEvent.MOUSE_DOWN , start_evt);
        new_panel.addEventListener(MouseEvent.MOUSE_UP , stop_evt);
        new_panel.ok_btn.addEventListener(MouseEvent.MOUSE_DOWN , ok_evt);
        new_panel.cancel_btn.addEventListener(MouseEvent.MOUSE_DOWN , cancel_evt);
    function start_evt(e:MouseEvent){
        new_panel.startDrag();
    function stop_evt(e:MouseEvent){
        new_panel.stopDrag();
    function ok_evt(e:MouseEvent){
    function cancel_evt(e:MouseEvent){
        removeChild(new_panel);
    if i create two movieclip, then how i remove a particular movieclip.
    i also attached the screen shot for reference..
    Anyone Knows reply..
    Thanks in advance..
    Regards
    Saransoft

    I guess the problem with your code is your message box is getting duplicated twice.
    You want to remove the previous instance if it is already on the stage.
    If I am correct you can use the following code:
    var new_panel:please_wait = null;
    click_btn.addEventListener(MouseEvent.MOUSE_DOWN, generate);
    function generate(e:MouseEvent):void{
        if(new_panel.parent)
              removeChild(new_panel);
        new_panel = new please_wait;
        addChild(new_panel);
        new_panel.addEventListener(MouseEvent.MOUSE_OVER , over_evt);
        new_panel.addEventListener(MouseEvent.MOUSE_DOWN , start_evt);
        new_panel.addEventListener(MouseEvent.MOUSE_UP , stop_evt);
        new_panel.ok_btn.addEventListener(MouseEvent.MOUSE_DOWN , ok_evt);
        new_panel.cancel_btn.addEventListener(MouseEvent.MOUSE_DOWN , cancel_evt);
    function start_evt(e:MouseEvent){
        new_panel.startDrag();
    function stop_evt(e:MouseEvent){
        new_panel.stopDrag();
    function ok_evt(e:MouseEvent){
    function cancel_evt(e:MouseEvent){
        removeChild(new_panel);

  • How can I create dynamic file references in Power Query?

    Hi all,
    I'm new at using PowerQuery, and so far I like it. There's one thing I am struggling with though... Once I have set up my PoweQuery connections, I don't find an easy way to change the file to which the query is connecting. I'm using it for a monthyl recurring
    process, and every month the source data to query on woudl be different. The same in format/structure, but just a different dataset.
    Is there a way to make the source setup more dynamic? Can I for example in a parameters sheet enter the name and path of the new source file and update the queries?
    Currently the Advanced editor shows me following file reference:
    let
        Source = Excel.Workbook(File.Contents("Z:\Templates\EMEA\Source Data Tables\EMEA_EW_Source_Data_for_Power_Queries v1.xlsm")),
    Thanks in advance for suggestions

    Yes, this is something that you can do with Power Query. Here's how you can do it:
    Create a table in Excel containing your parameter value. Let's say that it has one column, called ParameterValue, and one row.
    Create a new Power Query query that gets the data from this table. Call the query something like ParameterQuery.
    In your original query you will now be able to reference values from your parameter query by saying something like this:
    Source = Excel.Workbook(File.Contents(ParameterQuery[ParameterValue]{0})),
    HTH,
    Chris
    Check out my MS BI blog I also do
    SSAS, PowerPivot, MDX and DAX consultancy
    and run public SQL Server and BI training courses in the UK

  • Accessing Child Dynamic MovieClips

    Dev Environment: Flash 9 Pro
    Alright, I have a movie that has one movieclip (imageHolder,
    this is defined in the Library and is an empty movieClip used as a
    place holder) which is on the stage. I read in and load images to
    the flash file, and create them in their own movie clips WITHIN
    imageHolder like so:
    ========================
    var nm= imageHolder.createEmptyMovieClip("swfHolder"+i,-(i *
    10));
    nm.loadMovie(filename);
    ========================
    Obviously this is a code snippet, I am using the LoadVars
    object to load these files. Once everything is loaded, it is
    displayed on the stage, with a depth in order from first image to
    last (first image on top, last image on the bottom). After this, I
    have an interval set, to call a function called "selectImage" which
    gets a variable called photonum, and changes images to the number
    you have passed in. In selectImage, I ensure that the image that is
    coming up next is one depth level below the currently displayed
    image using swapDepths, and I am constantly incrementing a variable
    called "curdepth" which is global, and always assigning that depth
    to the currently displayed image to that depth. So, the current
    image will be displayed at depth 30, and the next image up will be
    displayed at depth 29. Then I fade the current image out using the
    tween object, and it works like a charm! To reference these
    MovieClips I use the following code:
    ====================
    var cmc:MovieClip = eval("imageHolder.swfHolder" + (curpho +
    1));
    var nmc:MovieClip = eval("imageHolder.swfHolder" + (nexpho +
    1));
    // Force current clip to front
    cmc.swapDepths(curdep);
    // Force next clip to one below front
    nmc.swapDepths(curdepth - 1);
    ====================
    and this works perfectly... in flash. Once it's on the page,
    or displayed within the standalone movie player, everything goes
    south. I assigned the typeof cmc and nmc to a textbox, and i got
    "movieclip", in flash and on the page. However, if I store
    "cmc.getDepth()" to the textbox, I get "[type function]" in flash,
    but, on the page "undefined" It seems anything that is specific to
    the MovieClip object, such as getDepth(), or swapDepths() is
    undefined when I plug it into the textbox, but, things that are
    inherited, such as enabled, _x, or _y are all available for my
    perusal and setting.
    Does anyone have any idea how to remedy this? I can attach
    all my code in a couple of hours if necessary. I have tried not
    putting the loaded images into the imageHolder, and I found that
    didn't help. I have also tried a combination of adding "_level0."
    and "_root." to my cmc and nmc references to no avail. Any help
    would be greatly appreciated.

    Seems it had something to do with my Flash Installation...
    Tried it on another computer and everything was fine. What a
    pain!

  • Dynamic MovieClip (Loader) Names

    I have an array of data that I'm using to create thumbnails and labels.  I'm using "Loader" to load the thumbnails (sample code below) but what I'm wondering is how I can make the name of the loader dynamic so that each child gets named "image1, image2, ...".  I tried adding "[i]" after the "image" for each item in the code but it complained about missing semicolon before left bracket.
    var image:Loader = new Loader();
    var target_image:URLRequest = new URLRequest("images/" + xmlData.Product[i].id + ".png");
    image.name = "image_"+[i];
    image.load(target_image);
    image.x = 80;
    image.y = 60;
    addChild(image);
    I saw an example for MovieClip which looks like it's exactly what I want to do but it doesn't work for Loader (and I don't know if it works at all).  In the example I saw, the last line in the above code would be:
    image.addChild(this["image"+i]);
    Also, if I can't make the names of the loaders dynamic, how would I add event listeners to each of the thumbnails so that when one is clicked it executes code specific to that particular image (such as open up a large version of it).  Usually you have the listeners linked to the names of the children, but if you have 10 children named "image" then that makes it a bit tough.
    Any help would be greatly appreciated.  Thanks!

    you can do any one of a few things.  the two most commonly used techniques:
    1.
    var mc:MovieClip=new MovieClip();
    addChild(mc);
    mc["image"+i] = new Loader();
    var target_image:URLRequest = new URLRequest("images/" + xmlData.Product[i].id + ".png"); mc["image"+i].load(target_image);
    mc["image"+i].x = 80;
    mc["image"+i].y = 60;
    mc["image"+i].ivar = i;  // probably needed at some point
    mc["image"+i].whateverProperty = whatever;  // this is the most flexible technique
    mc["image"+i].addEventListener(MouseEvent.CLICK,clickF);
    function clickF(e:MouseEvent){
    //do something with e.currentTarget.ivar
    //do something with e.currentTarget.whateverProperty
    2.
    var image:Loader = new Loader();
    var target_image:URLRequest = new URLRequest("images/" + xmlData.Product[i].id + ".png");
    image.name = i;  // this is more useful than the name you were using
    image.load(target_image);
    image.x = 80;
    image.y = 60;
    addChild(image);
    image.addEventListener(MouseEvent.CLICK,clickF);
    function clickF(e:MouseEvent){
    //do something with e.currentTarget.name
    //you can do most things with the above but this can sometimes be awkward.

  • MovieClip references from a class

    I have a files that has movie clips and nested movie clips on the stage. I am now writing a class and want to give the MCs event handlers and other properties.
    When I do something like the following:
    myMC_mc.MyOtherMC_mc.mouseEnabled = false;
    I get the error:
    1120: Access of undefined property myMC_mc.
    I added this to the top of my class and it seems to take away the error, but I thought this was not needed in AS3 anymore.
    private var myMC_mc:MovieClip;
    private var myMC_mc.MyOtherMC_mc:MovieClip;
    What do I have to do to not get the error? How is this done right?
    Thanks a lot for any help!

    you can't access/reference objects until they exist.
    if your class is the document class and myMC_mc doesn't exist on frame 1 of the main timeline, you'll have a problem.

  • Dynamic Movieclips

    Hi
    I am writing an application which manipulates triangles and
    squares. I wish to give user control to the number of triangles and
    sqaures created and allow the user to manipulate each object.
    Now I am using attachmovieclip e.g.
    _level0.attachMovie("MyTRA_mc_link", MyMc,
    _level0.getNextHighestDepth(), {_x:412.5, _y:225, _alpha:78});
    and i have a list of names an array which allow me to name up
    to 26 variables - MCA, MCB, MCC ... MCZ.
    Now the user functions i have are:
    use of THIS for drag and drop
    then to move x or y or rotate i have to write the actual code
    for each function so i have MOVE_MCA(key_press), which is selected
    by a case statement and then depending on the key pressed i have
    movement in x, y or a roatation.
    Now my question is - is their a simplier and more dynamic way
    to do this. I tried writing functions which use the movieclip as a
    function but could not get this to work ?

    Hi
    Ok!, I think I understand what you want to do, so let's see
    I take it that the Triangle and Square are MC's in the
    Library? and you want the user to create as many of each as they
    wish or do you define a fixed amount?
    Once created they can rotate CW or CCW and move around on the
    x and y plane?.
    I will write some code, while I wait for your reply. This is
    relatively simple and shouldn't take more than 15 minutes to
    complete.
    Back soon

  • Dynamic Class Reference in Custom Class

    I've created a custom class that I want to be able to
    dynamically insert a movie clip from the library. I'm running into
    trouble because I want to access the clip as a property of the
    custom class object (ie: so it can be swapped out for another
    library clip after instantiation, among other things). I'm using
    getDefinitionByName() but I can't use it outside my addDiagram()
    function (see attached code) because the string variable that
    stores the name of the library clip isn't defined until after the
    custom class constructor function. Any help is appreciated!
    Thanks,
    -Erik

    i'm not quite following - are you saying you want to access
    panelDiagram in functions other than your addDiagram function? just
    take your variable definition out of your function and make it a
    class variable eg put the following line above your constructor:
    private var panelDiagram:*;
    and in the second line of your addDiagram function use:
    panelDiagram = new diagramClass();
    sorry if this isn't your answer, if it isn't i'm struggling
    to understand the problem.

  • Dynamic page references within document

    I am working on a small binder style book that has 8 sections. The project is destined to be updated frequently and the client only wants to reprint the appropriate sections. So the question is, within the body text are numerous page references that will need to be updated as the page count potentially changes. I would like to use a section page numbering format (eg. 1-1, 1-2,...2-1, 2-2,...etc) to avoid conflicts with the TOC. Is there a way to tag the page references (see page 3-12 for more info) so that they will update themselves automatically, rather than having to find and replace them each time. I'm not even sure what this feature would be called.
    Thanks for your help.
    InDesign CS3
    Pat

    dtptools.com has a cross-reference plug-in for ID CS2, 3, and 4.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • Attach eventlisteners to dynamic movieclips and pass a variable.

    Hi there,
    I have a mc (changeColorMc) and three movieclips. The three
    movieclips are created on the fly (so there could be more
    movieclips) and filled with a color from an Array. This works fine.
    Now I want to add an eventlistener for each movieclip, so
    when someone push one of the movieclips the movieclip with the name
    "changeColorMc" gets that same color from the colorArray.
    My question is: How can I pass the color value from the
    colorArray to the buttonPressed function? Is this possible?
    I was also thinking that I had to create three buttonPressed
    functions ie. buttonPressed1, buttonPressed2 and buttonPressed3 and
    attach these to the created movieclips.. but how? Because I don't
    know up front how many movieclips there will be..
    Thanks Peter.
    My code:

    Frankly, I am yet to see any piece of code that could be
    considered perfect and the only way to deal with a task. There are
    so many dependencies that what looks perfect today may turn out to
    be a total failure tomorrow and vise versa.
    My question about better way was purely conceptual. What
    would be the perfect code if it was written in English?
    Congratulations on purchasing Moock's book. So far I think it
    is the best single piece about AS3. I am sure you will be up to
    speed in no time.

  • Dynamic MovieClip Names

    I have an array that houses the names of six movieclips. I randomly select three of them. I am trying to get my randomly chosen movieClips to do what I want them to do. I have tried the following code to get the first to fade in:
    stop();
    // import tween classes
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    var FirstPersonAnimation:Object;
    trace("mc"+[_global.FirstPerson]);
    FirstPersonAnimation = new Tween("mc"+[_global.FirstPerson], "_alpha", Regular.easeInOut, 0, 100, _global.FadeInTime, true);
    FirstPersonAnimation.onMotionFinished = function() {
    _root.nextFrame();
    But it does not work. The trace comes back with the full movie clip name ex: mcTom, but even though that value comes up in the trace, the AS doesn't see it as a movie clip. Any thoughts on how I can correct this?
    -Kirk

    I'm not sure what is involved with _global.FirstPerson, but when you use it the way you do, you are just feeding a string into the Tween.  You need to convert that string into an object using array notation:
    this["mc_"+_global.FirstPerson]

  • Dynamic movieclip creation from library

    Version: Flash CS3, AS3
    To add a new movieclip to the stage from the library you can
    do something like this:
    var newMC:libraryMC = new libraryMC();
    this.addChild(newMC);
    To do this, however, I need to know the name of the library
    movieclip beforehand (in this case, libraryMC). What do I do when I
    only receive the name at runtime?
    ie:
    randomMC = "libraryMC";
    In AS2, you could use this.attachMovie(randomMC,"newMC",x),
    but that is no longer supported in AS3.
    So how is this situation handled now?
    Thanks
    Rick

    Thanks kglad - that's what I wanted.

Maybe you are looking for

  • SFTP listening channel is not picking the file from remote location

    Hi, We are facing an issue in B2B 11g while connecting to the remote trading partner through SFTP. It is not picking file from root as trading partner has given the file location as ' . ' root only. They have provided us one certificate file (.dat fi

  • How can I define Tax Jurisdiction code in CRM?

    Hi, I want to repliate some business partners into CRM. But when processing IDocs of BP, there's an error for some of them like "Jurisdiction code 490333321 is not defined". So how can I find and define tax Jurisdiction code in CRM? Another question,

  • I can no longer drag and drop my bookmarks or url icons

    All of a sudden I can no longer drag and drop my bookmarks around the sidebar or drag url icons into the toolbar or sidebar. The problem seems to have coincided with the download of 3.6.14. The only other thing I did around that time was download Ado

  • I've lost my AirPort icon in network settings - can't get wifi - how do I get it back..??

    So I'm pretty green whe it comes to computers but trying to work through this.... My Macbook Pro's wi fi dropped out - I tried to re-activate it and inadvertedly removed the airport icon from my network connections options.. I'm assuming it's a fairl

  • Problems installing JDeveloper

    Hi all, I have recently installed JDeveloper from patch 6739235. I connected to vision instance of apps version 11.5.10.2 and tested it, it gave me success. When i built the tutorial.jpr, it builds with 25 warnings & 0 errors. And when i try to run t