createDynamicPartInstance returns null
I'm learning how to create custom components and started by developing a test component that correctly creates dynamic parts. So far, so good. Then I tried to move that component into my real project, but when I run it there, createDynamicPartInstance always returns null (which obviously doesn't happen in the test component). I've gone over and over the code, but can't find any differences, aside from the test components having a slightly different name.
Can anyone suggest what the difference may be? I'm at a loss.
Renee
Here are the relevant parts of the real component that isn't working correctly:
package com.leadingstep.components
{
import com.leadingstep.skins.DisplaySentenceSkin;
import mx.collections.*;
import mx.core.IFactory;
import mx.events.Request;
import spark.components.HGroup;
import spark.components.supportClasses.SkinnableComponent;
public class DisplaySentence extends SkinnableComponent
{
[SkinPart(required="true",type="com.leadingstep.components.SentenceWord")]
public var line1Words:IFactory;
[SkinPart(required="true",type="com.leadingstep.components.SentenceWord")]
public var line2Words:IFactory;
[SkinPart(required="true")]
public var line1:HGroup;
[SkinPart(required="true")]
public var line2:HGroup;
public function DisplaySentence()
{
super();
setStyle("skinClass", DisplaySentenceSkin);
}
protected function createLine1Words():void {
for (var i:uint=0; i < 20; i++) {
trace("create line 1 word " + i);
if (createDynamicPartInstance("line1Words") == null) {
trace("create dynamic returned null");
} else {
trace("create dynamic did not return null");
}
}
}
}
And the skin:
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="com.leadingstep.components.*">
<!-- host component -->
<fx:Metadata>
[HostComponent("com.leadingstep.components.DisplaySentence")]
</fx:Metadata>
<!-- SkinParts
name=line1Words, type=mx.core.IFactory, required=true
name=line2Words, type=mx.core.IFactory, required=true
name=line2, type=spark.components.HGroup, required=true
name=line1, type=spark.components.HGroup, required=true
-->
<fx:Declarations>
<fx:Component id="line1Words" >
<components:SentenceWord skinClass="com.leadingstep.skins.SentenceWordSkin"/>
</fx:Component>
<fx:Component id="line2Words" >
<components:SentenceWord skinClass="com.leadingstep.skins.SentenceWordSkin"/>
</fx:Component>
</fx:Declarations>
<s:VGroup>
<s:HGroup id="line1"/>
<s:HGroup id="line2"/>
</s:VGroup>
</s:Skin>
