A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How to resize item as it goes backward in carousel?!

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    2

    How to resize item as it goes backward in carousel?!

    So my issue is that I want my images to get smaller as they go to the back, and unlike the carousel in the tutorial, I don't want them to go up on the Y axis— I'd like them to stay level horizontally but get smaller as they recede. The code in the tutorial I'm using only goes over how to do this by adjusting radiusY.

    If someone could help me out with a snippet of code for this! My current code is:

    var numOfItems:Number = 4;
    var radiusX:Number = 250;
    var radiusY:Number = 5;
    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("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)/5500;
    }

  2. #2
    Tutorianus Hominidus
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    4

    Question

    Hi

    i'm not sure I understand what you are trying to achieve. I marked the changes in red, does this do what you want?

    var numOfItems:Number = 4;
    var radiusX:Number = 250;
    var radiusY:Number = 100;
    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("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 = (Math.sin(this.angle) * radiusY + centerY) /(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)/5500;
    }


    kindest regards,
    John

  3. #3
    Tutorianus Hominidus
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    4
    PS: some adjustments might be needed for the y coord depending on the position of the registration point of the movieclip

  4. #4
    Junior Member
    Join Date
    Mar 2010
    Posts
    2
    yes! that's exactly it! thank you soooo much! i'd been struggling for hours trying to figure that out!

  5. #5
    Tutorianus Hominidus
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    4

    Thumbs up

    glad to help you mate

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center