A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [RESOLVED] link to a sprite/mc in library from as3

  1. #1
    Senior Member
    Join Date
    Jul 2008
    Posts
    418

    resolved [RESOLVED] link to a sprite/mc in library from as3

    how do you create a new mc or sprite that does not have an external as file linked to it,
    from an external as file class in as3 code?

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Go to the Properties for the object in your Library, open the Advanced view and check "Export for ActionScript" - that will auto-fill a couple fields for you.

    Change the "Class" to whatever you want the object to be called - say "MyClip" and hit OK - you should get a nag message about a missing class file, ignore it.

    Now in your code you can say: var mc = new MyClip(); and create new instances of that library symbol just like any other object.

  3. #3
    Senior Member
    Join Date
    Jul 2008
    Posts
    418
    ok thanks!

    and how do I make that sprite a layer below the already existing mc.
    right now, the created sprite overlaps the parent mc.
    Last edited by omniscient232; 01-21-2009 at 12:43 PM.

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    When you add it to the stage you can specify a z-index...so if you wanted to send it all the way to the back you could use:

    addChildAt(mc, 0);

  5. #5
    Senior Member
    Join Date
    Jul 2008
    Posts
    418
    ok thanks
    one more question:
    if u do addChildAt(mc,0);
    then the parent will become at index 1?

  6. #6
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Yep - the AS3 display list will shift things around automatically (much more friendly than AS2!)

  7. #7
    Senior Member
    Join Date
    Jul 2008
    Posts
    418
    ok,
    thanks alot!

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