A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Problems with external library

  1. #1
    Junior Member
    Join Date
    Jul 2006
    Posts
    12

    Problems with external library

    Hello all!
    I am trying to use external libraries for a tile engine, so I have a bg.swf with a mc class name "tiles" in the library. I load this swf in another one and i can´t "attach" the mc tiles on it. I was told that it is possible to use external library in AS3, so this was my atempt, i really aprecciate any help.

    This is the code of the swf i am trying to load the mc tiles:
    PHP Code:
    package
    {
        
    import flash.display.*;
        
    import flash.events.*;
        
    import flash.net.URLRequest;
                
        public class 
    Test extends MovieClip
        
    {
            
            function 
    Test()
            {
                var 
    loader:Loader = new Loader();
                
    loader.load(new URLRequest("Library/bg.swf"));
    loader.contentLoaderInfo.addEventListener(Event.COMPLETEloadComplete);
            }

            function 
    loadComplete(event:Event){
                var 
    library event.target.content;
                
    stage.addChild(new library.tiles())
            }
        }

    The error is "TypeError: Error #1007: Instantiation attempted on a non-constructor."

    Obs:Sorry for the bad english.

    Thanks in advance.

  2. #2
    Actionscript 3, postproduction georgecalgary's Avatar
    Join Date
    Jun 2005
    Location
    Toronto
    Posts
    229
    At least it's wrong to call 'library.tiles()', the Flash compiler couldn't understand what you mean exactly. Usually your 'library' is a Sprite instance, how can you find a function .tiles() under that?

    Have you tried to create new instance with 'tiles()' directly?

    I didn't try this but I loaded external swf files like you. The classes automatically generated from library linkage in those external swfs will be seen in some way from the main stage (what I found there couldn't be used a same class name in main library and external swfs library). Unfortunately we don't have enough debug information for more details.
    Last edited by georgecalgary; 12-25-2006 at 02:30 AM.

  3. #3
    Actionscript 3, postproduction georgecalgary's Avatar
    Join Date
    Jun 2005
    Location
    Toronto
    Posts
    229
    I think you might could call a function inside your external swf to create a new instance of 'tiles' class and return the reference back to main stage, thus you can addChild it anywhere.

  4. #4
    Junior Member
    Join Date
    Jul 2006
    Posts
    12
    I think you might could call a function inside your external swf to create a new instance of 'tiles' class and return the reference back to main stage, thus you can addChild it anywhere.
    Oh thanks, this worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center