我无法解决错误 #2136 swf 包含无效数据
I cannot solve error #2136 swf contains invalid data
因此,我仍在开发我的 Tamagotchi 风格的游戏并使用单独的 classes,并且根据此处的建议,我将尽可能避免嵌套函数!
但是,我根据 hitTestObject
条件为 add/remove 食物编写了一些代码,它们在主要 class 中工作正常。
将所有内容移至 Food Class
后,我立即收到上述错误。
我试过使用痕迹并注释掉……我很难过。
这有点令人沮丧,因为作为一名学习者,我只是觉得我开始破解这个并且 WHAM 我撞墙了,这让我想起我实际上什么都不知道。
无论如何,我会很感激一些建议。
这是我的两个 classes 的代码。
再次感谢!
package {
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;
import DraggableItem;
import Food;
public class Tamagotchi extends MovieClip {
const BG_SPEED:int = 10;
const BG_MINX:int = -270;
const BG_MAXX:int = 0;
const BG_MINY:int = -200;
const BG_MAXY:int = 0;
var bG:BackGround = new BackGround();
var home:Home = new Home();
var soph:SophRun = new SophRun();
var item:DraggableItem=new DraggableItem();
var food:Food = new Food();
public function Tamagotchi() {
addChildAt(bG, 0);
bG.addChild(home);
home.x = 850;
home.y = 80;
addChild(soph);
trace("HI");
soph.x = 350;
soph.y = 250;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressListener);
stage.addEventListener(Event.ENTER_FRAME, bgScroll);
}
public function keyPressListener(e:KeyboardEvent):void
{
if (e.keyCode == 65)
{
soph.x -= 5;
soph.scaleX = 1;
}
if (e.keyCode == 68)
{
soph.x += 5;
soph.scaleX = -1;
}
if (e.keyCode == 87)
{
soph.y -= 5;
}
if (e.keyCode == 83)
{
soph.y += 5;
}
}//End of KeyPressListener
public function bgScroll(e:Event)
{
if (soph.x > 550 && bG.x > BG_MINX)
{
bG.x -= BG_SPEED;
soph.x -=2;
}
else if (soph.x < 150 && bG.x < BG_MAXX)
{
bG.x += BG_SPEED;
soph.x +=2;
}
else if (soph.y > 400 && bG.y > BG_MINY)
{
bG.y -= BG_SPEED;
soph.y -=2;
}
else if (soph.y < 400 && bG.y < BG_MAXY)
{
bG.y += BG_SPEED;
soph.y +=2;
}
}//End of bgScroll
} //End of Class
} //包结束
这是 Food Class
...
package {
import flash.display.MovieClip;
import flash.events.Event;
import Tamagotchi;
public class Food extends MovieClip{
var food1:Food1 = new Food1();
var food2:Food2 = new Food2();
var food3:Food1 = new Food1();
var food4:Food2 = new Food2();
var foodArray:Array = new Array(food1, food2, food3, food4);
var foodButton:FoodButton = new FoodButton();
var tam:Tamagotchi = new Tamagotchi();
public function Food() {
addChild(foodButton);
foodButton.x = 150;
foodButton.y = 650;
stage.addEventListener(Event.ENTER_FRAME, addingFood);
stage.addEventListener(Event.ENTER_FRAME, eatFood);
}
public function addButton(xpos:int, ypos:int)
{
addChild(foodButton);
foodButton.x = xpos;
foodButton.y = ypos;
}
public function addTheFood()
{
for (var i:int = 0; i < 4; i++)
{
addChild(foodArray[i]);
foodArray[i].x = 900 * Math.random();
foodArray[i].y = 650 * Math.random();
}
}
public function addingFood(e:Event)
{
if (tam.soph.hitTestObject(foodButton))
{
addTheFood();
removeChild(foodButton);
addButton(900 * Math.random(), 650 * Math.random());
}
}
public function eatFood(e:Event)
{
for (var j:int = 0; j < 4; j++)
{
if (tam.soph.hitTestObject(foodArray[j]))
{
removeChild(foodArray[j]);
foodArray[j].x=100000;
trace("Food gone!");
}
}
}
}//End of Class
}//包结束
很抱歉一直缠着你们,但我决心要解决这个问题,你们似乎真的很了解你们的东西,所以我只是想学习!
温柔一点!
在你的电子宠物中 Class 你有
var food:Food = new Food();
在你的食物中Class你有
var tam:Tamagotchi = new Tamagotchi();
这似乎无限循环......
(创建一个,创建另一个,再次创建第一个,再次创建另一个,依此类推...)
因此,我仍在开发我的 Tamagotchi 风格的游戏并使用单独的 classes,并且根据此处的建议,我将尽可能避免嵌套函数!
但是,我根据 hitTestObject
条件为 add/remove 食物编写了一些代码,它们在主要 class 中工作正常。
将所有内容移至 Food Class
后,我立即收到上述错误。
我试过使用痕迹并注释掉……我很难过。
这有点令人沮丧,因为作为一名学习者,我只是觉得我开始破解这个并且 WHAM 我撞墙了,这让我想起我实际上什么都不知道。
无论如何,我会很感激一些建议。 这是我的两个 classes 的代码。 再次感谢!
package {
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;
import DraggableItem;
import Food;
public class Tamagotchi extends MovieClip {
const BG_SPEED:int = 10;
const BG_MINX:int = -270;
const BG_MAXX:int = 0;
const BG_MINY:int = -200;
const BG_MAXY:int = 0;
var bG:BackGround = new BackGround();
var home:Home = new Home();
var soph:SophRun = new SophRun();
var item:DraggableItem=new DraggableItem();
var food:Food = new Food();
public function Tamagotchi() {
addChildAt(bG, 0);
bG.addChild(home);
home.x = 850;
home.y = 80;
addChild(soph);
trace("HI");
soph.x = 350;
soph.y = 250;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressListener);
stage.addEventListener(Event.ENTER_FRAME, bgScroll);
}
public function keyPressListener(e:KeyboardEvent):void
{
if (e.keyCode == 65)
{
soph.x -= 5;
soph.scaleX = 1;
}
if (e.keyCode == 68)
{
soph.x += 5;
soph.scaleX = -1;
}
if (e.keyCode == 87)
{
soph.y -= 5;
}
if (e.keyCode == 83)
{
soph.y += 5;
}
}//End of KeyPressListener
public function bgScroll(e:Event)
{
if (soph.x > 550 && bG.x > BG_MINX)
{
bG.x -= BG_SPEED;
soph.x -=2;
}
else if (soph.x < 150 && bG.x < BG_MAXX)
{
bG.x += BG_SPEED;
soph.x +=2;
}
else if (soph.y > 400 && bG.y > BG_MINY)
{
bG.y -= BG_SPEED;
soph.y -=2;
}
else if (soph.y < 400 && bG.y < BG_MAXY)
{
bG.y += BG_SPEED;
soph.y +=2;
}
}//End of bgScroll
} //End of Class
} //包结束
这是 Food Class
...
package {
import flash.display.MovieClip;
import flash.events.Event;
import Tamagotchi;
public class Food extends MovieClip{
var food1:Food1 = new Food1();
var food2:Food2 = new Food2();
var food3:Food1 = new Food1();
var food4:Food2 = new Food2();
var foodArray:Array = new Array(food1, food2, food3, food4);
var foodButton:FoodButton = new FoodButton();
var tam:Tamagotchi = new Tamagotchi();
public function Food() {
addChild(foodButton);
foodButton.x = 150;
foodButton.y = 650;
stage.addEventListener(Event.ENTER_FRAME, addingFood);
stage.addEventListener(Event.ENTER_FRAME, eatFood);
}
public function addButton(xpos:int, ypos:int)
{
addChild(foodButton);
foodButton.x = xpos;
foodButton.y = ypos;
}
public function addTheFood()
{
for (var i:int = 0; i < 4; i++)
{
addChild(foodArray[i]);
foodArray[i].x = 900 * Math.random();
foodArray[i].y = 650 * Math.random();
}
}
public function addingFood(e:Event)
{
if (tam.soph.hitTestObject(foodButton))
{
addTheFood();
removeChild(foodButton);
addButton(900 * Math.random(), 650 * Math.random());
}
}
public function eatFood(e:Event)
{
for (var j:int = 0; j < 4; j++)
{
if (tam.soph.hitTestObject(foodArray[j]))
{
removeChild(foodArray[j]);
foodArray[j].x=100000;
trace("Food gone!");
}
}
}
}//End of Class
}//包结束
很抱歉一直缠着你们,但我决心要解决这个问题,你们似乎真的很了解你们的东西,所以我只是想学习! 温柔一点!
在你的电子宠物中 Class 你有
var food:Food = new Food();
在你的食物中Class你有
var tam:Tamagotchi = new Tamagotchi();
这似乎无限循环...... (创建一个,创建另一个,再次创建第一个,再次创建另一个,依此类推...)