I have a MovieClip called chipmovie which I have exported to a class method called ChipMovie, when I try and add it to another movieclip, for some reason it doesn't display.
I have checked Export for ActionScript and Export in Frame 1.
The code that adds it to the MovieClip is as follows:
开发者_高级运维public function addChip(chip:Number)
{
var newChip:ChipMovie = new ChipMovie();
newChip.width = 47.50;
newChip.height = 47.50;
newChip.init(chip, topYPosition - INITIAL_OFFSET);
topYPosition += newChip.height;
chipList.push(newChip);
chipSelection.addChild(newChip);
}
The code in the ChipMovie class is:
public function ChipMovie():void
{
}
public function init(chip:Number, y:int) :void
{
this.y = y;
trace('init y =' + y + ' height is ' + this.height);
}
In the output it says:
init y = -151 height is 0
for all the ChipMovie objects I try to add.
so i assume, you have a MovieClip symbol in your library, which you assigned the class ChipMovie to. Is there actually something in that symbol, like any graphics, anything?
While assigning the class, did Flash IDE complain, perhaps? Or did it say something like: "class definition found at ...". That would be OK.
Is the movieclip, where your addChip methode resides in, added to the stage? is chipselection added to the movieclip?
What happens if you draw something in the graphics object of chipselection?! Do you see it? If not, you might want to double check, that chipselection or any parent objects are actually visible.
You can't resize a DisplayObject which has no content. If you do need to resize it, for whatever reason, you might consider putting a square with 0 alpha in it.
精彩评论