Urgent problem…(AS3)

By Xoria | Jul 6, 2009

actionscript3

In my file, I mixed up something AS2 stuff with some AS3, and it gave me problems. I got a few error and warnings messages after I tried to fire up the SWF…

Firstly, what’s wrong with the following lines? I got 4 error messages for all of them all throughout my work. (Not in any particular order)

Line 1:function init() {
Line 2:var items = 25;
Line 3:var layer = 10;
Line 4:function updateMovies() {

Secondly, I accidentally created some AS2 stuff into my AS3 folder… (I didn’t even recognize the diff at first!…) Now, I got a file with tons of Warnings. If anyone can send me a link of an accurate AS2-AS3 converter, or if anyone can point out what to change to get it to work in AS3, I’ll appreciate it beyond belief.

//define number of layer.
//number of items in a layer
var items = 25;
//create the bg that holds the layers
var layer = 10;
this.createEmptyMovieClip("bgHolder", this.getNextHighestDepth());
//this function will update the layers current position
function updateMovies() {
//easingStrenth
d = 10;
this.x = _root._xmouse;
this.y = _root._ymouse;

//get the linear relation fo x.
var coef = (Stage.width-this._width)/Stage.width;
//update x with easing.
this._x -= (this._x-coef*this.x)/d;
//get the linear relation fo y.
coef = (Stage.height-this._height)/Stage.height;
//update y with easing.
this._y -= (this._y-coef*this.y)/d;
}
//init function for the layers
function init() {
for (i=0; i<layer; i++) {
//create a layer
temp = this.bgHolder.createEmptyMovieClip("bg"+i, this.bgHolder.getNextHighestDepth());
depth = temp.getNextHighestDepth();
//create a virtual bag for the layer to define it height and width.
virtual_mc = temp.attachMovie("virtual", "vitrual"+depth, depth, {_visible:false, _width:(i+2)*Stage.width, _height:(i+2)*Stage.height});
//put the items into the layer
for (j=0; j<items; j++) {
depth = temp.getNextHighestDepth();
//attach an item
temp1 = temp.attachMovie("float1", "float"+depth, depth);
//position it randomly in the current layer
temp1._x = Math.random()*(i+2)*Stage.width;
temp1._y = Math.random()*(i+2)*Stage.height;
//scale it randomly
rand = Math.random();
temp1._xscale *= .5+rand;
temp1._yscale *= .5+rand;
//put is opacity randomly
temp1._alpha = random(80)+20;
}
//each layer share the same updating function.
temp.onEnterFrame = this.updateMovies;
}
}
init();

I BOLDED only problems .

actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0