2 Replies - 2305 Views - Last Post: 10 July 2008 - 08:40 AM

#1 brandon_v   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 62
  • Joined: 29-May 08

Converting this horizontal carousel to verticle

Post icon  Posted 05 June 2008 - 04:12 AM

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):

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:

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: 05 June 2008 - 04:16 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Converting this horizontal carousel to verticle

#2 BetaWar   User is online

  • #include "soul.h"
  • member icon

Reputation: 1624
  • View blog
  • Posts: 8,481
  • Joined: 07-September 06

Re: Converting this horizontal carousel to verticle

Posted 06 June 2008 - 02:35 PM

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:
public var perspective:Number=0;


To something like this:

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.
Was This Post Helpful? 0
  • +
  • -

#3 raincoder   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-July 08

Re: Converting this horizontal carousel to verticle

Posted 10 July 2008 - 08:40 AM

I hope this tutorial will help you somehow
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1