• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to refer to a Class linkage set in Library from external code?

Community Beginner ,
Jan 12, 2011 Jan 12, 2011

Copy link to clipboard

Copied

If one uses [Embed] to refer to external graphic assets its easy to instantiate and use them.

However, I've got a png in an Fla, with the Class identifier set to "Symbols", Base class is BitmapData.

I need to instantiate it like this:

var symbols:BitmapData = new Symbols(1, 1);

addChild(new Bitmap(symbols));

Of course the compiler complains about a call to a possibly undefined method Symbols.

For a temporary fix I guess i'll put the graphic external to the swf, but for this project it needs to be in the library along with everything else.

TOPICS
ActionScript

Views

811

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 12, 2011 Jan 12, 2011

Copy link to clipboard

Copied

If you have a symbol in your library with a Class identity of "Symbols" then you should only need to use...

var symbols:Symbols = new Symbols();

addChild(symbols);

As far as the 1,1 argumets go, are those not something you could assign when the instance is created?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2011 Jan 12, 2011

Copy link to clipboard

Copied

(if Symbols is extends the bitmapdata class, he'll need to create a bitmap to create a displayobject.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 12, 2011 Jan 12, 2011

Copy link to clipboard

Copied

Well, the 1,1 is a red herring, just to ensure the new BitmapData instance is created with some dimensions (it gets the correct dimension from the bitmap)

The problem here is the disconnect between the class identifier in the library of a swf created in Flash.exe, and compiling it using an external compiler. If I followed your suggestion - var symbols:Symbols = new Symbols(); - the compiler would still complain about an unkown identifier.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2011 Jan 12, 2011

Copy link to clipboard

Copied

flash would compile that without problem.

what compiler are you using?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 12, 2011 Jan 12, 2011

Copy link to clipboard

Copied

Can't use Flash to compile, we use Maven/Flex-mojos. Why do it the simple way when you can hugely overcomplicate it?! Compilation has to be done in a DOS window and just to do a few classes takes a couple of minutes as all manner of Java malarkey takes place also. Our enterprise imposes a load of restrictions on how you can create code assets.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2011 Jan 12, 2011

Copy link to clipboard

Copied

i can't help you with that compiler.  but i don't see why it would be a problem when flash wouldn't.

is Symbols in a swf that's loaded by a main swf?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

Yep, it is in a separate swf, but that wouldn't affect compilation. After a bit of checking around, I've created a Symbols class (as opposed to allowing Flash to create a default class when exporting the swf) that subclasses BitmapData and just contains a constructor. This allows a clean compile using the flexcompiler. Havent actually got it displaying yet but its a step in the right direction....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

check the applicationdomain class.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

LATEST

You can embed symbol from external swf using syntax:

[Embed(source = 'swfName.swf', symbol = 'Symbols')]

Given swfName is in the same directory as your top level class.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines