Welcome to Dream.In.Code
Getting Help is Easy!

Join 119,730 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,310 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Converting this horizontal carousel to verticle

 
Reply to this topicStart new topic

Converting this horizontal carousel to verticle, Help! Code inside

brandon_v
post 5 Jun, 2008 - 04:12 AM
Post #1


New D.I.C Head

*
Joined: 29 May, 2008
Posts: 17


My Contributions


Ok!

So what I have right now is a pseudo 3D carousel created in Actionscript. I didn't write this though, although I did a little editing for my own purposes.
But now, I found that I need to change this vertical carousel into a horizontal one, which is where I am having trouble.

In the .fla file, the library consists of a movie clip named "mc", with the linkage "mc", and a bitmap image, which is placed inside said movie clip. The movie clip is NOT placed on the stage.
Here is the code for that .fla (on a separate layer):

CODE
import CarouselInverse;

var numOfItems:Number = 10;
var clips:Array = new Array();

for(var i:Number = 0; i < numOfItems; i++)
{
    this.attachMovie("mc", "mc" + i, i +1);
    var mc:MovieClip = this["mc" + i];
    clips.push(mc);
}

var carousel:CarouselInverse = new CarouselInverse(clips);
carousel.radiusX = 200;

onEnterFrame = function()
{
    carousel.speed += (_ymouse-Stage.height/2  )*.00015;
    carousel.radiusY = (Stage.width/2 - _xmouse)*.15;
    carousel.render();
}




This is importing a class named "CarouselInverse", in an .as file named "CarouselInverse.as" with this code:

CODE
class CarouselInverse
{
    
    private var __numOfItems:Number;
    private var clips:Array;

    public var speed:Number = 0;
    
    public var radiusX:Number=250;
    public var radiusY:Number=0;
    public var toX:Number=Stage.width/2;
    public var toY:Number=Stage.height/2;
    public var perspective:Number=0;
    
    function CarouselInverse(clips:Array)
    {
        this.clips=clips;
        __numOfItems=clips.length;
    }

    public function render()
    {
        
        for (var i:Number=0; i < __numOfItems; i++)
        {
            var __temp:MovieClip=clips[i];            

            __temp.angle = (i * Math.PI * 2 / __numOfItems) + speed;
            __temp._y=Math.cos(__temp.angle) * radiusX + toY;
            __temp._x=Math.sin(__temp.angle) * radiusY + toX;
            __temp.z = Math.sin(__temp.angle)*100;
            
            var scale:Number = 1/(1-((__temp.z - perspective)/(radiusX-perspective)));
            __temp._xscale=__temp._yscale=scale*55;

            __temp.swapDepths(Math.round(__temp._xscale + 200));
        }
        
    }
        
    public function toArray():Array
    {
        return clips;
    }
    
}


What I am trying to do is convert that carousel from a vertical one, to a horizontal one! If you can, PLEASE help!
Thanks so much in advance!

This post has been edited by brandon_v: 5 Jun, 2008 - 04:16 AM
User is offlineProfile CardPM

Go to the top of the page


BetaWar
post 6 Jun, 2008 - 02:35 PM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,723



Thanked 68 times

Dream Kudos: 1075
My Contributions


I am sorry and haven't tried out the code, but from looking at it it looks like if you edit the perspective variable you should be abel to change angles you view the carousel at. So try changing:
CODE
public var perspective:Number=0;


To something like this:

CODE
public var perspective:Number=90;


and see what happens.

Like I said I haven't tried ou tthe code yet, but will try to at some point here in the next day or two.

Hope that helps.
User is online!Profile CardPM

Go to the top of the page

raincoder
post 10 Jul, 2008 - 08:40 AM
Post #3


New D.I.C Head

*
Joined: 10 Jul, 2008
Posts: 7

I hope this tutorial will help you somehow
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/15/08 04:36PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month