-
[FL8-AS2.0]Passing MC coordinatesto a function whitin a class
Hi,
Im new with flash classes (just started learning) and i've finished those small tutorials, so i gave myself, lets call it a mission to make something bigger :P
And here i'am with a problem (hope its an easy one for you guys.. and girls):
I have a class named Test in Test.as file :
Code:
class Test{
public function set movePlayer(_Playah:MovieClip):Void {
trace(_Playah._x);
}
}
and when I "run" this function in my .fla file, its says "undefined" (for this position):S
i have no ideas how to "pass" MC informations to a function inside a class (x,y coordinates, rotation..) although when I trace only "_Playah" it shows the correct name of MC i've passed to it.
pls, give mi some tip how to solve this problem
tnx
Last edited by weeblo; 07-21-2009 at 08:31 PM.
-
http://pat.theorigin.net
This is the situation?
PHP Code:
import Test; var myPlayer = new Test(); var yourPlayer = createEmptyMovieClip(); attachMovie(yourPlayer, getNextHighestDepth()); myPlayer.movePlayer = yourPlayer; //traces 0
-
 Originally Posted by cresquin
This is the situation?
PHP Code:
import Test;
var myPlayer = new Test();
var yourPlayer = createEmptyMovieClip();
attachMovie(yourPlayer, getNextHighestDepth());
myPlayer.movePlayer = yourPlayer;
//traces 0
i have this in .as
PHP Code:
class Test{
public var _First:Number;
public var _Playah:MovieClip
public function get movePlayer():Void {
trace(_Playah._x);
trace(_Playah);
}
public function get bibe():Void {
trace("TeST");
}
}
and in fla
PHP Code:
var Group:Array = new Array();
//this creates an array of objects (found this on google)
//because there should be more than one "player"
for (var i = 0; i<4; i++) {
var carTest:Test = new Test();
carTest._First = i;
Group.push(carTest);
}
Group[0]._Playah = "blob"; //blob is MC instance name
Group[0].bibe(); // traces TeST
Group[0].movePlayer(); //traces p-undefined in the first line, and in another line blob
and MC blob is just a small red round circle 
and let me explain the game im working on 
First of all, i want to make something like a car based game. Nobody could drive these cars and this game would be like a "live preview" of a race.
With class (thats why i created an array of objects) i'll pass the coordinates by which cars should move (coordinates are held in XML file)
Coordinates represent path, and are generated with php.
Also, besides coordinates, another information should be added, such as speed on specific location (for each car), name of map and so on..)
So, is this the right way to create such a game ? Are there any additional things i should pay attantion on ?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|