Ultrashock Forums > Flash > Flash Newbie
Please help with 3d in Flash and AS3 syntax.
Member Blogs
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Please help with 3d in Flash and AS3 syntax.
Old 4 Weeks Ago

Hey.

I am working on a project, a sphere in 3d with points on its surface to be connected at run time. Those points' coordinates are stored in arrays. I was able to make everything work, a simple version in the beginning, and I am ready to ,see if it works with all the points, there are over 1000 arrays, but I cannot write the code without getting syntax error messages.

For example, right now I have:

"
var l1:Number = points1Array.length;

var l2:Number = points2Array.length;

var l3:Number = points3Array.length;

var l4:Number = points4Array.length;"

but I want to use a "for" statement or something similar, so all the variables are declared with one piece of code, like:

for (i=0; i<1000; i++) {

var "l+[i]":Number = points[i]+Array.length;

}

Following are blocks of code which I would need to rewrite in a compact form but I am not able to do it:

1.
var l1:Number = points1Array.length;
var l2:Number = points2Array.length;

2.
var continents1Array:Array=[];
var continents2Array:Array=[];

3.
setContinents1Array();
setContinents2Array();

4.
function setContinents1Array():void {
var i:int;
var Tetha:Number;
var Phi:Number;
/*//We convert t and p into radians.
Tetha=Tetha*Math.PI/180;
Phi=Phi*Math.PI/180;*/
var loop:int = 0;
for (i=0; i<l1/2; i++)
{
Tetha=(points1Array[loop])*Math.PI/180;
Phi=(89.536-points1Array[loop+1]*Math.PI/180);
continents1Array[i]=[R*Math.cos(Tetha)*Math.sin(Phi),R*Math.sin(Tetha)*Math.sin(Phi),R*Math.cos(Phi)];
loop+=2;
}
}

function setContinents2Array():void {
var i:int;
var Tetha:Number;
var Phi:Number;
/*//We convert t and p into radians.
Tetha=Tetha*Math.PI/180;
Phi=Phi*Math.PI/180;*/
var loop:int = 0;
for (i=0; i<l1/2; i++)
{

Tetha=(points2Array[loop])*Math.PI/180;
Phi=(89.536-points2Array[loop+1]*Math.PI/180);
continents2Array[i]=[R*Math.cos(Tetha)*Math.sin(Phi),R*Math.sin(Tetha)*Math.sin(Phi),R*Math.cos(Phi)];
loop+=2;
}
}

5.
drawCont1();
drawCont2();
drawCont3();


6.

function drawCont1():void {
shCont.graphics.lineStyle(1,0x00FFFF);

for (n=0; n<l1/2-2; n++)
{
shCont.graphics.moveTo(dispCont1Array[n][0],dispCont1Array[n][1]);
shCont.graphics.lineTo(dispCont1Array[n+1][0],dispCont1Array[n+1][1]);


}
}

function drawCont2():void {
shCont.graphics.lineStyle(1,0x00FFFF);

for (n=0; n<l2/2-2; n++)
{
shCont.graphics.moveTo(dispCont2Array[n][0],dispCont2Array[n][1]);
shCont.graphics.lineTo(dispCont2Array[n+1][0],dispCont2Array[n+1][1]);


}
}

Help will be greatly appreciated.
postbit arrow 3 comments | 277 views postbit arrow Reply: with Quote   
hopo
Registered User
hopo is offline
seperator
Posts: 3
2005-04-13
seperator

Ultrashock Member Comments:
Sundev Sundev is offline Sundev lives in United States 4 Weeks Ago #2 Old  
What error are you getting?
Reply With Quote  
hopo hopo is offline 4 Weeks Ago #3 Old  
1084: Syntax error: expecting identifier before l+[i].
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is online now Nutrox lives in United Kingdom 1 Blog Entries 13 Creative Assets 4 Weeks Ago #4 Old  
You can't define variables like that, you will probably need to push all of the values into another Array...

Code:
var lengths:Array = [];

for (i=0; i<1000; i++) {

lengths[ i ] = points[ i ] + Array.length;

}
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: