dcsimg
A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: help....please?

  1. #1
    Senior Member
    Join Date
    May 2009
    Posts
    280

    Unhappy help....please?

    ok, ive done everything i can think of with this code and i cant get anything working right. basically i have this movieclip on stage that is suppose to load another movieclip from an swf. in that swf are 31 copies of the movieclip since theres no duplicateMovieclip function in as3...

    I am able to load and add child to the movieclips easy with this,
    PHP Code:
    function duplicateMovieclips():void
    {
    for (var 
    i=0i<movieclipsToLoadi++)
    {

        
    movieclipsDuplicated++;
            
    entrys_mc.addChild(mcV[i]);
            
    //below (which i excluded) are other various bits of code to edit the movieclip and what not. decided not to include it do to...would flood the forum and not make you reply...like last time :P
                            
    }

    i can also remove it just fine with this bit of code here
    PHP Code:
    function removeF():void
        
    {
            var 
    repeat:int 0;
            for (var 
    i=0i<timesToRemove;i++)
            {
                
    entrys_mc.removeChild(mcV[i]);
                
    repeat++;
                
    movieclipsToLoad--;
                if(
    == timesToRemove-1)
                {
                    
    loadSelected(); //THE PROBLEM
                
    }
            }
            
        } 
    what this swf is trying to do is record the year and the month the user clicks on and then return every day's data from the xml if a day is filled out. when removeF(); executes, i get the error
    Code:
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    pointing at entrys_mc.removeChild(mcV[i]);...but when its NOT there, loadSelected(); that is, it works just fine...i even put a trace statement in it. the whole if condition works fine to.

    loadSelected is the one that retrieves the text needed to load in the movieclip. whatever year and month the user selects, it loads the information of it and puts it in a string. then it displays in the dynamic text field inside the movieclip.

    also, WHEN THE SWF IS LOADED it loads all 31 movieclips using this.
    Code:
    for (var i = 0; i < 31; i++)
    	{
    		var groupMC:MovieClip=MovieClip(clip.getChildByName("group" + i));
    		mcV.push(groupMC);
    		trace("repeat # = " + i);
    	}
    ...i would really appreciate any help on this...........

  2. #2
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Maybe this will work, but I'm not sure if it will remove the mc's in the right order:
    PHP Code:
    entrys_mc.removeChild(entrys_mc.getChildAt(i)); 
    rather than "entrys_mc.removeChild(mcV[i]);"
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Are you sure that it is the removeChild line in removeF that is throwing that error? Not something in loadSelected?

    Is this only done once, or multiple times? Does loadSelected result in any of the mcV entries being reparented?

  4. #4
    Senior Member
    Join Date
    May 2009
    Posts
    280
    @florain - "The suplied index is out of bounds." Also not sure what your trying to do there. Also mcV is a vector.

    @5TOF no, load selected is throwing the error. when i remove it, im able to remove child just fine. but when its there, it i gives the error that it cant remove it.... Again, i put a trace statement in the if conditional and that works fine. but when i throw that function in there it gives the error.

    loadSelected is this function.
    PHP Code:
    function loadSelected():void
        
    {
        
    //    trace(yearSelected);
        //    trace(monthSelected);
        
    trace("LOAD SELECTED F");
            for (var 
    i=0;i<numberOfChildren;i++)
            {
                if(
    entrysXML.entry[i].year == yearSelected)
                {
                    if(
    entrysXML.entry[i].month == monthSelected || entrysXML.entry[i].month == monthSelected.charAt(1))
                    {
                        var 
    aText:String = (entrysXML.entry[i].text);
                        
    textV.push(aText);
                        var 
    aDay:String entrysXML.entry[i].day;
                        
    dayV.push(aDay);
                        var 
    aHeadline:String = (entrysXML.entry[i].headline);
                        
    headlineV.push(aHeadline);
                        var 
    aImgsrc:String = (entrysXML.entry[i].imgSrc);
                        
    imgsrcV.push(aImgsrc);
                        
    movieclipsToLoad++;
                        
    trace("MCTL " movieclipsToLoad);
                    }
                    
                }
            }
            
    duplicateMovieclips();
        } 
    It retrives the day, the text, the headline, and the image to load. In duplicateMovieclips function, it places these elements in the right position...

    It successfully does this...once.

    This is done multiple times if the user clicks on a month more than once.

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    What is timesToRemove?

    It seems like you might be either getting the same item in mcV more than once, or attempting to remove the same item from entrys_mc more than once.

  6. #6
    Senior Member
    Join Date
    May 2009
    Posts
    280
    timesToRemove is a variable. Its a number that adds 1 every time duplicateMovielcips is executed. Basically its a counter. How ever many times a child is added will be how many times a child is to be removed in the removeF funciton.

  7. #7
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Then it should be:
    PHP Code:
    entrys_mc.removeChild(entrys_mc.getChildAt(i-1)); 
    What this does is remove the children from entrys_mc, based on their depth, so the mc's added first will be remove first too.
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  8. #8
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Ah. But the same movieclip cannot be in the display list more than once. So I think what is happening is that the second (and subsequent) times through duplicateMovieClips, you attempt to add things to entrys_mc that are already on it, resulting in nothing happening. Then, you attempt to remove it twice, and the second time fails because it's already gone.

    Your duplicateMovieClips function isn't duplicating anything. It is only putting stuff on stage that already exists.

  9. #9
    Senior Member
    Join Date
    May 2009
    Posts
    280
    What im trying to do, and have successfully done so far, is be able to load the movieclips from components.swf, place them on the stage with the "duplicate"movieclip function, and edit them. there instance names in components.swf is group0, group1, group2, etc. What im trying to do is be able to, after i remove the movieclips, add them AGAIN but a different amount depending on what the user clicks.

  10. #10
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    The simple solution is to guard the removeChild call with a contains call. But the better solution is to not try to remove things that aren't on there in the first place.

    Code:
    function removeF():void{
      var repeat:int = 0;
      for (var i=0; i<timesToRemove;i++){
         if (entrys_mc.contains(mcV[i]){
           entrys_mc.removeChild(mcV[i]);
         }
         repeat++;
         movieclipsToLoad--;
         if(i == timesToRemove-1){
            loadSelected();
         }
      }
    }

  11. #11
    Senior Member
    Join Date
    May 2009
    Posts
    280
    it works! thanks alot! i had alot of i variables in my script, so i replaced i with j and it works!

  12. #12
    Senior Member
    Join Date
    May 2009
    Posts
    280
    nevermind. got to exited. if i click on the same month and year it does nothing that i can see in the display. but it doesnt come up with an error. but when i click on a different year and month, none of there days load...

  13. #13
    Senior Member
    Join Date
    May 2009
    Posts
    280
    NEVERMIND AGAIN... it still doesnt work. j or i or however you make that variable to be somehow turns up to be 31....wow what?

  14. #14
    Senior Member
    Join Date
    May 2009
    Posts
    280
    pressxml.txt

    Press.fla

    Components.fla

    Those are the three files. Components contains all the movieclips. Press is what im working in. I figure it would be easier because im so bad at explaining things. sorry.

  15. #15
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I might be able to take a look at these this weekend if they're cs3 compatible.

  16. #16
    Senior Member
    Join Date
    May 2009
    Posts
    280
    ComponentsCS3.fla

    PressCS3.fla

    It would really be appreciated man. These are the cs3 versions.

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