A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: how do i :swap "instance of" in code??

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    7

    Question how do i :swap "instance of" in code??

    hey, i have been looking how to do this but i am stuck...
    say i have a symbol composed of different symbols, how can i use actionscript to swap the "instance of" of one of the internal symbols to a different one?

    thanks for any help !!

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Very misleading title. "instanceof" like "is" is an operator which lets you test whether an instance is an instance of a particular class.

    For your question, the answer depends on what you mean by "swap". Do you have another instance already that you want to put in place, or just something in the library?

    If you already have it, you can simply remove the first item with removeChild, set the other one's transform to the same, and then add it with addChild.

    If you don't already have it, you'll have to create it from the library before adding.

    the following assumes that you want to swap parta out and partb in, and they are in a movieclip with instancename container.
    Code:
    var trans:Transform = parta.transform;
    partb.transform = trans;
    container.removeChild(parta);
    container.addChild(partb);

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Posts
    7
    kk thanks

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center