2 Replies Latest reply on Oct 9, 2009 10:43 AM by javissss

    loadMovie without container mc

    javissss

      Hi! Im using AS2.

      Now, i got this trouble: when i load an external movie into the main one, i had some errors if i put it into a containter mc, with this code:

      Code:

      loadMovie ("movie.swf", containter_mc);

      The scroll bar not only move the movie.swf object, but the container_mc too...

      So, i just load the movie without using a container, with this code:

      Code:

      loadMovie ("movie.swf", 2);

      And suprise! now the scroll bar works just fine. But...

      How can i position the movie into the main one?

      Like :

      movie._x = 200;
      movie._y = 200;

      How can i do that in the right way?

      Thanks for your patience and help!

      (Sorry, but my english its not good enough ha! )

        • 1. Re: loadMovie without container mc
          Rothrock Level 5

          Technically you should use

           

          loadMovieNum ("movie.swf", 2);

           

          if you are going to load into a level.

           

          You can adjust the _x and _y using

           

          _level2._x=someNumber;

          _level2._y=someNumber;

           

          However I don't think you are going to be able to move it until after it has loaded because _level2 won't "exist" until the content has loaded. So you will need a preloader.

           

          But generally I avoid using _levels. Mostly because there really is no class api for them and therefore you can't do much with them.

           

          I'm not really sure what is going on with your container, but you could try this:

           

          var home:MovieClip=this;

          var container:MovieClip=home.createEmptyMovieClip("container",100);

          var content:MovieClip=container.createEmptyMovieClip("content",1);

           

          var mcl:MovieClipLoader=new MovieClipLoader();

          var listener:Object=new Object();

          listener.onLoadInit=function(target:MovieClip){

          trace(target+" loaded!");

          }

          mcl.addListener(listener);

          mcl.loadClip("movie.swf",content);

           

          That should work...assuming I didn't make a typo.

          • 2. Re: loadMovie without container mc
            javissss Level 1

            Ok. I tried to use the first script, the one that manage levels, and couldn't do anything.

             

            So, i follow your advice, and use the script at the bottom of your post. It shows the external swf, but i back to my first problem:

             

            The scroll bar move the content of "movie.swf", and also move the whole mc where resides the container. I'll try to make a map of the main movie:

             

            Main movie, Scene 1 = Preloader -> Main movie, Scene 2 = The main time line -> layer 4, frame 1 = content mc -> layer 3, frame 7 = news mc

             

            Now, in news mc, in frame 15, i call the external swf, "movie.swf". So, when i use the scroll bar (wich is into movie.swf), the scroll move all the content inside content mc.

             

            The scroll bar works with an as included, this one:

             

            generarScrollEasyn = function (nivel, clip, anchoScroll, suavizado) {
                if (clip != undefined) {
                    var anchoScroll = anchoScroll;
                    var div = suavizado;
                    if (div != undefined) {
                        if (div<1) {
                            div = 1;
                        } else {
                            div = suavizado;
                        }
                    } else {
                        div = 10;
                    }
                    var ruta = nivel;
                    var altoScroll = Math.floor(ruta.mcMask._height);
                    var mask_top = clip._y;
                    var mask_height = ruta.mcMask._height;
                    var mc_heigth = clip._height;
                    if (mc_heigth<mask_height or mc_heigth == mask_height) {
                        // el campo de texo es ma corto que el largo de la mascara
                    } else {
                        ruta.attachMovie("mcContScroll", "mcContScroll", _root.mcCont);
                        ruta.mcContScroll.attachMovie("fondo", "fondo", ruta.mcContScroll);
                        with (ruta.mcContScroll) {
                            ruta.mcContScroll._x = clip._x+clip._width+5;
                            fondo._height = altoScroll;
                            attachMovie("barrita", "barra", 1);
                            barra._height = 10;
                            barra.inicioY = barra._y;
                            barra.finalY = barra._y+ruta.mcMask._height-barra._height;
                            barra.inicioX = barra.finalX=barra._x;
                            var scroll_top = barra._y;
                            var scroll_buttom = Math.floor(ruta.mcMask._height-barra._height-3);
                            if (anchoScroll>3) {
                                fondo._width = anchoScroll;
                                barra._width = anchoScroll;
                            } else {
                                fondo._width = 3;
                                barra._width = 3;
                            }
                            barra.onPress = function() {
                                this.gotoAndStop(2);
                                this.startDrag(0, this.inicioX, this.inicioY, this.finalX, this.finalY);
                                mouse_drag = true;
                                this._alpha = 100;
                                this.onEnterFrame = function() {
                                    var mcAlto = clip._height;
                                    if (mcAlto<mask_height) {
                                        return;
                                    }
                                    if (mouse_drag) {
                                        var mk = ruta.mcMask;
                                        if (mot<(-1)*(clip._height-mk._height)) {
                                            mot = Math.round((clip._height-mk._height))*-1;
                                        }
                                        var pos = Math.floor(mask_top-(mcAlto-mask_height)*(barra._y-scroll_top)/(scroll_buttom-scroll_top) );
                                        var posY = pos-clip._y;
                                        clip._y -= Math.round((int(mot)-posY)/div);
                                    }
                                };
                            };
                            barra.rollOut = function() {
                                this._alpha = 100;
                                this.gotoAndStop(1);
                            };
                            barra.onRollOver = function() {
                                this._alpha = 100;
                                this.gotoAndStop(2);
                            };
                            barra.onRelease = function() {
                                this.stopDrag();
                                this.gotoAndStop(1);
                                //mouse_drag = false;
                                //delete this.onEnterFrame;
                            };
                            barra.onReleaseOutside = barra.onRelease;
                        }
                    }
                } else {
                    trace(nivel);
                    nivel.createTextField("my_txt", 1, 100, 100, 300, 100);
                    nivel.my_txt.multiline = true;
                    nivel.my_txt.wordWrap = true;
                    var my_fmt:TextFormat = new TextFormat();
                    my_fmt.color = 0xFF0000;
                    my_fmt.underline = true;
                    my_fmt.font = "Verdana";
                    my_fmt.size = 10;
                    nivel.my_txt.htmlText = "No se ha podido detectar el CLIP CONTENEDOR";
                    nivel.my_txt.setTextFormat(my_fmt);
                    nivel.my_txt._x = nivel._x;
                    nivel.my_txt._y = nivel._y;
                }
            };

            And in movie.swf, layer 2, frame 1, theres a few parameters to set up this action:

             

            #include "scroll_easyn.as"
            var nivel = _root.mcCont;
            var clip = _root.mcCont.mc;
            var anchoScroll = 10;
            var suavizado = 5;
            _root.generarScrollEasyn(nivel, clip, anchoScroll, suavizado);


            Im just desesperate now LOL!

             

            Thanks for your answer, and im looking eveywhere to possible solutions