Help me descipher the code please

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Help me descipher the code please

Post by DarkRanger »

Hi guys,

This is AS 2 code I found on the web. Can someone please add comments to it for me explaining what it does, because I have no idea and I want to write something in AS 3 that uses this code (I know it works, because the flash file does exactly what I want it to do, I just need to make adjustments to it).

Code: Select all

numOfBalls:Number = 10; //number of Icons it creates
var radiusX:Number = 250; //radius of circle
var radiusY:Number = 75; //radius of circle
var centerX:Number = Stage.width / 2; //center of circle
var centerY:Number = Stage.height / 2; //center of circle
var speed:Number = 0.05; // speed of rotation

for(var i=0;i<numOfBalls;i++)
{
	var t = this.attachMovie("ball","b"+i,i+1);
	t.angle = i * ((Math.PI*2)/numOfBalls);
	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)/1500;
}
Thanks,

DR
Image
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Re: Help me descipher the code please

Post by rustypup »

de·ci·pher (dĭ-sī'fər)
tr.v., -phered, -pher·ing, -phers.
  • i. To read or interpret (ambiguous, obscure, or illegible matter). See synonyms at solve.
    ii. To convert from a code or cipher to plain text; decode.
WiKi wrote:DES Cipher is a block cipher (a form of shared secret encryption) that was selected by the National Bureau of Standards as an official Federal Information Processing Standard (FIPS) for the United States in 1976 and which has subsequently enjoyed widespread use internationally.
which part of the code in particular is confusing to you?
Most people would sooner die than think; in fact, they do so - Bertrand Russel
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: Help me descipher the code please

Post by DarkRanger »

Oh thanks mister rusty!! :) Now I know the true meaning of it too. Please forgive me for being Afrikaans. :wink: Ugh, and my spelling didn't help either. lol

I'm looking to change the code from AS 2 to AS 3.

The part getting me is this:

Code: Select all

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);
}
I have no idea what it does.
Image
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Re: Help me descipher the code please

Post by rustypup »

having no knowledge whatsoever of AS, i'm going to go out on a limb and say it's positioning and scaling something...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
maxxis
Moderator Emeritus
Posts: 8307
Joined: 30 Jun 2004, 02:00
Location: ( . Y . )
Contact:

Re: Help me descipher the code please

Post by maxxis »

The problem is the way functions are written in AS3 vs AS2

What that function does is take the current object, icon I take it, and assigns a new x and y value to it based on a math calculation.

Also sets a rotation and scale to it which is odd. I don't see why it needs it.

Right at the end it does a layer depth adjustment based on the xScale of the object with 100 added to it which would make it current xScale + 100% which makes no sense at all.

Mail the original file to me at maxxis2112 at that gmail place .com
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: Help me descipher the code please

Post by DarkRanger »

I sent you the file yesterday.

Tell me if you got it please! :)
Image
maxxis
Moderator Emeritus
Posts: 8307
Joined: 30 Jun 2004, 02:00
Location: ( . Y . )
Contact:

Re: Help me descipher the code please

Post by maxxis »

Got the file. Will look at it in the morning.
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: Help me descipher the code please

Post by DarkRanger »

Any news maxxis?
Image
Post Reply