16 Replies Latest reply on Nov 15, 2007 8:56 AM by kglad

# Vertical carousel

I was trying to do one with amended code from gotoandlearn, however, can't get the scaling to work properly.

var numOfBalls:Number = 3;
var centerX:Number = Stage.width / 2;
var centerY:Number = Stage.height / 2;
var speed:Number = 0.05;

for(var i=0;i<numOfBalls;i++)
{
var t = this.attachMovie("ball","b"+i,i+1);
t.angle = i * ((Math.PI*2)/numOfBalls);
t.onEnterFrame = mover;
}

function mover()
{
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
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;
}

anybody??

cheers
L.
• ###### 1. Re: Vertical carousel
if you have a movieclip with linkage id = tfmc that contains a dynamic textfield with instance name tf, you can use:

• ###### 2. Re: Vertical carousel
If you want the scale to vary, you're going to have to use a number somewhere in your equation that's not constant. Right now, your _x, centerY and radiusY are all constants. Maybe if you write var s = this._y /(centerY+radiusY); with a _y instead of an _x, that will give you the effect you are looking for?
• ###### 3. Vertical carousel

Hm, thanks a lot mate. However, what is this supposed to be doing exactly?
Is there no way just to adjust the scaling in the code I posted previously?

I mean the code you sent me is a bit more complex and it actually does the vertical carousel, however, the y scaling is like 10% and the whole thing doesn't respond to mouse movement.

• ###### 4. Vertical carousel
joeflashTO

Yeah, I've tried that already, it kinda does the job of scaling, but the result is the biggest icon is at the very bottom instead of the middle as well as the smallest is at the top instead of in the middle (at the back) > wrong angle?

...
• ###### 5. Re: Vertical carousel
read the comment (about creating a movieclip with instance name field) if you want movement to respond to the mouse.

• ###### 6. Re: Vertical carousel
and the code's not more complex. it's just more flexible and allows a number of parameters to be controlled and adjusts the color of text as movement progresses. you can ignore all the code related to color.

the only part you need to check is in spinF().
• ###### 7. Vertical carousel
sorry dude, I'm an idiot...didn't see the comment - thanks a lot!

Ok I have it done, working on the mouse movement, scaled, however the depths are not being swapped properly... did you test it?
• ###### 8. Re: Vertical carousel
i wrote it. so yes, i tested it.

there's no depth swapping because you use the alpha fade to eliminate that need.
• ###### 9. Re: Vertical carousel
quote:

Originally posted by: l_u_b_i_007
Hm, thanks a lot mate. However, what is this supposed to be doing exactly?

I guess I would ask you the same thing. A very detailed description of what you want the animation to accomplish would help us help you out in this situation.

• ###### 10. Re: Vertical carousel
quote:

i wrote it. so yes, i tested it.

there's no depth swapping because you use the alpha fade to eliminate that need.

Oh, I see, it makes sense now. Thanks a lot, works perfectly then!

joeflashTO
Sorry if this wasn't clear enough. I thought the thread title should be enough. However, I just wanted a vertical carousel. Preferably with swapping depths of objects so I don't have to use alpha so that I can see all, however, kglad helped me a lot, I didn't know how mathematically divide the abgle for scaling and he did exactly what I needed.

Thanks a lot guys!
• ###### 12. Re: Vertical carousel
you're welcome.
• ###### 13. Vertical carousel
Yeah, that's exactly what I ended up on.

Just one more question if you don't mind - If you wanted to attach different symbols from the library, instead of duplicating them, how would you please adjust the FOR loop then?

Let's say I wouldn't be using an XML file for identification or whatsoever, just few different linkage identifiers in the library.
I guess you would have to add one more variable then, instead of using the "rclip", wouldn't you...?
• ###### 14. Re: Vertical carousel
rclip is just a variable name to make it easy to reference the newly created movieclip. if you want to attach different movieclips, you would change the first parameter of attachMovie() in that for-loop.

so, if you had an array of linkage ids, you could easily iterate through that array in the initializeF() for-loop attach different library movieclips.
• ###### 15. Re: Vertical carousel
sorted, great idea, thanks again.
• ###### 16. Re: Vertical carousel
you're welcome.