Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1338
  • Last Modified:

Shared Library question in AS3/CS3...

Hm...  I don't seem to be able to get this Shared Library in AS3/CS3...  :(

I have SharedLibrary.fla file where I have a movieClip linked as Square for the class, flash.display.MovieClip, and Export for ActionScript and Export in first frame are checked...

I have SharedLibraryMain.fla file where I have the following script...

var loader:Loader = new Loader();
var request:URLRequest = new URLRequest("SharedLibrary.swf");
loader.contentLoaderInfo.addEventListener('complete', completeHandler);
loader.load(request);

function completeHandler(e):void
{
      var square:Class = getDefinitionByName("Square") as Class;
      addChild(square);
}

But that gives me this '1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.' error message...  I can use that method to use the image or font just fine, but I am not able to use a movieClip...  What am I missing here???

Thanks...  :)
0
CyanBlue
Asked:
CyanBlue
  • 4
  • 3
1 Solution
 
blue-genieCommented:
hey CB.
are you just trying to get the square on the stage?

try this.
var loader:Loader = new Loader();
var request:URLRequest = new URLRequest("SharedLibrary.swf");
 
loader.contentLoaderInfo.addEventListener('complete', completeHandler);
 
loader.load(request);
function completeHandler(e:Event):void
{
addChild(e.target.content);
}

Open in new window

0
 
CyanBlueAuthor Commented:
What's up...  :)

Well...  There's gotta be multiple movieClips, Square and Circle for example, in the library of the SharedLibrary.swf file, and I'd like to specify them as needed...  Maybe this sample file will make it simple for you to understand the problem...  (Don't forget to remove the TXT extensions...)

Thanks...  ;)

CyanBlue
SharedLibrary.fla.txt
SharedLibraryMain.fla.txt
0
 
CyanBlueAuthor Commented:
I have solved the problem and posted the solution here if anybody is interested...  ;)
http://www.actionscript.org/forums/showthread.php3?t=188687
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
blue-genieCommented:
good to know, thanks
0
 
CyanBlueAuthor Commented:
Love to hear more if you'd like to chime in...  ;)

CyanBlue
0
 
blue-genieCommented:
i'm clueless about shared libraries. never tried it never had a need to, should learn to.
i actually pointed some other people to your post thinking that might resolve the problem. but i'm joining the I hate AS3 club.
0
 
CyanBlueAuthor Commented:
That's cool...  Thanks for that...  ;)

Hm...  How about I-Hate-ActionScript club???  :p
Yeah...  I've been learninging alot on AS3 for some months now and I also have mixed feelings...

CyanBlue
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now