我從xml動態地向我的Flash影片添加了一系列對象,但在我運行影片時它們不會顯示。我有幾乎相同的代碼添加對象在不同的瑞士法郎工作得很好。我已經從星期天開始測試了這8種方式,包括確保將它們添加到主MovieClip的子容器(測試顯示列表),它們被添加到舞臺(有ADDED_TO_STAGE的監聽器),並且它們的位置是正確(顯示x,y值並將它們與mouseX & mouseY值進行比較)。他們在顯示列表中正確的位置。仍然沒有任何物體。該課程正確鏈接,我有庫中的電影剪輯。添加了兒童但物體不在閃存中顯示
任何想法可能導致問題? 我覺得我已經檢查了一切。
「公共類小地圖擴展影片剪輯 {
private var expLoader:LoadXML = new LoadXML("Experiences.xml",true);
public var expList:XMLList;
private var popCont:Sprite = new Sprite();
private var pop:PopUp;
private var expCont:Sprite = new Sprite();
private var pnt:Point;
private var exp:Experiences;
public function MiniMap()
{
// requires mouseup mousedown (pan) and close functions
//must load experiences which will have their own class
popCont.name = "popCont";
expCont.name = "expCont";
expCont.x = 0;
expCont.y = 0;
expCont.visible = true;
expCont.width = 4000;
expCont.height = 3000;
mm.addEventListener(MouseEvent.MOUSE_DOWN, panMap, false, 0, true);
expLoader.addEventListener("xmlLoaded", onLoadexp);
mm.addChild(popCont);
mm.addChildAt(expCont, 2);
}
private function onLoadexp(e:Event):void
{
expList = new XMLList(expLoader.xml.*);
trace(expList.Longitude[1]);
for (var i:int = 0; i < 3; i++)
{
exp = new Experiences(expList.Description[i],expList.Experience_Name[i]);
exp.x = i * 0.5 + 1156;
exp.y = i*0.75 + 1651;
exp.name = expList.Experience_ID[i];
/*exp.x = 1284.3216 * expList.Longitude[i] + 101472.0151;
exp.y = -1744.6503 * expList.Latitude[i] + 80213.7461;*/
exp.titl = expList.Experience_Name[i];
exp.desc = expList.Description[i];
exp.phourl = expList.photo[i];
exp.type = expList.County[i];
switch (exp.type)
{
case "City of Kawartha Lakes" :
exp.gotoAndPlay("Yellow");
break;
case "Peterborough County" :
exp.gotoAndPlay("Green");
break;
case "Northumberland County" :
exp.gotoAndPlay("Blue");
break;
case "Northumberland" :
exp.gotoAndPlay("Red");
break;
}
exp.addEventListener(MouseEvent.CLICK, onExpClick, false,0, true);
exp.addEventListener(Event.ADDED_TO_STAGE, onAdded, false,0, true);
expCont.addChild(exp);
}
trace(expCont.root);
}
private function onExpClick(m:MouseEvent):void
{
//check for other popups
if (popCont.numChildren > 0)
{
closePop();
}
pop = new PopUp(m.target.titl,m.target.desc);
pop.closer.addEventListener(MouseEvent.CLICK, closePop);
mm.popCont.addChild(pop);
}
private function onAdded(e:Event):void
{
trace(e.target.name + " was added to the stage at "+e.target.x + ", " + e.target.y);
}
private function closePop():void {
mm.popCont.removeChildAt(0);
}
private function panMap(m:MouseEvent):void
{
//click and drag to pan the minimap
mm.startDrag();
trace(mouseX+", "+mouseY);
mm.addEventListener(MouseEvent.MOUSE_UP, relsMap, false, 0, true);
}
private function relsMap(m:MouseEvent):void
{
//drops the minimap
mm.stopDrag();
}'
歡迎來到程序員!本網站提供更多主觀性問題,但StackOverflow的許多專家很樂意爲您提供幫助。我預計這個問題很快就會被移植到那裏。 – 2011-05-11 17:21:35
經驗延伸到什麼階層? – 2011-05-11 20:56:57