xbox live gold membership generator chrysler financial make a payment jeans for big thighs small waist desktop backgrounds for macbook pro windows xp internet backgammon os x snow leopard server serial number canon powershot sx20 is price in malaysia summer 2010 fashion internships in new york snowboarding games online free guitar hero world tour unlock all songs cheat buy commercial truck tires online yamaha atv parts yamaha outboards troubleshooting samsung lcd tv problems black screen dress up barbie games to play satellite tv for pc elite edition password subaru outback 2010 review canada diamond solitaire engagement rings monster truck games online for kids watch summer heights high episode 1 online samsung lcd tv troubleshooting no picture nikon d5000 prices in dubai limewire basic for mac os x bridezillas where are they now karee rpg maker 2003 rtp cheap dresses for juniors online wireless headphones for ipod touch 1g youtube malayalam movies xbox 720 pics xbox 360 hard drive transfer kit gamestop student doctor network interview feedback compaq mini netbook with intel atom processor used pool tables for sale in michigan download auctioneer addon for wow chrysler town and country parts mitsubishi lancer evolution x mr pizza hut coupons online codes 2001 chrysler sebring convertible parts boots online shopping ireland canon rebel eos manual ds6041 honda civic hatchback parts for sale skype download for blackberry curve 8520 famous love quotes from the notebook healthy pizza dough no yeast pizza hut menu with prices canada wedding invitation wording divorced parents mdi reader download jar software free download for mobile travelocity gnome commercial song cruises only coupons best screensavers for mac snow leopard xbox 360 games on demand hack student loans without cosigner and no credit dvd ripper for mac freeware jcpenney furniture outlet atlanta ga cocktail dresses online cheap youtube video to mp3 converter for mac paid summer internships new york city radiohead tour 2010 north america dodge journey 2009 sxt housecall antivirus helmets for motorcycles in india free playstation network card generator bathroom shower tiles pictures nintendo ds roms free download english canon rebel xti vs nikon d5000 best wireless headphones for tv listening porsche 911 turbo for sale craigslist snowflake patterns crochet backpacks for college radio disney live stream wireless n router review cnet truck mount carpet cleaning machines for sale subaru 22b sti for sale commercial carpet steam cleaning machines hairstyles for women over 60 pictures bride wars soundtrack listen wireless n router range comparison free elementary career interest inventory bmw m3 for sale cheap tires plus locations in florida next radiohead tour 2010 pontiac grand prix gtp supercharged transmission websites like craigslist personals samsung i8000 omnia ii reviews gps maps for blackberry playstation 3 gamestop trade in value barcode scanner java api laptops cheapest uk project portfolio management software open source radiohead tour 2010 uk dating simulation games for girls online porsche carrera gt for sale in us pontiac gto judge 1969 for sale land rover freelander parts diagram samsung plasma tv calibration settings honda motorcycle parts warehouse honda generators eu2000i rpg maker vx sprite generator download snowboarding jackets on sale for women replica daft punk helmets for sale portfolio lighting replacement parts playstation 3 network card generator 2010 mazda 3 replacement parts infinity ward nat strict pc jeep wrangler unlimited for sale in iowa rpg maker vx activation code free nissan skyline gtr for sale in florida dvdfab registration key generator dvdfab 6 keygen download download snowboarding games for pc porsche cayenne 2010 prices hp psc 1610 scanner software for vista autotune 5 download for windows princess cut diamond engagement rings cheap free strip blackjack canon rebel xsi tutorial video murray riding lawn mower parts diagram nintendo ds roms download free xbox live ban wave finished glassjaw tour dates 2010 buy cigarettes online paypal mazda 626 manual transmission guitar pro 6 release date bmw m3 2010 prices mazda reviews mercedes benz amg black edition 2011 cadillac cts v coupe motorcycle repair manuals for free subaru forester parts catalog wedding reception invitation wording examples skype for mac snow leopard movies online streaming new moon dvd ripper for mac snow leopard playstation emulator vista download software architecture in practice ppt shirt printing machines for sale hyundai santa fe 2010 release date samsung mythic a897 price in india rolex prices datejust flash player 9 free download firefox marlboro cigarettes online usa radio stations online free hip hop mitsubishi lancer evolution for sale used volkswagen jetta sportwagen tdi for sale honda financial services phone number handbags leather manufacturer mazda tribute parts diagram wedding vows traditional catholic tattoo quote ideas for girls logo creator software free download canon rebel xti vs nikon d3000 nissan skyline gtr for sale in california tools download free skype video conference 3 people templates for powerpoint games kids snow boots clearance uk jeep grand cherokee reviews 2000 design your own wedding dress online free game xbox tips toyota prius prices paid canon s90 review ken rockwell radiohead tour dates 2010 furnitureland south bankruptcy skinny jeans for men on sale crochet snowflake patterns free pizza hut menu prices us design your own wedding dress for free wedding shower favors homemade 1971 volkswagen beetle convertible for sale wireless bridge linksys wrt160n snowboarding gloves or mittens gps coordinates conversion formula mercedes benz parts online uk jaguar xk8 performance parts snowboard pants sale nikon d60 manual download free land rover defender 110 for sale travelers insurance commercial song worry mobile satellite internet service providers tattoo wedding rings pictures furniture liquidators denver download logo maker freeware sony ereader touch backlight download desktop destroyer 2 chicken carnage how to make pizza dough without yeast and baking powder skype download vista 64 bit cypress hill torrent summer paid internships 2010 design your own engagement ring tiffany prom dresses for prom 2010 modem commands us robotics xbox 360 e73 repair guide roses are red poems funny crocodile monitor lizards for sale marriage counseling infidelity wedding dresses pictures for men dvdfab 6 platinum registration key master bathroom renovation ideas warcraft 3 cd key finder tires plus corporate headquarters sony reader vs kindle vs nook sony vegas 9 serial number free toyota corolla parts catalog playstation emulator mac os x snow leopard guitar tuner drop c tuning mitsubishi lancer ralliart specs skype phone wifi dress up games and makeover games and cooking games tattoo ideas for girls wrist yamaha baby grand piano for sale compaq presario c700 drivers for xp suzuki sidekick parts manual templates for resumes for teachers samsung mythic a897 black wifi porsche cayenne forum italian pizza recipes dough nintendo ds emulator for iphone 3g golf digest hot list 2010 irons toyota oem parts discount winter olympics history wow cataclysm worgen druid forms famous movie quotes from the 80s gps maps free download tomtom wedding ceremony songs christian sony vaio recovery disk free download laminate flooring installation instructions pergo caribbean weather forecast subaru impreza wrx sti for sale in canada toyota forklift parts catalog skype emoticons hidden volkswagen tiguan review top gear cable modem hacking software sofas direct from factory wholesale handbags designer inspired kawasaki mule parts diagram antique harley davidson motorcycle parts sample resume restaurant waitress monitor audio rx8 test logo design freeware download honda civic 2010 price egyptian arts and crafts for kids example career essays tattoos ideas for girls pictures flooring options for screened porch toyota recall gas pedals honda accord forum 7th gen toyota camry recall 2009 guitar tabs for beginners acoustic mazda rx8 performance parts tattoos quotes for guys guitar tuner widget os x suzuki gsxr motorcycles for sale xbox 360 games torrent tracker volkswagen tiguan 2010 release date used mercedes amg for sale yamaha vmax motorcycles for sale harley davidson sportster parts and accessories snowboard pants men toyota corolla floor mat recall football fanatics coupon code 20 off sofa beds for sale in san diego ca sony psp 3000 games free download dresses for prom under 100 dollars latin tattoo quote ideas subaru wrx parts catalog grassroots lobbying examples mac logo creator freeware hyundai genesis coupe review chevrolet tahoe police package for sale toyota center seating chart 3d download gps maps europe lawnmower man game jaguar cars for sale on ebay warcraft 3 cheats reign of chaos suzuki grand vitara parts online subaru forester forum singapore saturn ion performance parts xbox 360 transfer kit gamestop jeans size chart forever 21 beginner guitar chord chart printable winter olympics 2010 tv coverage mercedes parts hardware temperature monitor windows 7 mitsubishi outlander 2010 commercial song craftsman tool boxes on wheels illuminated bathroom mirrors with shelf subaru baja turbo mpg dresses to wear to a wedding games for girls flight attendant mile high club sony vegas free download for mac suzuki samurai engine swap kit jeep grand cherokee 2011 release date yamaha atvs for sale cheap toyota venza 2010 hybrid 1998 mitsubishi eclipse spyder parts guitar chord chart finger position guitar tabs for sweet home alabama for beginners toyota recalls rav4 famous movie quotes quiz toyota body parts used guest bathroom color ideas mercedes benz sl55 amg price xbox 360 elite vs ps3 specs jeanstar jeans macys toyota recall list accelerator installing laminate flooring on stairs video harley davidson accessories for dogs guitar chord chart finger placement free soccer drills for 4 year olds dodge charger srt8 for sale used perfume outlet online snow leopard hackintosh laptop compaq presario v2000 laptop motherboard rpg maker vx resources faces warcraft 3 download free for mac tattoos for guys forearms kitchenaid dishwasher parts diagram mitsubishi parts oem guitar pro torrent mac toyota land cruiser parts and accessories modern wedding invitation wording examples lexus is 250 for sale by owner animation factory essential collection honda generators prices tattoo quote ideas for men famous funny poems about school software testing tutorials for beginners pdf chrysler 300 accessories canada cruises only coupon code garden of eden key west web cam summer internships for college students 2010 invoice templates free microsoft word jeep wrangler unlimited hardtop volkswagen gti 2010 price volkswagen beetle convertible pink mitsubishi evo 8 mr for sale winter jackets for men sale winter bells game cheat sony ericsson equinox reviews samsung moment vs htc hero comparison replica cowboy guns computer science resume objective dvdfab registration key 6 harley oem parts online 2000 jaguar s type parts clothes horse store samsung omnia i910 firmware update download snowflake patterns photoshop saturn vue transmission problems canon powershot a480 manual pdf biketoberfest 2009 pictures famous deaf people in history glass bongs online store gamecube emulator mac os x 2005 volkswagen beetle convertible for sale mitsubishi eclipse spyder body kits kia sportage 2008 problems coach shoes on sale at dillards wedding dresses pictures indian desktop wallpaper for macbook pro software manual testing interview questions hair color pictures highlights guitar chord chart poster famous short funny poems dvd shrink free download for mac mattress firm clearance center toyota tacoma lift kits 2wd world war 2 replica cap guns toyota camry parts for sale warcraft 2 tides of darkness mac download unblock facebook proxy at school ford trucks for sale in florida mitsubishi electric air conditioning remote control jeep grand cherokee 2011 video nissan versa hatchback reviews 2010 laminate flooring installation costs toyota camry 2010 recall mercedes e63 amg wagon for sale volkswagen passat cc 2010 famous american ceramic artists facebook layouts for mac empire carpeting reviews tattoo ideas for men quotes biker chicks photos college football recruiting rankings 2011 isuzu trooper engine diagram cable tv providers by zip code daft punk helmets for sale equalizer software mazda rx 8 r3 body kit replica cap guns snow white and the seven dwarfs story script linux commands list pdf free tattoo cursive lettering bathroom wall tile design ideas famous love poems sonnets tattoo script lettering alphabet satellite internet connection wwe dvd release schedule 2010 linux ubuntu beryl download free funny wedding vows write your own compaq presario c700 specifications movie replica airsoft guns compaq presario f700 drivers for windows 7 winter olympics history wiki summer heights high quotes jonah takalua used opel cars for sale in germany bathroom vanities cabinets wireless router booster homemade acoustic guitar scales beginners mercedes benz e63 amg coupe volkswagen parts diagrams software testing life cycle flow chart bicycles for sale at walmart toyota recall 2009 list apartments for rent in philadelphia no credit check why is flash flash revolution down used pool tables for sale dallas tx porsche boxster spyder 2010 guitar power chords chart t shirt dress sewing pattern youtube indian movies songs the jewelry exchange complaints hyundai elantra 2010 mpg compaq presario v6000 specs toyota tacoma used 4x4 mazda 626 parts online list of toyota recall september 2009 warcraft 3 cd key battlenet custom jeep cherokee bumpers famous poems about death and loss furniture factory outlet missouri suzuki sx4 forum toyota tacoma 2010 diesel used mud tires for sale cheap girls pantsed and wedgied pics chrysler sebring parts diagram minivan gas mileage comparison chart mens underwear blogspot vinyl siding colors pictures harley davidson parts made in china dvd decrypter download 64 bit poster templates free powerpoint logo creator freeware mac linux mint download mirror jewelry instructions mercedes benz accessories bluetooth wow cataclysm release date rumors jaguar xj 2010 test drive mitsubishi lancer evolution x for sale online rpg space star wars designer wedding dresses with sleeves famous historical hispanic people rolex submariner price used subaru outback gas mileage guitar chords chart printable facebook login proxy chrysler sebring 2008 owners manual compaq mini 110c netbook canon g11 manual pdf hair color trends winter 2010 samsung impression covers pool table dimensions room size civilian contracting jobs overseas portfolio cases for modeling tattoos for guys chest xbox 720 real pictures recipes for chicken breast strips kitchen islands for sale in toronto bathroom corner vanity cabinets youtube full length movies malayalam volkswagen tiguan 2010 diesel summer internships for high school students 2010 samsung solstice a887 black wifi volkswagen jetta for sale by owner gps maps for blackberry 9000 pontiac grand prix for sale in michigan jaguar xf problems radio stations for sale california minivan with best gas mileage toyota sienna parts catalog sturgis biker chicks photos kawasaki ninja 250r mpg golf shoes closeouts volkswagen gti forum play pocket god online game mitsubishi eclipse parts oem flowers for algernon short story summary laptop computer deals walmart dvdfab 6 key siding colors home depot kitchen islands with breakfast bars subwoofer wiring calculator samsung eternity apps glass bongs and pipes for sale laptop computer deals under 400 wireless internet connection keeps dropping pokemon rpgs online best gps systems for truck drivers subaru legacy oem parts open gps tracker android toyota tacoma gas mileage basketball plays motion offense isuzu npr snow summit lift tickets coupons tattoo ideas for men forearm winter olympics 2014


