A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Help ,SetChildIndex over movieclips not working properly..

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    10

    Angry Help ,SetChildIndex over movieclips not working properly..

    The problem is simply,
    the code which works over stage, is not working properly over a movieclip..

    sample, i have many objects to stay at different indexes at flash..

    with that code block below. I add 300 mc's to stage,
    Code:
    for (var j:Number = 0; j<300; j++) {
            var mc2:MovieClip = new MovieClip();
    	stage.addChildAt(mc2, j);
    }
    TO be able to change indexes with different items.. i have random movieclips which have to be placed indexes between 5 and 300.. And everything goes great when i do this directly at stage..

    But when i do this with a movieclip.. example;

    Code:
    for (var i:Number = 0; i<300; i++) {
            var mc3:MovieClip = new MovieClip();
    	my_mc.addChildAt(mc3, i);
    }
    i can't see the movieclips inside.. but i know they are at their right indexes..
    but somehow they are getting behind those fake movieclips..

    What might the reason be? Does anyone have any idea HELP PLEASE...

    Any effort will be appreciated :P

    Note: the layer is at the highest position which i use..

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268
    It should work actually. Have you added my_mc itself to stage?

    Or am I missing something? Why do you need to change these indexes to random ones?

  3. #3
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Not sure what you are calling a fake movieclip, but remember if you have clips added to the stage manually (in the timeline) they will probably sit on top of the additional layers. However, you are manually adjusting the indexes of the MC so, a change should be apparent, so back to my original questions, what are fake movieclips? Can you post a stripped sample?
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  4. #4
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    If you could explain what you are trying to accomplish here, maybe we could help you better.

  5. #5
    Junior Member
    Join Date
    Aug 2010
    Posts
    10

    Angry Actually you re not missing something..

    Quote Originally Posted by caseyryan View Post
    It should work actually. Have you added my_mc itself to stage?

    Or am I missing something? Why do you need to change these indexes to random ones?
    I think this attached example will explain anything.

    The active code block is working without any problems,

    but the commented part, ( only difference is the objects.. one of them is using stage the other is using MovieClip called mmc )

    U can check it.. Actually indexes not random, they re known but programatically i don't know themm :P

    If you can please test the example.. u will get it..

    below is the also codeblock.

    And thank you for your reply.

    Code:
    var ldr:Loader;
    /* Without stage.. 
    
    for (var k:Number = 0; k<300; k++) {
    	var mc4:MovieClip = new MovieClip();
    	mmc.addChildAt(mc4, k);
    }
    ldr = new Loader();
    ldr.load(new URLRequest("cloth.png"));
    mmc.addChildAt(ldr,5);
    
    ldr = new Loader();
    ldr.load(new URLRequest("jacket.png"));
    mmc.addChildAt(ldr,10);
    
    ldr = new Loader();
    ldr.load(new URLRequest("pants.png"));
    mmc.addChildAt(ldr,15);
    */
    
    /* 
    With Stage
    
    for (var k:Number = 0; k<300; k++) {
    	var mc4:MovieClip = new MovieClip();
    	stage.addChildAt(mc4, k);
    }
    ldr = new Loader();
    ldr.load(new URLRequest("cloth.png"));
    stage.addChildAt(ldr,5);
    
    ldr = new Loader();
    ldr.load(new URLRequest("jacket.png"));
    stage.addChildAt(ldr,10);
    
    ldr = new Loader();
    ldr.load(new URLRequest("pants.png"));
    stage.addChildAt(ldr,15);
    */
    Attached Files Attached Files

  6. #6
    Junior Member
    Join Date
    Aug 2010
    Posts
    10
    I think this example will explain anything...

    Trying items to get over other items with the mentioned indexes .. dynamically..

    this is just a simple example i ve made it for you to be able to understand..

    THank you all from now on

  7. #7
    Junior Member
    Join Date
    Aug 2010
    Posts
    10
    Looking FORWARD >> to hear your comments masters

  8. #8
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    You can't use that ldr variable three times in a row like that. You're resetting it everytime you call the new Loader().

    Try ldr1, ldr2, ldr3.

    I still don't understand why you're creating 300 empty movieclips. What is the context of all this? There as to be a better way to be going about things. Don't worry, no one is gonna steal your idea.
    Last edited by Beathoven; 08-30-2010 at 04:31 PM.

  9. #9
    Junior Member
    Join Date
    Aug 2010
    Posts
    10

    Nope...

    Quote Originally Posted by Beathoven View Post
    You can't use that ldr variable three times in a row like that. You're resetting it everytime you call the new Loader().

    Try ldr1, ldr2, ldr3.

    I still don't understand why you're creating 300 empty movieclips.
    I wonder if u checked the attacment,

    Yes u can use the loader like that at least in this sample..

    and i don't normally use it like that,

    And it's working in that example,

    but when everything is same, it's not working with the movieclip.


    Because, the items which i ll add they all have their own properties.
    some has to be added at 60. index. because it has to be in front of items which are lower 60..

    and i create 300 emply movieclips because unless u create that indexes. i won't be able to add a mc directly to 15th or 250th index.

    i think i m clear enough?

    And i suggest u to download the attacment please

  10. #10
    Junior Member
    Join Date
    Aug 2010
    Posts
    10

    HAHAHA :) steal huh

    Quote Originally Posted by Beathoven View Post
    You can't use that ldr variable three times in a row like that. You're resetting it everytime you call the new Loader().

    Try ldr1, ldr2, ldr3.

    I still don't understand why you're creating 300 empty movieclips. What is the context of all this? There as to be a better way to be going about things. Don't worry, no one is gonna steal your idea.
    In normal life,

    can u wear ur t-shirt over your jacket?
    t-shirt is at 60 jacket is at 100th index

    enough?

  11. #11
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    It's cause you got a great big white rectangle inside your movieClip.

    Remove mmc from stage

    And then just create mmc in the actionscript:

    var mmc:MovieClip = new MovieClip();

    addChild(mmc);

    before your for loop

  12. #12
    Junior Member
    Join Date
    Aug 2010
    Posts
    10

    Arigatou

    Quote Originally Posted by Beathoven View Post
    It's cause you got a great big white rectangle inside your movieClip.

    Remove mmc from stage

    And then just create mmc in the actionscript:

    var mmc:MovieClip = new MovieClip();

    addChild(mmc);

    before your for loop
    Thank you ,
    Tesekkurler,
    And thank you in all the languages

    i m not new at oop programming but at flash

    THanks again

  13. #13
    Lunatic
    Join Date
    Nov 2002
    Location
    AS3 Forum
    Posts
    342
    Quote Originally Posted by sincefirsttime View Post
    In normal life,

    can u wear ur t-shirt over your jacket?
    t-shirt is at 60 jacket is at 100th index

    enough?
    Watch your attitude buddy I'm trying to help you here.

    Depending on the requirement, I can think of a 100 better ways to go about it. However you're just providing a meaningless piece of code out of a bigger project with no scope as to what you're trying to accomplish.

    You could set the index of stuff according to other stuff's index. So for instance, let's say jacket as to be over shirt.


    var shirt:Sprite = new Sprite();
    var jacket:Sprite = new Sprite();

    ldr = new Loader();
    ldr.load(new URLRequest("jacket.png"));
    jacket.addChild(ldr);

    ldr = new Loader();
    ldr.load(new URLRequest("shirt.png"));
    shirt.addChild(ldr);

    mmc.addChild(shirt);
    mmc.addChildAt(jacket, mmc.getChildIndex(shirt) + 1);

    You don't wanna load the memory with 300 movieclip instances for no good reason. As well, you're creating additional movieClips on top of those 300 original ones. You're not replacing them when you use the addChildAt method.
    Last edited by Beathoven; 08-30-2010 at 05:04 PM.

  14. #14
    Junior Member
    Join Date
    Aug 2010
    Posts
    10

    OK but.

    Quote Originally Posted by sincefirsttime View Post
    Thank you ,
    Tesekkurler,
    And thank you in all the languages

    i m not new at oop programming but at flash

    THanks again
    Now i m wondering?

    why, i think i ve been adding those childs over that big white rectangle? not am i?

  15. #15
    Junior Member
    Join Date
    Aug 2010
    Posts
    10

    Greatingssssss

    Quote Originally Posted by Beathoven View Post
    Watch your attitude buddy I'm trying to help you here.

    Depending on the requirement, I can think of a 100 better ways to go about it. However you're just providing a meaningless piece of code out of a bigger project with no scope as to what you're trying to accomplish.

    You could set the index of stuff according to other stuff's index. So for instance, let's say jacket as to be over shirt.


    var shirt:Sprite = new Sprite();
    var jacket:Sprite = new Sprite();

    ldr = new Loader();
    ldr.load(new URLRequest("jacket.png"));
    jacket.addChild(ldr);

    ldr = new Loader();
    ldr.load(new URLRequest("shirt.png"));
    shirt.addChild(ldr);

    mmc.addChild(shirt);
    mmc.addChildAt(jacket, mmc.getChildIndex(shirt) + 1);

    You don't wanna load the memory with 300 movieclip instances for no good reason. As well, you're creating additional movieClips on top of those 300 original ones. You're not replacing them when you use the addChildAt method.
    I see u re helping me, and i m grateful for your help...

    Sorry if i meant something rude...

    And i know that i m not replacing them.. i ve passed many things for that project..

    but just a newbie flash learners mistake is what i couldn't see, and won't be able to see unless someone shows me..


    with that way u made up;

    it's not that simple;

    u just added the jacket over shirt..


    but there won't be shirt, there will be t-shirt and won't be jacket , won't be coat there will be another thing which should be over all of these ,

    what i try to mean is when u don't have a jacket but coat,

    then you ll have to make tons of if else blog to check if there is next item ..

    And all meaningless words that i m using are just because of my none-enough english..

    Again, i am grateful for you help.

  16. #16
    Junior Member
    Join Date
    Aug 2010
    Posts
    10

    As a result

    But as a result,

    My BIIIIIIIIIIIIIIIIIIIIIIIIIGGGGGGGGGGGGGGGGGG

    problem has been solved by you.

    Thank you, thank you..

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