11 Replies Latest reply on Dec 28, 2010 3:49 PM by kglad

    ActionScript 2

    U11

      Hello...Basically iv included actionscript which produces a 3d carousel through an xml file. everything has worked out well except I dont knw how to stop the carousel from playing throughout my flash document. I have included button and frame labels which allow you to go to different pages, but on every page the carousel is playing throughout. iv tried the stop();

       

      What i would like is for the actionscript to disappear after frame 19 and beyound. is there anyway I could do that through actionscript maybe?

       

      I am using Flash CS5 and Actionscript 2.0

       

      Thank You

        • 1. Re: ActionScript 2
          kglad Adobe Community Professional & MVP

          if you're using attachMovie() to add movieclips to your swf, use removeMovieClip() to remove them.


          • 2. Re: ActionScript 2
            U11 Level 1

            Thx 4 the reply m8. Im new to flash I want to remove it after frame 19? how wud i go abwt doing that?

            • 3. Re: ActionScript 2
              U11 Level 1

              var t = home.attachMovie("icon","icon"+i,i+1);

               

              ^^ Thats what iv used....Iv tried removeMovieClip() it still dont work?

              • 4. Re: ActionScript 2
                kglad Adobe Community Professional & MVP

                then you're not applying removeMovieClip() to the correct object.

                 

                use:

                 

                 

                home["icon"+i].removeMovieClip();  // don't forget to iterate through your variable i

                • 5. Re: ActionScript 2
                  U11 Level 1

                  I appreciate your help

                   

                  It still doesn't seem to work. Im abit confused with the actionscript that I have for the 3D carousel..so I will paste it:

                   

                   

                   

                   

                  var numOfItems:Number;

                  var radiusX:Number = 450;

                  var radiusY:Number = 350;

                  var centerX:Number = Stage.width/2;

                  var centerY:Number = Stage.height/2;

                  var speed:Number = 0.05;

                  var perspective;

                  var home:MovieClip = this;

                   

                  var xml:XML = new XML();

                  xml.ignoreWhite = true;

                   

                  xml.onLoad = function()

                  {

                  var nodes = this.firstChild.childNodes;

                  numOfItems = nodes.length;

                  for(var i=0;i<numOfItems;i++)

                  {

                  var t = home.attachMovie("icon","icon"+i,i+1);

                  t.angle = i * ((Math.PI*2)/numOfItems);

                  t.onEnterFrame = mover;

                  t.inner.loadMovie(nodes[i].attributes.image);

                  }

                  }

                   

                  xml.load("icons.xml");

                   

                   

                  function mover()

                  {

                  this._x = Math.cos(this.angle) * radiusX + centerX;

                  this._y = Math.sin(this.angle) * radiusY + centerY;

                  var s:Number = (this._y - perspective) /(centerY+radiusY-perspective);

                  this._xscale = this._yscale = s * 100;

                  this.angle += this._parent.speed;

                  this.swapDepths(Math.round(this._xscale) + 100);

                  }

                   

                  this.onMouseMove = function()

                  {

                  speed = (this._xmouse-centerX)/2500;

                  • 6. Re: ActionScript 2
                    kglad Adobe Community Professional & MVP

                    actually, what will be easier would be to use the following and call removeF() when you want to remove the carousel:

                     


                     

                     

                     

                    var numOfItems:Number;

                    var radiusX:Number = 450;

                    var radiusY:Number = 350;

                    var centerX:Number = Stage.width/2;

                    var centerY:Number = Stage.height/2;

                    var speed:Number = 0.05;

                    var perspective;

                     

                    if(!home){

                    var home:MovieClip = this.createEmptyMovieClip("home_mc",this.getNextHighestDepth());

                    }

                     

                    var xml:XML = new XML();

                    xml.ignoreWhite = true;

                     

                    function removeF():Void{

                    home.removeMovieClip();

                    }

                     

                    xml.onLoad = function()

                    {

                    var nodes = this.firstChild.childNodes;

                    numOfItems = nodes.length;

                    for(var i=0;i<numOfItems;i++)

                    {

                    var t = home.attachMovie("icon","icon"+i,i+1);

                    t.angle = i * ((Math.PI*2)/numOfItems);

                    t.onEnterFrame = mover;

                    t.inner.loadMovie(nodes[i].attributes.image);

                    }

                    }

                     

                    xml.load("icons.xml");

                     

                     

                    function mover()

                    {

                    this._x = Math.cos(this.angle) * radiusX + centerX;

                    this._y = Math.sin(this.angle) * radiusY + centerY;

                    var s:Number = (this._y - perspective) /(centerY+radiusY-perspective);

                    this._xscale = this._yscale = s * 100;

                    this.angle += this._parent.speed;

                    this.swapDepths(Math.round(this._xscale) + 100);

                    }

                     

                    this.onMouseMove = function()

                    {

                    speed = (this._xmouse-centerX)/2500;

                    1 person found this helpful
                    • 7. Re: ActionScript 2
                      U11 Level 1

                      Where would I insert this code? in frame 19 where i dont want the carousel?

                      • 8. Re: ActionScript 2
                        U11 Level 1

                        Scene=Scene 1, layer=actions, frame=20, Line 47 Statement block must be terminated by '}'

                        Scene=Scene 1, layer=actions, frame=20, Line 48 Syntax error.

                        Im getting these error messages, when I insert them in frame 19.

                        • 9. Re: ActionScript 2
                          kglad Adobe Community Professional & MVP

                          replace your current code with the code i suggested.  call removeF() whenever you navigate away from your carousel.

                          1 person found this helpful
                          • 10. Re: ActionScript 2
                            U11 Level 1

                            Iv tried to replace the code but my carousel disappears..aint there a way where I can jus stop the carousel after frame 19 through actionscript?

                            • 11. Re: ActionScript 2
                              kglad Adobe Community Professional & MVP

                              there's nothing in the code i showed that would make your carousel disappear.  you have to add that function call to do that.  if your carousel disappears when you don't want it to disappear, you're adding that function call in the wrong place and calling that function at the wrong time.

                              1 person found this helpful