target right back to the _root from inside movie clips??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elamberdor
    New Member
    • Mar 2007
    • 39

    target right back to the _root from inside movie clips??

    Hello All!
    Well, I can load in swf's just loverly, but what I have is a sliding menu, with buttons in it, that when pressed, load an image into an empty movieclip.

    I really just need to know how to target back to the _root of the whole movie.

    It works great when the buttons and empty movieclip in the same stage or same movie clip, however I need to work out the right script to target right back to the root where i want the image to sit, from a button, inside a movie clip. I have the jpegs in both the swf folder and inside the flash file.

    The reason I need the buttons and the img_container separate is because if you slide the buttons left or right in the sliding menu, the image slides across as well.

    Here is what works when they are within the same movie clip:

    on (release) {
    loadMovie("lamp 1.jpg", "img_container" );
    _root.img_conta iner._xscale = 40
    _root.img_conta iner._yscale = 40
    }

    ...however i'm trying to use target path, and it's not working too well...

    on (release) {
    loadMovie("lamp 1.jpg", "img_container" );
    this.img_contai ner._xscale = 40;
    this.img_contai ner._yscale = 40;
    }

    Any ideas, or how I could better structure this would be wonderful!
    Thanks!
  • elamberdor
    New Member
    • Mar 2007
    • 39

    #2
    Hey All!

    Ok, I got it to work!
    I thought I would post the answer here! =)

    Basically the answer was sticking my img_container ( the movie that load in images..) into another movie placed on the _root.

    so:

    on (release) {
    loadMovie("lamp 1.jpg", "_root.staticI. img_container") ;
    _root.staticI.img_container. _xscale = 40;
    _root.staticI.img_container. _yscale = 40;
    }

    just took it straight off the root, and it worked!
    yay! =)

    *one problem with this site ticked off the list! =P *

    Comment

    • xNephilimx
      Recognized Expert New Member
      • Jun 2007
      • 213

      #3
      Great that you have that working.
      An advice that' will be usefull for you and for everyone:

      don't use the _root, cause if the movie that is using _root as reference is for some reason loaded inside another movie the _root will be referencing that other movie, try this, make a variable named home (for example) and make it equal to this (the pseudo-element "this" I mean). So the home object will be now the current root element and you'll avoid nesting problems. Also you can call this home object from wherever you like and will still be the root of your movie. even if your movie is being called inside another one.

      [CODE=actionscri pt]

      var home:MovieClip = this;

      [/CODE]

      Kind regards.

      Comment

      • elamberdor
        New Member
        • Mar 2007
        • 39

        #4
        Thanks xNephilimx,

        Funny your should mention that, this movie is actually going to sit within another main movie to cut loading, and that's exactly the problem i'm having!

        I'm not too familiar with var.script, But know I know where at least i'm going wrong! I'll have a bit of a play!

        Thanks Heaps!
        =)

        Comment

        • xNephilimx
          Recognized Expert New Member
          • Jun 2007
          • 213

          #5
          Lol, you're welcome, that's one of my main advices, because it really helped me a lot to always refer to the local root with a variable, and I know it's a common problem.
          Well, now knowing where you're wrong it's a pretty good start, I'm always around the actionscript forum, so any doubt you might have post it here and I or other experts will try to help.

          Kind regards and good luck with your projects,
          The_Nephilim

          Originally posted by elamberdor
          Thanks xNephilimx,

          Funny your should mention that, this movie is actually going to sit within another main movie to cut loading, and that's exactly the problem i'm having!

          I'm not too familiar with var.script, But know I know where at least i'm going wrong! I'll have a bit of a play!

          Thanks Heaps!
          =)

          Comment

          • elamberdor
            New Member
            • Mar 2007
            • 39

            #6
            Hello Again!

            Well, i've had a bit of a search around, found a good tut about var home here at
            studio koi
            and I've given that a go on a button that calls to an image container inside another movie:
            [code=actionscri pt]
            on (release) {
            var home:MovieClip = this;
            loadMovie("imag es/image.jpg", "_root.staticI. img_container") ;
            }
            [/code]
            works on it's own when using that "_root." you see there, however called into another movie clip not so well. I've tried:

            [code=actionscri pt]
            "home.staticI.i mg_container");
            and
            "this.staticI.i mg_container");
            [/code]
            But i'm pretty sure i'm missing the mark and i'm soooo close!

            Because my sliding buttons no longer work:
            they use:(left arrow example)
            [code=actionscri pt]
            on (release) {
            targetx = 360;
            script.gotoAndP lay("move");
            }
            [/code]
            ("move" being a frame label in a hidden "script" movie clip)
            it may have something to do with the movie dimensions though....

            But my main focus is on properly writing that "home" link......
            Any ideas!? =)

            Originally posted by xNephilimx
            Lol, you're welcome, that's one of my main advices, because it really helped me a lot to always refer to the local root with a variable, and I know it's a common problem.
            Well, now knowing where you're wrong it's a pretty good start, I'm always around the actionscript forum, so any doubt you might have post it here and I or other experts will try to help.

            Kind regards and good luck with your projects,
            The_Nephilim

            Comment

            • elamberdor
              New Member
              • Mar 2007
              • 39

              #7
              Alrighty,

              Well, it seems to be working now:
              [code=actionscri pt]
              on (release) {
              var home:MovieClip = this;
              loadMovie("imag es/image.jpg", "_root.staticI. img_container") ;
              }
              [/code]
              same code, just re-did it....*hrmm*

              that's on the actual button of the call in movie, now in the main timeline, i've got the button that load this swf to say:
              [code=actionscri pt]
              on (release) {
              var home:MovieClip = this;
              loadMovie("ligh ting.swf", "_root.swf_load er.swf_containe r");
              }
              [/code]
              as well...
              (yay! doing a bit of a happy dance right now!)
              (sorry i'm not really the serious forum type! =P)

              sliding buttons still load well too.... exact coordinates too...
              Thanks as always!!!!
              =)

              Comment

              • xNephilimx
                Recognized Expert New Member
                • Jun 2007
                • 213

                #8
                LOL
                Glad you had it working!
                Another way to do that is by using the target movieclip you want to use as a loder and from it using the loadMovie method, like this:

                [CODE=actionscri pt]

                home.mc1.mc2.et c.loadMovie("pa th/to/file");

                [/CODE]

                That way you safely use the home var, and have no problems when using this movie inside another one.

                Anyway, it's good to see users here that actually put effort in solving their problems by themselves. Have no doubt when you need something you can't figure out that I'll try to help as much as I can.

                Best regards,
                The_Nephilim

                Originally posted by elamberdor
                Alrighty,

                Well, it seems to be working now:
                [code=actionscri pt]
                on (release) {
                var home:MovieClip = this;
                loadMovie("imag es/image.jpg", "_root.staticI. img_container") ;
                }
                [/code]
                same code, just re-did it....*hrmm*

                that's on the actual button of the call in movie, now in the main timeline, i've got the button that load this swf to say:
                [code=actionscri pt]
                on (release) {
                var home:MovieClip = this;
                loadMovie("ligh ting.swf", "_root.swf_load er.swf_containe r");
                }
                [/code]
                as well...
                (yay! doing a bit of a happy dance right now!)
                (sorry i'm not really the serious forum type! =P)

                sliding buttons still load well too.... exact coordinates too...
                Thanks as always!!!!
                =)

                Comment

                • elamberdor
                  New Member
                  • Mar 2007
                  • 39

                  #9
                  Well, I find nothing worse when i'm searching for answers that the original poster hasn't come back with their solution...! I try to when I can!

                  You have been extreamely helpful with your code snippets & easy to understand language!

                  Thanks again as always!
                  =)

                  Comment

                  • ghert
                    New Member
                    • Apr 2009
                    • 1

                    #10
                    argh!

                    thanks guys! i have been having the same problem this entire day and then i stumbled updon this! thanks so much! even though its 2 years later! cooool

                    Comment

                    • elamberdor
                      New Member
                      • Mar 2007
                      • 39

                      #11
                      yay! the internet works! =D

                      Comment

                      Working...