3 Replies Latest reply on Feb 23, 2009 12:31 PM by Ned Murphy

    attachMovie - work but loadMovie - not

    CodyMaverick
      hi
      This Code working: var t = this.attachMovie("ball"+i,"bb"+i,i+1);

      But this: createEmptyMovieClip("ball"+i, this.getNextHighestDepth());
      var t = "ball"+i.loadMovie(PIC ); - not.

      I cant understand why!?

      How i can understand attachMovie working only with library's movie clips, does it ??
      Does exist function that can put movie clip into a library ?? Or create movie clip into a library??

      Thanx
        • 1. attachMovie - work but loadMovie - not
          Ned Murphy Adobe Community Professional & MVP
          "ball"+i is simply a string, so when you say...

          var t = "ball"+i.loadMovie(PIC);

          You are trying to get a string to behave like a movieclip, which it will not do. On the other hand, the following will work...

          var t = this["ball"+i].loadMovie(PIC);

          The array notation [ ] causes the program to evaluate the string as the name of an object

          You do not need to assign "var t = " in any of the cases you showed, unless you have a purpose in doing so

          You should read thru the Help documents anytime you have a question about what certain commands do.

          attachMovie will load items from the library
          loadMovie will load image/swf files from the server

          No, there is no function that can dynamically add something to the library

          • 2. Re: attachMovie - work but loadMovie - not
            CodyMaverick Level 1
            Sorry, but PIC is array, it's my mistake i want write:

            createEmptyMovieClip("ball"+i, this.getNextHighestDepth());
            var t = this["ball"+i].loadMovie(PIC );

            does't work, Can't understand why.

            All my code:

            // XML
            var galery:XML = new XML();
            galery.ignoreWhite = true;

            var PIC:Array = new Array();
            var index:Number = 0;

            xml.onLoad = Delegate.create (this, onLoad);
            galery.load("galery.xml");

            galery.onLoad = function(success){
            if (success){
            nodes = galery.firstChild.childNodes;

            for (i=1; i<=nodes.length; i++){
            PIC.push(nodes[i-1].childNodes[0].nodeValue);
            }

            var numOfBalls:Number = 4;
            var radiusX:Number = 500;
            var radiusY:Number = 100;
            var centerX:Number = Stage.width / 2;
            var centerY:Number = (Stage.height / 2)-90;
            var speed:Number = 0.01;
            var vector:Number = 1;
            var AlphaSpeed:Number = 5;

            right.onRollOver = function() { _root.vector = 1; };
            left.onRollOver = function() { _root.vector = 0; };

            main();
            }}

            function main()
            {
            for(var i=0;i<nodes.length;i++)
            {
            createEmptyMovieClip("ball"+i, this.getNextHighestDepth());
            var t = this["ball"+i].loadMovie(PIC
            ); trace(t);
            t.angle = i * ((Math.PI*2)/nodes.length);
            t.onEnterFrame = mover;
            }
            }

            function mover()
            {
            this._x = Math.cos(this.angle) * radiusX + centerX;
            this._y = Math.sin(this.angle) * radiusY + centerY;
            var s = this._y /(centerY+radiusY);
            this._xscale = this._yscale = s*100;
            if(vector==1) { this.angle -= this._parent.speed; }
            if(vector==0) { this.angle += this._parent.speed; }
            this.swapDepths(Math.round(this._xscale) + 100);

            this.onRollOver = function()
            { _root.speed = 0; _root.AlphaSpeed = 0;
            if(this._x>100 && this._x<860) {
            tip.swapDepths(1000); tip._x = _xmouse; tip._y = _ymouse; tip.startDrag();
            tip.content = "1";
            tip.head = "1";
            tip.gotoAndPlay(2);
            }};


            this.onRollOut = function()
            { _root.speed = 0.01; _root.AlphaSpeed = 5; tip._x = -300; tip._y = -300; };

            if (this._x<100 && this._x>30 && vector==0) { this._alpha -= AlphaSpeed; }
            if (this._x<930 && this._x>860 && vector==0 && this._alpha<100) { this._alpha += AlphaSpeed; }
            if (this._x>30 && this._x<100 && vector==1 && this._alpha<100) { this._alpha += AlphaSpeed; }
            if (this._x>860 && this._x<930 && vector==1) { this._alpha -= AlphaSpeed; }

            if (this._x<0) { this._alpha = 0; }
            if (this._x>960) { this._alpha = 0; }
            }

            Where is my mistake??
            • 3. Re: attachMovie - work but loadMovie - not
              Ned Murphy Adobe Community Professional & MVP
              Have you traced PIC to see what it holds?

              Your code is hard to read/follow. Use the Attach Code feature. Since you use an [ i ] index, it is read as an italic tag for your posting, removing it from the code. Also, attaching the code keeps the indentation intact that you hopefully have used for your code... making it easier to follow.