Problem with this code ...can someone explain

  • viki9
  • Novice
  • Novice
  • viki9
  • Posts: 16

Post 3+ Months Ago

Hi and thanks in advance for reading this

Ok i got a code from this webiste http://www.n99creations.com/vieweg.php?id=4 its a circlar Menu and i've downloaded the sample file....it works fine and all but i only want it to work for 4 buttons instead of 5 buttons but when i delete one button it doesn't move any more and plus i tried my best to change the code but i'm not very good in array
Here is the code

Code: [ Select ]
var xCentre:Number = Stage.width/2;
var yCentre:Number = Stage.height/2;
var radius:Number = 150;
var myArray:Array = [];
var allClips:Array = [];
var i:Number = 1;
var easeSpeed:Number = 10;
while (_root["but"+i]) {
    _root["but"+i].ivar=i, allClips.push(_root["but"+i]);
    _root["but"+i++].onEnterFrame = spin;
}
for (var e:Number = 1; e<i; e++) {
    myArray.push((2*Math.PI)*_root["but"+e].ivar/(i-1));
}
onEnterFrame=function () {
    for (var obj in allClips) {
        allClips[obj].theta = myArray[obj];
    }
}, leftButton.onPress=function () {
    var lastItem = allClips[allClips.length-1];
    allClips.pop(), allClips.unshift(lastItem);
}, rightButton.onPress=function () {
    var firstItem = allClips[0];
    allClips.shift(), allClips.push(firstItem);
};
function spin() {
    this._x += ((xCentre+Math.cos(this.theta)*radius)-this._x)/easeSpeed;
    this._y += ((yCentre+Math.sin(this.theta)*radius)-this._y)/easeSpeed;
}
  1. var xCentre:Number = Stage.width/2;
  2. var yCentre:Number = Stage.height/2;
  3. var radius:Number = 150;
  4. var myArray:Array = [];
  5. var allClips:Array = [];
  6. var i:Number = 1;
  7. var easeSpeed:Number = 10;
  8. while (_root["but"+i]) {
  9.     _root["but"+i].ivar=i, allClips.push(_root["but"+i]);
  10.     _root["but"+i++].onEnterFrame = spin;
  11. }
  12. for (var e:Number = 1; e<i; e++) {
  13.     myArray.push((2*Math.PI)*_root["but"+e].ivar/(i-1));
  14. }
  15. onEnterFrame=function () {
  16.     for (var obj in allClips) {
  17.         allClips[obj].theta = myArray[obj];
  18.     }
  19. }, leftButton.onPress=function () {
  20.     var lastItem = allClips[allClips.length-1];
  21.     allClips.pop(), allClips.unshift(lastItem);
  22. }, rightButton.onPress=function () {
  23.     var firstItem = allClips[0];
  24.     allClips.shift(), allClips.push(firstItem);
  25. };
  26. function spin() {
  27.     this._x += ((xCentre+Math.cos(this.theta)*radius)-this._x)/easeSpeed;
  28.     this._y += ((yCentre+Math.sin(this.theta)*radius)-this._y)/easeSpeed;
  29. }


now i just want only 4 buttons to rotate ....can someone explain what is the code about ...becoz they just gave code and no explaination ....i wanna know what it means no point of doing projects if u don't understand them ....please help
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.