A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [RESOLVED] Evoking Box container classes in AS3?

  1. #1
    Member
    Join Date
    Mar 2004
    Posts
    89

    [RESOLVED] Evoking Box container classes in AS3?

    I'm trying to build am AS3 function that will take an xml document (formated like an mxml document) and render it at runtime rather than at compile. It looks like the Box, VBox, and HBox classes are there, but they seem to be restricted from being evoked in ActionScript.

    Does that sound right? Is there no way for me to get at these pre-made classes?

  2. #2
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    What are you using? Flex?

    I've done something similar. But to be able to generate instances at runtime, they have to be included in the SWF. If not, their defiitions will not be available and instances can't be created.

  3. #3
    Member
    Join Date
    Mar 2004
    Posts
    89
    Quote Originally Posted by senocular
    What are you using? Flex?
    I'm using the Flex IDE, but I'm working on it as an Actionscript project.


    Quote Originally Posted by senocular
    I've done something similar. But to be able to generate instances at runtime, they have to be included in the SWF. If not, their defiitions will not be available and instances can't be created.
    So...
    If I include a Flex project swf that uses the various classes I'd like to use, but are not included in actionscript, will I be able to use those classes then?

    How did you generate the instances at runtime?

    Code:
    var myBox:HBox = new HBox
    ?

  4. #4
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    I'm not entirely sure how the Flex components work in an ActionScript project in Flex 2 (if at all). Otherwise, you just include it and place the class somewhere, even if after the include.

    Code:
    import com.flashkit.Component; Component;

  5. #5
    Member
    Join Date
    Mar 2004
    Posts
    89
    The more I look at it, the less likely this appears. I'm not sure why an Actionscript project has access to some classes in the mx package and not others, or how you determine that before you try to implement it, but there definitely seems to be a restriction.

    For instance, I can import mx.core.* but not mx.containers.* Even though it looks like mx.containers classes extends flash.display classes, which my project does have access to.

    Go figure.

    I'm going to leave this as unresolved in case someone comes up with a solution, but at this point I don't think there is one short of creating my own custom classes that do the same thing as the classes I'm trying to import.

    Yuck.

  6. #6
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    I'm not entirely fluent in Flex, but I know the mx framework, especially the ui components, are heavily dependant on things like the Application class which is facilitated by the Application tag in MXML. If you want to use those components, you're best bet will probably to use MXML with two tags, the Application tag and the Script tag within it for your ActionScript.

  7. #7
    Member
    Join Date
    Mar 2004
    Posts
    89
    That did it. Instead of my top level being an actionscript file, I swapped it out for an MXML file and I could access everything. Thanks.

  8. #8
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    welcome

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