The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 7 of 7

Thread: Name all instances of a movieclip dragged on to the stage

  1. #1

    Name all instances of a movieclip dragged on to the stage

    I have a number of instances of a MovieClip on stage. These are dragged onto the stage and arranged manually. Now, I would like to alter the instances during run time, using as2 code.
    My question is, how can I name all the instances of the same MovieClip dragged onto the stage, using as2 code?
    (Please specify if the solution involves exporting the library MovieClip with an identifier name)

  2. #2
    Code:
    original_mc._name = "newName_mc";
    trace(newName_mc);
    2006-11 GlosRFC - Searching 8,168,684,336 brain cells

  3. #3
    Yep, I got that bit!

    The thing is, first I need to check whether original_mc is an instance of library_mc, which is in the library, exported with id "library_mc".
    How can I do that in as2? Or can I?

  4. #4
    Not sure what you mean by check...if you haven't attached it to the stage at some point, then it won't exist and so can't be renamed:
    Code:
    this.attachMovie("library_mc", "attached_mc", this.getNextHighestDepth());
    trace(attached_mc);
    attached_mc._name = "changed_mc";
    trace(changed_mc);
    Although changing the name seems to be a waste of time, as you can give it any valid name at the point you attach it. Or delete an existing attached instance, and simply attach another instance with a new name.

    Also, a linkage_ID won't have any effect on instances added, and named, manually on the stage. If you're asking "Can I get the linkage_ID for any movieclip" then the answer is going to be no.
    2006-11 GlosRFC - Searching 8,168,684,336 brain cells

  5. #5
    The above code gives some helpful hints. But my exact question is this:

    * There is library_mc, in the library.
    * I drag library_mc to the stage a number of times, and arrange these instances as I want.
    * (On the stage, there are also instances of movieclips other than library_mc)
    * I want to alter the (dragged to stage) instances of library_mc dynamically
    * I need to iterate through all movieclips on the stage, find those which are instances of library_mc, and alter them.

    (Here I wanted to automate the naming also so that I don't have to manually name some 15 or 20 instances every time)

    Is this possible?

  6. #6
    Possible? No...See my last sentence above.

    The Library name (and Linkage ID) are properties of the Library, which is NOT compiled into your SWF. It would defeat the whole purpose of Flash and the Small Web Format (SWF) concept if this was to occur.

    However, you can use JSFL to dynamically identify which clips are instances of a Library item, rename them, etc., but only within the Flash authoring environment. JSFL can interrogate the Library properties...for example, the following code will display a dialog box containing the Linkage Identifier value for the selected Library symbol:
    Code:
    alert(fl.getDocumentDOM().library.getItemProperty("linkageIdentifier"));
    The following code will apply an instance name to a particular symbol (in this case, a symbol residing on frame 1, layer 1, of the main timeline:
    Code:
    fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].name = "newInstanceName_mc";
    You can see that objects on any timeline are stored in an array so, just as with Actionscript, you can also iterate through your symbols; rename them; increment the instance names; or whatever you want....while editing your FLA. But you won't be able to do the same with an SWF in the Flash Player. In the above code, the "fl" object represents the Flash application, the "documentDOM" object represents the FLA, and the "library" references the Library Panel; none of which exist within an SWF.
    2006-11 GlosRFC - Searching 8,168,684,336 brain cells

  7. #7
    Thank you for the detailed explanation
    So it seems that I don't have to take more effort trying to figure out which clips are instances of which item.

    Anyhow, I used a work around for the problem. All the required instances were put in the lowest layer. So an iteration of _root symbols has these instances at the end. Now if we can keep track of their count, we have exactly those instances we want!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012