dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Is there a way to bring a library object onto the stage without making a class?

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    22

    Is there a way to bring a library object onto the stage without making a class?

    For example, say I had a library object called 'camera'. If I wanted to bring the object onto the stage, is there another way to do that from a class besides making an actual class for the object? If it's just a graphic, and I want to add it to the display list, it's sort of troublesome to have a whole other .as file to deal with.

    Thanks!

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You can set a class in the properties for that library symbol and not create a corresponding .as file. Flash will warn you that a file was not found and will create the class for you. No actual .as file is generated, but you can use the class to create instances.

  3. #3

  4. #4
    Junior Member
    Join Date
    Sep 2009
    Posts
    22
    Oh okay, that makes a little more sense. The thing is though, I'm not doing the actionscript on the stage timeline. I'm doing everything from the document class. So when I create a movieclip called 'vCam', and have flash create a class for it, the line

    Code:
    var _cam:MovieClip = new vCam();
    only works on the stage timeline. When I try it from the document class, I get an error that I cannot access a property of a null object reference. Is there a way to do the same thing from the document class?

    EDIT: Okay. I think I figured it out. Actionscript creates the class on the first frame, so that's why I get a null object reference when I declare that before the first frame. If I declare the variable outside of the constructor, then assign it to the vCam class it works. Strangely though, I still get the error if I don't use 'addChild' on the variable. But nonetheless, it works.
    Last edited by ad1nf1n1tum; 10-18-2009 at 10:44 AM.

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