A Simple Papervision Carousel

Papervision 3D Carousel

download-source

This week I set out to create a Papervision Carousel in it's simplest form. At the heart of this carousel is a simple "for" loop / math which places the items in a circle in 3D space

Actionscript:
  1. for (var i:int = 0; i <planes.length; i++)
  2. {
  3.     var angle:Number    = Math.PI * 2 / numItems * i;
  4.     var plane:Plane     = planes[i];
  5.     plane.x             = Math.cos(angle) * radius;
  6.     plane.z             = Math.sin(angle) * radius;
  7.     plane.rotationY     = -360 / numItems * i - 90;
  8. }

Then to rotate our carousel we apply some similar math

Actionscript:
  1. var rotateTo:Number = (-360 / numItems) * currentItem + 90;
  2. TweenLite.to(planesHolder, 1, { rotationY:rotateTo, ease:Quint.easeInOut } );

This code allows us to just increment currentItem and rotate our carousel. Another easy add-on would be to setup a navigation along the bottom where you could control and change the currentItem to a specific number to rotate right to that section of the carousel.

It's also very easy to customize the number of items and radius of the carousel by adjusting these numbers.

Actionscript:
  1. protected var numItems:Number = 20;
  2. protected var radius:Number = 500;

Here is the full code.

Actionscript:
  1. package
  2. {
  3.     import flash.display.DisplayObject;
  4.     import flash.display.MovieClip;
  5.     import flash.display.Sprite;
  6.     import flash.events.Event;
  7.     import flash.events.MouseEvent;
  8.     import gs.easing.Quint;
  9.     import gs.TweenLite;
  10.     import org.papervision3d.materials.BitmapFileMaterial;
  11.     import org.papervision3d.objects.DisplayObject3D;
  12.     import org.papervision3d.objects.primitives.Plane;
  13.     import org.papervision3d.view.BasicView;
  14.    
  15.     /**
  16.      * ...
  17.      * @author Charlie Schulze, charlie[at]woveninteractive[dot]com
  18.      */
  19.    
  20.     public class Main extends BasicView
  21.     {
  22.         protected var planes:Array = [];
  23.         protected var numItems:Number = 20;
  24.         protected var radius:Number = 500;
  25.         protected var currentItem:Number = 0;
  26.        
  27.         protected var mat:BitmapFileMaterial;
  28.         protected var planesHolder:DisplayObject3D;
  29.         protected var rightBtn:Sprite;
  30.         protected var leftBtn:Sprite;
  31.        
  32.         public function Main():void
  33.         {
  34.             super();
  35.             init();
  36.         }
  37.         protected function init():void
  38.         {
  39.             createChildren();
  40.             createButtons();
  41.             commitProperties();
  42.             startRendering();
  43.         }
  44.         protected function createChildren():void
  45.         {
  46.            
  47.             planesHolder = new DisplayObject3D();
  48.            
  49.             //Create Material
  50.             mat             = new BitmapFileMaterial("images/queen.gif");
  51.             mat.smooth   = true;
  52.             mat.doubleSided = true;
  53.            
  54.             for (var i:int = 0; i <numItems; i++)
  55.             {
  56.                 var plane:Plane = new Plane(mat, 150, 234);
  57.                 planes.push(plane);
  58.                
  59.                 //Add plane to the scene
  60.                 planesHolder.addChild(plane);
  61.             }
  62.             scene.addChild(planesHolder);
  63.         }
  64.        
  65.         protected function commitProperties():void
  66.         {
  67.             //Set properties of our planes
  68.             for (var i:int = 0; i <planes.length; i++)
  69.             {
  70.                 var angle:Number    = Math.PI * 2 / numItems * i;
  71.                 var plane:Plane     = planes[i];
  72.                 plane.x             = Math.cos(angle) * radius;
  73.                 plane.z             = Math.sin(angle) * radius;
  74.                 plane.rotationY     = -360 / numItems * i - 90;
  75.             }
  76.            
  77.             //Adjust camera
  78.             camera.y = 200;
  79.            
  80.             //Rotate once
  81.             rotate();
  82.         }
  83.  
  84.         //Rotates the carousel
  85.         protected function rotate():void
  86.         {
  87.             var rotateTo:Number = (-360 / numItems) * currentItem + 90;
  88.             TweenLite.to(planesHolder, 1, { rotationY:rotateTo, ease:Quint.easeInOut } );
  89.         }
  90.        
  91.         /*
  92.          * Everything below this point is just for creating the buttons and
  93.          * setting button events for controlling the carousel.
  94.          */
  95.  
  96.         protected function createButtons():void
  97.         {
  98.             //Create Buttons
  99.             rightBtn = createButton();
  100.             leftBtn = createButton();
  101.                
  102.             addChild(leftBtn);
  103.             addChild(rightBtn);
  104.            
  105.             //Add button listeners
  106.             rightBtn.buttonMode = true;
  107.             leftBtn.buttonMode = true;
  108.             rightBtn.addEventListener(MouseEvent.CLICK, buttonClick);
  109.             leftBtn.addEventListener(MouseEvent.CLICK, buttonClick);
  110.                        
  111.             //Place buttons on stage
  112.             rightBtn.x    = stage.stageWidth - 120;
  113.             leftBtn.x       = 100;
  114.             rightBtn.y    =  stage.stageHeight / 2;
  115.             leftBtn.y       =  (stage.stageHeight / 2) + 20;
  116.             leftBtn.rotation    = 180;
  117.         }
  118.        
  119.         //Button actions
  120.         protected function buttonClick(evt:MouseEvent):void
  121.         {
  122.             switch (evt.target)
  123.             {
  124.                 case rightBtn:
  125.                 currentItem --;
  126.                 break;
  127.                
  128.                 case leftBtn:
  129.                 currentItem ++;
  130.                 break;
  131.             }
  132.             rotate();
  133.         }
  134.        
  135.         //Creates a simple arrow shape / returns the sprite
  136.         protected function createButton():Sprite
  137.         {
  138.             var btn:Sprite = new Sprite();
  139.            
  140.             btn.graphics.beginFill(0x333333);
  141.             btn.graphics.moveTo(0, 0);
  142.             btn.graphics.lineTo(0, 20);
  143.             btn.graphics.lineTo(10, 10);
  144.             btn.graphics.lineTo(0, 0);
  145.             btn.graphics.endFill();
  146.             return btn;
  147.         }
  148.     }
  149. }

