PDA

View Full Version : Linkage coding help plz!



martinb18
March 13th, 2006, 12:06 PM
Hi, ive been following the 3d wheel turioal and its just what i want ive slighty edited it to suit what i need but i just cant seem to get other movie clips to go onto the wheel im pretty sure its to do with this line ( attachedObj = theScene.attachMovie("pane2", "pane2"+i, i);
) of code but dont quite know how to edit it can any one help plz?

// create a scene movieclip to contain all 3D elements
// and center it on the screen.
this.createEmptyMovieClip("theScene", 1);
theScene._x = 150;
theScene._y = 50;
// now we'r going to create an array to keep track of all the
// objects in the scene. That way, to position all the objects
// you just need to loop through this array.
objectsInScene = new Array();
// no camera, but a rotation will be needed to keep track of the
// spinning involved (though its the same as the camera)
spin = 0;
// focal length to determine perspective scaling
focalLength = 250;
// the function for controling the position of a friend
displayPane = function(){
var angle = this.angle - spin;
var x = Math.cos(angle)*this.radius;
var z = Math.sin(angle)*this.radius;
var y = this.y;

this._alpha = -z + 130;
var scaleRatio = focalLength/(focalLength + z);
this._x = x * scaleRatio;
this._y = y * scaleRatio;

this._xscale = this._yscale = 100 * scaleRatio;
// on top of the normal scaling, also squish the
// _xscale based on where in the rotation the pane is
// since you would be looking at its side when at a z
// of 0, it would be at its thinnest which would be
// 0 since its a completely flat pane. So for that,
// we can use the trig function of z (sin) to squish the
// _xscale based on its position in z.

this.swapDepths(Math.round(-z));
}

// attach each pane in a loop and arrange them in a
// circle based on the circumference of the circle
// divided into steps
angleStep = 2*Math.PI/8;
for (i=0; i<8; i++){

attachedObj = theScene.attachMovie("pane2", "pane2"+i, i);
attachedObj.angle = angleStep * i;
attachedObj.radius = 80;
attachedObj.x = Math.cos(attachedObj.angle) * attachedObj.radius;
attachedObj.z = Math.sin(attachedObj.angle) * attachedObj.radius;
attachedObj.y = 100;
attachedObj.display = displayPane;
objectsInScene.push(attachedObj);
}

Many thanks Martin

talonofdarkness
March 13th, 2006, 05:00 PM
right for the attachMovie, the first name inside the "" is the mc which u have exported for animation :)

so like say i create a movieclip i also set it to export for actionscript and name it say example1 so to use it with attachMovie i would do attachMovie("example1","a new name u wanna give this movieclip (e.g. example 2", _root.getNextHighestDepth);

:) so make sure u have a movieclip exported for actionshript with the export name as pane2 :)

martinb18
March 13th, 2006, 05:11 PM
right so do i just keep adding it on to this line for exsample i want to add a movie clip called pane3

attachedObj = theScene.attachMovie("pane2", "pane2" ,"pane3"+i, i);

or

attachedObj = theScene.attachMovie("pane2", "pane2"+i, i);
attachedObj = theScene.attachMovie("pane3", _root.getNextHighestDepth);

what i intend to do is add up to 70 different movieclips can this be done?

thanks Martin

talonofdarkness
March 13th, 2006, 05:47 PM
right basically u want

attachedObj = theScene.attachMovie("pane3", "{whatever u want it to be called e.g. pane3_mc}"+i,i);

so say u want to go somewhere in that atatchedmovie u would do

theScene.pane3_mc.gotoAndStop(1); :) i hope this helps.

martinb18
March 13th, 2006, 06:17 PM
i tried that but came out with some weird results there is only one ojbect and its static ?

http://www.funnycrew.co.uk/SpinningImages.fla thats my source file have i gone wrong some where ?

thanks again martin

talonofdarkness
March 13th, 2006, 07:15 PM
haahaa ok fixed it up basically the file test1 (the movieclip) is exported as test2, right click on test1 in the library and click on linkage, then set the name to test1 and it works :D

martinb18
March 14th, 2006, 04:56 AM
haahaa ok fixed it up basically the file test1 (the movieclip) is exported as test2, right click on test1 in the library and click on linkage, then set the name to test1 and it works :D

it sort of works but it replaces the the first movie clip so there still is only one movie clip spinning around, i want up to 70 different movie clips spinning around at once

thanks martin

talonofdarkness
March 14th, 2006, 11:00 AM
i wills ee what i can do XD

martinb18
March 14th, 2006, 11:49 AM
i wills ee what i can do XD

Cheers m8 hope u can solve it i will be ever greatful =)

martinb18
March 15th, 2006, 02:35 PM
any luck yet m8?

talonofdarkness
March 15th, 2006, 04:16 PM
no not yet i tried changing the attachMovie to attachMovie("pane_"+i"."pane"+i,i); but no luck >.<

martinb18
March 16th, 2006, 08:17 AM
right i think i have got some progress

this guy in another fourm has mention about using these lines of code



it looks like this line:
Code:attachedObj = theScene.attachMovie("pane2", "pane2"+i, i);
is going to add 8 instances of the "pane2" object to "theScene" since it's in your for loop (it will be repeated in every loop).

I assume you want to add different clips (like say "pane3", "pane4", etc) and what I would do is set up an array of the names, use the array name with the index number to add the clips:

set up the array:
Code:var paneArray:Array = ["pane2", "pane3", "pane4", etc];

Switch your for loop to count from 0 to 7 instead of 1 to 8 (array's start at index #0)

Then change your other code like this:
Code:attachedObj = theScene.attachMovie(paneArray[i], "pane"+i, i);


but as im still learning im not sure how to incorporate this into my code?

martinb18
March 16th, 2006, 08:25 AM
owait i belive i have figured it out thanks to this very useful infromation from another foum http://www.billybussey.com/forum/viewthread.php?tid=17488

objectsInScene = new Array();
var paneArray:Array = ["pane", "pane2", "pane4", etc];
var paneArray = [];
paneArray[0] = "pane";
paneArray[1] = "pane2";
paneArray[2] = "pane4";

and it works :) thanks for all you help man