12 Replies Latest reply on Jun 6, 2007 8:44 AM by kglad

    loadClip question

    chrissy b
      i was just reading a post regarding loading mc's into child clips and i am wondering if what i want to do is even possible?

      i have a movie where i load several thumbnails into a horizontal panel. i would like to load a single .gif into each of the new thumbnail mc's so that when the thumbnail is rolled over, the .gif appears. here is the code of what i have that is not working:

      if there is another route i should take, i would love to hear it. thank you for any help/advice!
        • 1. Re: loadClip question
          kglad Adobe Community Professional & MVP
          you can either

          1. create a parent and child movieclip for each image, define your mouse handlers for the parent and load into the child

          or

          2. load into a movieclip and define your mouse handlers after loading is complete
          • 2. Re: loadClip question
            chrissy b Level 1
            so since i have 25 thumbnails..you are sayiing i would create 25 mc's and then load all of those into one mc for the horizontal panel? wouldn't it still have the same problem in loading the rollover state image underneath the thumbnail image? maybe i am not understanding you correctly...
            • 3. Re: loadClip question
              kglad Adobe Community Professional & MVP
              you'll need 25 (option 2) or 50 (option 1) movieclips. 50 is easier to code.

              and if you want all the movieclips in a panel movieclip, then you'll need 26 or 51 movieclips.
              • 4. Re: loadClip question
                chrissy b Level 1
                hi kglad...thanks for your response. i made a small change...instead of loading that gif...i just made it vector art in flash so that i can just attach it. is it possible to load the thumbnails into an attached movieclip? i am just wondering if this could be a possible work around to avoid making 50 clips and keep my code as simple as possible.

                thanks again for your help.
                • 5. Re: loadClip question
                  kglad Adobe Community Professional & MVP
                  sure, you can load into any movieclip (or _level) you want including an attached movieclip.

                  but if you need more than 1 loaded image to be visible at any one time, you'll need to use more than 1 target movieclip (unless you load into other levels).
                  • 6. loadClip question
                    chrissy b Level 1
                    so could i create a loop to create all the imgs i need and then load my thumbnail into those images from the loop - such as this:

                    for (r=0;r<prodID.length; r++) {
                    var rollovermc:MovieClip = mainContainer.attachMovie("gradient", "rollovermc", mainContainer.getNextHighestDepth());
                    }



                    var container:MovieClip = rollovermc.createEmptyMovieClip(prodID[j], rollovermc.getNextHighestDepth());
                    var mcLoader:MovieClipLoader = new MovieClipLoader();
                    var imageListener:Object = new Object();
                    mcLoader.addListener(imageListener);
                    mcLoader.loadClip(imagePath + prodID[j] + ".png", container);
                    • 7. Re: loadClip question
                      kglad Adobe Community Professional & MVP
                      yes, except all the lines of code referencing container should be in your for-loop and j should probably be r.

                      and you can apply mouse handlers to rollovermc (within that for-loop) without problem.
                      • 8. Re: loadClip question
                        chrissy b Level 1
                        hi kglad...i ended up getting some help from a coworker and he had me change it to this:

                        function addProdImg():Void {

                        // Number of products in scroller
                        var numProd:Number = prodID.length;
                        var mcLoader:MovieClipLoader = new MovieClipLoader();
                        var imageListener:Object = new Object();

                        mcLoader.addListener(imageListener);

                        for (var r:Number=0; r<numProd; r++) {
                        var rollovermc:MovieClip = mainContainer.attachMovie("gradient", "rollovermc_"+r, r, { _x:(r*120), _y:2 } );
                        var container:MovieClip = rollovermc.createEmptyMovieClip("container", 1);
                        rollovermc.grad._alpha = 0;
                        mcLoader.loadClip(imagePath + prodID[r] + ".png", container);
                        initMouseEvents(rollovermc);
                        }

                        }

                        //---------------------------------------------------------------------------------------- ----
                        // mouse functions

                        function initMouseEvents(target:MovieClip):Void {
                        target.onRollOver = rollover;
                        target.onRollOut = rollout;
                        target.onRelease = release;
                        }

                        function killMouseEvents(target:MovieClip):Void {
                        delete target.onRollOver;
                        delete target.onRollOut;
                        delete target.onRelease;
                        }

                        function rollover():Function {
                        var clip:Number = Number(this._name.substr(11));
                        //trace("Clicked on prod: "+prodID[clip]);

                        topBarOver._alpha = 100;
                        this.grad._alpha = 100;
                        //populate text fields
                        for(i=0; i<prodID.length; i++) {
                        if(this._name == prodID .id) {
                        var pretty_fmt:TextFormat = new TextFormat();
                        pretty_fmt.font = "whitney";
                        pretty_fmt.color = 0xFFFFFF;
                        pretty_fmt.size = 17;
                        prettyNameText.embedFonts = true;
                        prettyNameText.text = prettyName
                        ;
                        this.prettyNameText.setTextFormat(pretty_fmt);
                        prettyWidth = prettyNameText._width;
                        }

                        if(this._name == prodID ) {
                        var tagline_fmt:TextFormat = new TextFormat();
                        tagline_fmt.font = "din";
                        tagline_fmt.color = 0xFFFFFF;
                        tagline_fmt.size = 13;
                        taglineText.embedFonts = true;
                        this.taglineText.text = tagline
                        ;
                        taglineText.setTextFormat(tagline_fmt);

                        }


                        }

                        return this;
                        }

                        function rollout():Function {
                        topBarOver._alpha = 0;
                        this.grad._alpha = 0;
                        return this;
                        }


                        so everything is loading correctly and rollover over...except i am unable to find the right target to get the text boxes to load with the appropriate text(prettyname and tagline). i thought it would work as i had it before...but no such luck. do you have any advice? thanks again fo ryour help!
                        • 9. Re: loadClip question
                          kglad Adobe Community Professional & MVP
                          use the attach code option.
                          • 10. Re: loadClip question
                            chrissy b Level 1
                            sorry
                            • 11. Re: loadClip question
                              chrissy b Level 1
                              ok i got it working...i added this variable:

                              var clip:Number = Number(this._name.substr(11));

                              and then set clip == i in the if statements. i think i needed to take a break from it. anyway, thank you so much for your help.
                              • 12. Re: loadClip question
                                kglad Adobe Community Professional & MVP
                                you're welcome.