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...  :)
LVL 37
CyanBlueAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.