Preview Message Thank you Rob, i went through the tutorials, and now have a working carousel using part I of the tutorials......i would like to know however how to add different items from the library into the carousel instead of just the same item multiple times. This is the code i have so far: stop(); var numOfItems:Number= 5; var radiusX:Number = 250; var radiusY:Number = 75; var centerX:Number = Stage.width / 2; var centerY:Number = Stage.height / 2; var speed:Number = 0.05; //var perspective:Number = 150; var tooltip:MovieClip = this.attachMovie ("tooltip","too;tip",1000) tooltip._alpha = 0; //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++) // ( for (var i=0;i<numOfItems;i++) { var t= this.attachMovie ("item","item"+i,+i+1); t.angle = i * ((Math.PI*2) / numOfItems); 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; this.angle += this._parent.speed; this.swapDepths (Math.round (this._xscale) + 100); } this.onMouseMove = function () { speed = (this._xmouse-centerX) / 1500; } Any suggestions as to what to add or change to achieve my goal? My items are named item, item1, item2, item3, and item4 in the library. Any and all help is appreciated. Thank you
Use an array to store the names of the library items and load the library items using a for loop. I've attached adapted code from Lee's first tutorial on gotoandlearn.com with the array etc. You'll need to change the icons.push statement to include the names of each element in the carousel per their linkage identifier in the library panel. The rest should work just fine. Adapted from the code @ gotoandlearn.com. var icons:Array = new Array(); icons.push("name1", "name2", "name3"); var numOfItems:Number = icons.length; var radiusX:Number = 250; var radiusY:Number = 75; var centerX:Number = Stage.width/2; var centerY:Number = Stage.height/2; var speed:Number = 0.05; for(var i=0; i<numOfItems;i++) { var t = this.attachMovie(icons[i], "item"+i, i+1); t.angle = i * ((Math.PI*2)/numOfItems); t.onEnterFrame = mover; } function mover() { this._x = Math.cos(this.angle) * radiusX + centerX; this._y = Math.sin(this.angle) * radiusY + centerY; var s:Number = this._y / centerY+radiusY; 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)/1500; }
I forgot a parenthetical grouping so the math is messed in one spot. Try this... var icons:Array = new Array(); icons.push("name1", "name2", "name3"); var numOfItems:Number = icons.length; var radiusX:Number = 250; var radiusY:Number = 75; var centerX:Number = Stage.width/2; var centerY:Number = Stage.height/2; var speed:Number = 0.05; for(var i=0; i<numOfItems;i++) { var t = this.attachMovie(icons[i], "item"+i, i+1); t.angle = i * ((Math.PI*2)/numOfItems); t.onEnterFrame = mover; } function mover() { this._x = Math.cos(this.angle) * radiusX + centerX; this._y = Math.sin(this.angle) * radiusY + centerY; var s:Number = this._y / (centerY+radiusY); 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)/1500; }
Thank you SymsTsb, that code works.....now i was wondering if you could help me with one more thing. Im trying to combine part 3 from those tutorials with part 1, so that i can select one item, and have it open up as the main focus on the stage while the other items go shrink and go away, until i close that item and bring all the other items back where i can select any of them again. I seen in part 3 his code was very way different from part 1, so how do i add this extra functionality in to this current code we already have working?
Thank you SymTsb, that code works.....now i was wondering if you could help me with one more thing. Im trying to combine part 3 from those tutorials with part 1, so that i can select one item, and have it open up as the main focus on the stage while the other items go shrink and go away, until i close that item and bring all the other items back where i can select any of them again. I seen in part 3 his code was very way different from part 1, so how do i add this extra functionality in to this current code we already have working?
im not using any xml, tooltips, or anything extra.......i just want to combine the act of stopping the carousel and focusing on the active object at the time, and then going back to the regular carousel animation when i close the item. How do i do that
Sorry fan. I'm no longer in the habit of checking forum posts over the weekend since I spend such large portions of my daily work time on them. Watch Lee's third movie again and pay close attention to the area where he adds the click handlers for the buttons. The process (believe it or not) is exactly the same whether you are using XML, tooltips, etc. Tooltips happen on rollover and are not relevant so ignore them. The XML stuff that Lee talks about is simply used to load his content for the different sections. Yours may use loadMovie or something else after the icon is expanded. The core feature though (the scaling after being pressed etc.) is identical.
Don't see what you're looking for? Try a search.
|