Feel free to post links to ways you expand upon this file.

download-source

Post to Twitter Post to Delicious Delicious Post to Digg Digg This Post Post to Facebook Facebook Post to StumbleUpon Stumble This Post

6 Responses to “A Simple Papervision Carousel”


  • Hi,

    the tutorial and view is great, but after one more desperate day with as, I still worry about this:
    HOW TO MAKE THE IMAGES CLICK-ABLE.
    I tried already any kind of AddEventListener… and also
    mat.interactive = true;
    mat.addEventListener(MouseEvent.CLICK, ClickFunction123);

    But it looks like this event is not implemented :-(
    Please help

  • You’re on the right track. Yes the material “mat.interactive = true;” needs to be set. When you are doing mouse events you do not apply them to the material but to the object. so instead of mat.addEventListener you will do plane.addEventListener and instead of using a MouseEvent you need to use an InteractiveScene3DEvent as follows:

    plane.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, onPlaneClick);

    The other thing to keep in mind is that you need to make sure that your viewport is set to interactive as well.

    viewport.interactive = true;

    Do that and you should have success.

    Charlie

  • Heho,
    Had to deal with the same issue last year. It was a bit confusing because the mat.interactive must be true and the plane gets the eventlistener.
    Next confusion came with the event which can not be the standard events, but has to be InteractiveScene3DEvent and took lots of hours of reading through the source :-)
    After that, it took some more minutes to find out the viewport.interactive which is not directly addressed anywhere in this sample, but played with viewport in another papervision test already.
    Now it’s working properly.
    Congratulation, papervision is a really cool “library”.
    Best regards,
    rabby

  • Thanks for the tutorial. I am new to flash and as3, and am having a hard time. I can’t seem to figure out how to make this carousel rotate relative to the position of the mouse (similar to your cow example). I also would like to set a min and max speed. Can someone help me please : )

    Thanks

  • Ok so I figured out if I add this to the render camera code it rotates the carousel to the mouse:

    var dist2:Number = ((stage.mouseX) – stage.stageWidth * 0.5) * 0.0002;
    angle += dist2;
    cam.x = Math.cos(angle) * 1000;
    cam.z = Math.sin(angle) * 1000;

    But I still would like to add a max speed. It also seems to go faster if the mouse if on the left and pretty slow if mouse is on the right Does anyone know why that is doing it and how to fix it? Also how could I insert an image into the center of the carousel that does not move/rotate? Thanks for the help!

  • Hello!
    Thank you so much for the tutorial, but I have a question, I need to incorporate more images in the carousel. I try to do with XML such as in other example that you have but a can´t.
    PD: Sorry for my english I don´t speak so good.

Leave a Reply


Follow papervision2 on Twitter

Flash and the City banner
2010 Flash And The City Speaker

RSS Feed