开发者

Is there a way to extend on classes that have been embedded? (AS3)

I have a assets file that embeds things,

[Embed(source='assets.swf', symbol='block')]
public static const SYM_BLOCK:Class;

I wish to expand on my block symbols class for later use, so I try to call it a heck of a lot of ways.

EX:

package isoscreen 
{
    import assets.Assets;

    public class开发者_开发知识库 isoBlock extends SYM_BLOCK
    {

...

    import assets.Assets.SYM_BLOCK;

    public class isoBlock extends SYM_BLOCK
    {

...

    import assets.Assets;

    public class isoBlock extends Assets.SYM_BLOCK
    {

...

is it possible? I haven't seen any examples of it anywhere.

ANSWER

The answer was simple, once shown to me. =)

But did require a bit of tinkering.

[Embed(source='/assets/assets.swf#block')] // you need to properly change the linkage to the file if your assets are in their own folder (also I found # as a shorthand to get to the symbol inside of the swf)
public class isoBlock extends Sprite
{
    public var top, left, right; //You need to define each symbol within the symbol as well, or it will fail to create. 

Thank you, folks.


A symbol is not exactly the same thing as a class, therefore you cannot extend it. You can however, link a symbol to your class, much like you would in Flash authoring.

package foo {

    [Embed(source='assets.swf', symbol='block')]

    public class BlockClass extends MovieClip {
        // if your symbol only has one frame, extend Sprite instead
    }

}


You can't do this for different reasons. The most important is:

You can't use variables in class declarations. E.g.: class A extends myVar is not allowed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