12 Replies Latest reply on Dec 10, 2008 12:28 PM by lfcfan

    Containers and border colours

    lfcfan
      Hi is it possible to apply a border colour to a container? If so how would you do this in the following script?

      _root.createEmptyMovieClip("container", 1);
      loadMovie("scene_2.swf", "container");
      container._x = 20 ;
      container._y = 5 ;


        • 1. Re: Containers and border colours
          kglad Adobe Community Professional & MVP
          you can assign a color to a movieclip so create a movieclip border.
          • 2. Containers and border colours
            clbeech Level 3
            if you use the MovieClipLoader class to load the file, you can then use the onLoadInit handler to apply a 'border' line using the drawing API. but the file must be instantiated on the timeline previously in order to access the correct height and width of the loaded file. more like this:

            EDIT: sorry kg - odd, there was no post here, and it couldn't have taken me that long to write this LOL!!!
            • 3. Re: Containers and border colours
              lfcfan Level 1
              Thanks for your help, but just one more question if i may, in my first post i wanted to trigger the loading of the movieclip using a button (where buton is an instance of a button) like so :

              button.onPress = function () {
              _root.createEmptyMovieClip("container", 1);
              loadMovie("scene_2.swf", "container");
              container._x = 20 ;
              container._y = 5 ;
              }

              however where would i include the button.onPress in your code? Sorry but i'm new to AS.
              • 4. Re: Containers and border colours
                clbeech Level 3
                you're welcome - in this particular case you could use:

                button.onPress = function() {
                mcl.loadClip('scene_2.swf', container);
                }

                after the other codes are declared. the onLoadInit handler will fire once the loadClip method has been called, and the file loaded.
                • 5. Re: Containers and border colours
                  lfcfan Level 1
                  quote:

                  Originally posted by: clbeech
                  you're welcome - in this particular case you could use:

                  button.onPress = function() {
                  mcl.loadClip('scene_2.swf', container);
                  }

                  after the other codes are declared. the onLoadInit handler will fire once the loadClip method has been called, and the file loaded.


                  Hi thanks again. It works now and i have a white border. However i have a small problem, that is the shape of the border is a not a rectangle it more like a trapezium and also my "scene_2.swf"" does not play its entire length? Am i doing something wrong, do i need to change any of the figures in the lineTo
                  • 6. Re: Containers and border colours
                    clbeech Level 3
                    LOL! yes i see what is happening here - my mistake, the 'size' of the box is actually being changed AS the drawing is being done so that the 3rd and forth 'corners' are getting adjusted as we move through the drawing process. to remedy, set a var equal to the original specs and use it within the drawing statements:

                    (BTW: kg if you read this, I'm interested in knowing more about what you mean here)



                    • 7. Re: Containers and border colours
                      lfcfan Level 1
                      Thanks again, but i've got a question with the following code:
                      (clip) {
                      _x = 20;
                      _y = 5;
                      var w = _width;
                      var h = _height;

                      lineStyle(4, 0xFFFFFF);
                      moveTo(0,0);
                      lineTo(w, 0);
                      lineTo(w, h);
                      lineTo(0, h);
                      lineTo(0, 0);

                      in the lineTo(w,0); do i put numerical values for width and heighte.g. lineTo(200,0) lineTo(200,200); etc..?
                      • 8. Re: Containers and border colours
                        clbeech Level 3
                        yes that's exactly correct :) the values are (x,y) based in relation to the coordinates of the MC symbol you are targeting - you can find more information about the drawing API in the help docs under: Actionscript2.0>Actionscript Language reference>Actionscript classes>MovieClip class
                        • 9. Re: Containers and border colours
                          lfcfan Level 1
                          Ok thanks so much for your help but please just one more thing, why won't my loaded movie clip play its full length it stops half way through? On its own it plays fine.
                          • 10. Re: Containers and border colours
                            clbeech Level 3
                            you're welcome - hmmm... that's tough to say, it would seem unrelated to the codes we've worked with here, other than the fact that we are loading the other file. there must be something that is causing this to happen but there's no way to determine what it is from the given information. if you could post a copy of both fla files, someone may be able to spot the problem.
                            • 11. Re: Containers and border colours
                              lfcfan Level 1
                              clbeech, thanks so much for your help and time. Upon you telling me that nothing in the code that we had worked with could have been causing the problem, i decided to look into the matter myself LOL. It turns out for some reason on the layer where i had the code for some reason i had 30 frames inserted, and the second movie clip was only playing for this length of time. Upon removing these frames everything is working great...for now, thanks a million.
                              • 12. Re: Containers and border colours
                                lfcfan Level 1
                                Hi i was wondering if anyone could assist me with a small problem. After having got my head round this actionscript, (thanks to clbeech) i now want to explore further and try and load two containers and play different movies in each. Is this possible? here is what i have tried but it does nothing, and i'm probably doing something obviously wrong.

                                var container = _root.createEmptyMovieClip('container', 1);
                                var mcl = new MovieClipLoader();
                                var lstn = new Object();
                                mcl.addListener(lstn);

                                lstn.onLoadInit = function(clip) {
                                with(clip) {
                                _x = 100;
                                _y = 50;
                                var w = _width;
                                var h = _height;

                                lineStyle(1, 0xFFFFFF);
                                moveTo(0,0);
                                lineTo(600, 0);
                                lineTo(600, 300);
                                lineTo(0, 300);
                                lineTo(0, 0);
                                }

                                }

                                but.onPress = function() {
                                mcl.loadClip('scene_2.swf', 'container');
                                }
                                but2.onPress = function() {
                                mcl.loadClip('scene_4.swf', 'container');
                                }

                                var container = _root.createEmptyMovieClip('container2', 1);
                                var mcl2 = new MovieClipLoader();
                                var lstn2 = new Object();
                                mcl2.addListener(lstn2);

                                lstn2.onLoadInit = function(clip) {
                                with(clip) {
                                _x = 25;
                                _y = 50;
                                var w = _width;
                                var h = _height;

                                lineStyle(1, 0xFFFFFF);
                                moveTo(0,0);
                                lineTo(600, 0);
                                lineTo(600, 300);
                                lineTo(0, 300);
                                lineTo(0, 0);
                                }

                                }

                                but.onPress = function() {
                                mcl.loadClip('scene_5.swf', 'container1');
                                }
                                but2.onPress = function() {
                                mcl.loadClip('scene_6.swf', 'container1');
                                }