PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Refering to nested sprites
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Refering to nested sprites

  1. #1
    THE YELLOW FLASH!
    Join Date
    Feb 2008
    Posts
    57

    Refering to nested sprites

    What I am basically trying to do is

    Like,the yellow boxes are dynamically made,with
    Actionscript Code:
    new Sprite();
    inside that red and blue are also made with new sprite();
    with instance names

    yellow1(red1,blue10),yellow2(red2,blue2) etc...

    How can I refer to yellow1.red1?Like,these are dynamically made,and i dont know the limit,like say it adds on with each click,It will make
    Actionscript Code:
    'yellow'+i
    and red+i etc...

    How can I refer to the ith sprite when the user clicks?Suppose the user clicks yellow5,I want a reusable code that will refer to
    yellow5.red5

    Please help.
    Attached Images Attached Images
    The CodeBreaker!

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Stop using instance names.

    You have a collection of things. Put it in a collection in your code. Use arrays. Or vectors.

    And since you're building a bunch of things that should be more or less identical, you should make a class for those.

    Also, you don't need to know that the one the user clicked on was the fifth one, probably. You already know that it was the one they clicked on. So just use the target and currentTarget properties in your event handler to get the correct instances.

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