I have done a test code to create plattform to move down and then go back to the top.
It works, but when i copy the code and paste it for the game then I get this error.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@3633941 to plattform.
I have localized who cause the problem but I don’t know how to fix it.
Here is the problem
var tempPlatt:plattform = plattform(this.getChildAt(j));
The rest of the code
//Create plattform
for(var i:int=0;i<6;i++) {
var myPlatt:plattform = new plattform();
myPlatt.x = Math.random() *330+10;
myPlatt.y = -650+i*100;
myPlatt.name = "minPlatt" +i;
addChild(myPlatt);
}
this.addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
function onEnterFrameHandler(evt:Event):void {
for(var j:int=0;j<this.numChildren;j++) {
var tempPlatt:plattform = plattform(this.getChildAt(j));
//Change Speed
tempPlatt.y +=1.5;
if(tempPlatt.y >550){
tempPlatt.x = Math.random() *330+10;
tempPlatt.y =-50;
trace(tempPlatt.x);
trace(tempPlatt.name);
}
}
}