It depends.  Just like in Flex 3, there are some “rules” to being a child 
component in the Flex framework and Wprites are generally too low-level to be 
used everywhere.  There is documentation and examples on writing a custom 
component and various methods you have to implement to get the component to 
display correctly.  The rules are a bit different for Flex 4, but mostly the 
same.

You can probably use Group or SpriteVisualElement instead of Sprite but again, 
they may not size correctly unless you follow the rules.


On 4/29/10 9:40 AM, "helmutgranda" <[email protected]> wrote:






I am trying to create a simple sprite that I can draw to during instantiation 
but I keep getting error after error and here is one of the most common one:

<error>
Multiple markers at this line:
-SkinnableContainer
-Could not resolve <s:Sprite> to a component implementation.
</error>

All I want to do is create a sprite with one color which then will listen to 
different events during the life of the application and then display a color 
that reflects the event dispatched.

Here is some code:

<fx:Script>
<![CDATA[
private const spr1:Sprite = new Sprite();
private const spr2:Sprite = new Sprite();

private function init():void {

spr1.graphics.beginFill(0xFF0000, 0.5);
spr1.graphics.drawRect(10, 10, 100, 80);
spr1.graphics.endFill();
dom.addChild(spr1);

spr2.graphics.beginFill(0x0000FF, 0.3);
spr2.graphics.drawRect(20, 20, 80, 100);
spr2.graphics.endFill();
dom.addChild(spr2);
}
]]>
</fx:Script>
<s:Sprite x="33" y="38" width="200" height="200" id="dom">
</s:Sprite>

Now if I change the Sprite to a Button it works as expected and it does because 
the Button subclasses spark.components so if that is the only way to get around 
it what would be the spark.component that would give me the freedom I want?

TIA






--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to