Printable Version of Topic
Sandy's Forum _ AS2 1.x versions _ use MTASC complie error with tutorials files
Posted by: lavlav Oct 20 2006, 10:37 PM
I am first time to use MTASC to complie the tutorials file
but it has an error on it
QUOTE
function init( Void ):Void <<<<<< parse error Unexpected function
{ var ecran:ClipScreen = new ClipScreen( this.createEmptyMovieClip('ecran', 1), 300, 300 );
var cam:Camera3D = new Camera3D( 700, ecran);
World3D.getInstance().addCamera( cam );
var bg:Group = new Group();
createScene( bg );
World3D.getInstance().setRootGroup( bg );
World3D.getInstance().render();
}
.
.
.
and I try to add this
QUOTE
class init
{
function init( Void ):Void <<<<<< no error now
{ var ecran:ClipScreen = new ClipScreen( this.createEmptyMovieClip('ecran', 1), 300, 300 );
var cam:Camera3D = new Camera3D( 700, ecran);
World3D.getInstance().addCamera( cam );
var bg:Group = new Group();
createScene( bg );
World3D.getInstance().setRootGroup( bg );
World3D.getInstance().render();
}
}
.
.
.
then at the end of file will come out another error on
.
.
.
init(); <<<<parse error Unexpected init
I ask is how to correct it ?
I test the tutorials files "create a first box" and "skin the box" in flash8 is no problem
I don't know how to do it......
can anyone help me ?
THX
PS. I am a very newbie to learn flash programming , and sorry for my poor english
Posted by: kiroukou Oct 20 2006, 11:08 PM
Hi,
no pb for your english 
Well you are trying to mix two different approach here.
MTASC needs a static main function to start an application.
Here you should write :
(rename your class InitTest for example)
CODE
class InitTest
{
public InitTest()
{
//constructor
init();
}
function init()
{
put the tutorial code here
}
public static function main()
{
var e:InitTest = new InitTest();
}
}
In fact with MTASC, your code MUST be completely object oriented and class based.
In the tutorial I'm using a procedural approach in Flash IDE, which allows that.
You need to port this code into a class to be able to test in with MTASC once again

++
Posted by: lavlav Oct 23 2006, 07:47 PM
very thanks for your helpful and teaching
I am so clumsy in programming
10 years ago, I was learn C ,but later I give up
because programm is very hard for me to learn
I following your code and do ,like this ,but also come an error
CODE
class InitTest
{
public InitTest() <<<<<< parse error Unexpected InitTest
{
//constructor
init();
}
function init()
{
// screen creation, the object where objects will be displayed.
var screen:ClipScreen = new ClipScreen( this.createEmptyMovieClip('screen', 1), 600, 600 );
// we create our camera
var cam:Camera3D = new Camera3D( 700, screen);
// we move the camera backward to be able to see the object placed at 0,0,0
cam.setPosition(0, 0, -500);
// we add the camera to the world
World3D.getInstance().addCamera( cam );
// we create the root node.
var bg:Group = new Group();
// and set it as the root node of the world.
World3D.getInstance().setRootGroup( bg );
// and we lauch the scene creation
createScene( bg );
// and now that everything is created, we can launch the world rendering.
World3D.getInstance().render();
}
function createScene( bg:Group )
{
// We create our object. It is a cube of 50 pixels
var o:Object3D = new Box( 50, 50, 50 );
// Now we simply link the Object leaf to the root node, and finish the tree creation
bg.addChild( o);
}
// We lauch the animation creation.
init();
public static function main()
{
var e:InitTest = InitTest();
}
}
I am try to search the web and also get no idea
I think I will need more more time to learn and make an exercise
thanks again
Posted by: kiroukou Oct 23 2006, 08:12 PM
Hi, no pbs 
You need to remove this part :
// We lauch the animation creation.
init();
Why?
Because yu allready call init function in the constructor. And you must
put the function calls (and all your programming stuff) INSIDE method
declaration 
++
Posted by: lavlav Oct 23 2006, 09:07 PM
sure , I am try a few days ,like del
// We lauch the animation creation.
init();
but also get in 3rd line
public InitTest() <<<<<< parse error Unexpected InitTest
and try to del the "Void" and "bg:Group"
something like that
I may temporary stop to try this ,and go back to learn action scripts
thx , very fast reply
Posted by: SamsamTS Nov 3 2006, 03:04 PM
Ahum...
I just was going around on this forum.
About
your problem, since InitTest is a function you have to declare it as a
function. Is it clear ? No ? Okay here is what i mean :
Replace public InitTest by public function InitTest
Bye
Posted by: lavlav Nov 4 2006, 08:13 PM
thx , SamsamTS
I try to change the code
but also same error....
Posted by: kiroukou Nov 5 2006, 05:31 PM
lavlav try to read some tutorials explaining how to create some AS2 classes.
and if you still need some help, please attach you code here.
++
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)