0
我還有一個影片剪輯中的動畫片段。我給孩子movieClip實例名稱「hSprite」,並將其添加到父級movieClip階段。現在我收到如下錯誤。訪問兒童影片剪輯的FlashDevelop
[Fault] exception, information=ReferenceError: Error #1056: Cannot create property hSprite on com.objects.Hero.
如果我從兒童影片剪輯刪除實例名稱,那麼錯誤消失。但是當我添加實例名稱時,錯誤再次出現。
請記住,這兩個類都設置爲導出。
父類是由完全正常工作的自定義類內嵌。但是,我給孩子movieClip一個實例名稱一分鐘,錯誤再次啓動。
這裏是嵌入父類的類。我最初想要做的就是訪問孩子的MovieClip是在英雄符號
package com.objects
{
import flash.display.MovieClip;
import flash.events.*;
/**
* ...
* @author Anthony Gordon
*/
[Embed(source='../../../bin/Assets.swf', symbol='Hero')]
public class Hero extends GameObject
{
private var aKeyPress:Array;
private var jumpDisabled:Boolean = false;
//private var heroSprite:MovieClip;
public function Hero()
{
wY = 150;
wX = 90;
speed = .5;
aKeyPress = new Array();
TheGame.sr.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
TheGame.sr.addEventListener(KeyboardEvent.KEY_UP,keyUpListener);
}
private function keyDownListener(e:KeyboardEvent):void {
//trace("down e.keyCode=" + e.keyCode);
aKeyPress[e.keyCode]=true;
}
private function keyUpListener(e:KeyboardEvent):void {
//trace("up e.keyCode=" + e.keyCode);
aKeyPress[e.keyCode]=false;
}
override public function UpdateObject():void
{
Controls();
updatePosition();
}
private function Controls():void
{
if (aKeyPress[38])//Key press up
;//dy -= speed;
else if (aKeyPress[40])//Key press down
dy += speed;
if (aKeyPress[37])//left
{
dx -= speed;
}
else if (aKeyPress[39])//Right
{
dx += speed;
}
if (aKeyPress[32]){//space
jump();
}
}//End Controls
private function jump():void
{
if (!jumpDisabled)
{
if (onGround)
{
dy = -15;
jumpDisabled = true;
}
}
else
{
jumpDisabled = false;
}
}
}
}
你是絕對正確的!我感謝你! – numerical25 2010-02-17 03:10:42