Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: It's time to start using external code

  1. #1
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default It's time to start using external code

    OK I have gone to school and learned about :

    Inheritance, Encapsulation & Polymorphism

    but to put it into practice I NEED to know some BASICS in how to structur, name and link .as files to .fla files correctly.

    The tutorials I find talk about oop and I practice exples and my code does nothing.



    so I started from scratch with the most barebones example:

    1)create test.fla
    2)create test.as
    3) make sure test .as targets test.fla in the top right corner
    4) in test.as I plug in these lines:


    package
    {

    public class test
    {
    public function test():void
    {trace ("hello");
    }

    test();

    }

    }

    5) I save everthything and run test.fla or publish test.swf and nothing happens.
    Last edited by evan; 11-10-2008 at 09:32 PM. Reason: update

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    I'm not exactly sure what you're doing. Are you setting this as the Document class? Or are you attaching it to an object?

  3. The Following User Says Thank You to Medyman For This Useful Post:

    evan (11-10-2008)

  4. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    You have to call the .as files from the .fla.. in frame 1 actions layer put this:

    Code:
    #include "test.as"
    save, publish, upload.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. The Following User Says Thank You to BLiZZaRD For This Useful Post:

    evan (11-10-2008)

  6. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    You have to call the .as files from the .fla.. in frame 1 actions layer put this:

    Code:
    #include "test.as"
    save, publish, upload.
    Blizz, that would be true for AS2. I'm pretty sure Evan is using AS3 and CS3's OOP techniques.

  7. The Following User Says Thank You to Medyman For This Useful Post:

    evan (11-10-2008)

  8. #5
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    I think this would be a document class as in this would not be in a folder but reside in the same folder as the fla.

    How is it different? I know partly because I have worked with other scripts but not on my own from scratch. if it's in a folder I think ithe file/class and folder need to be named the same.

    In this case I name the .as the same as the .fla and ensure they are linked via the upper right hand corner selector.

  9. #6
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    I'm not sure what you're referring to in terms of the "upper right hand corner selector". You could have workspace configured than I have mine, but I don't see anything related to relating AS classes in the upper right hand corner of my screen.

    The Document class is set in the Properties panel.

    If you haven't already, watch the following tutorials by Lee Brimelow. I think they'll give you a better idea of using OOP techniques with AS.

    Introduction to OOP (AS2)
    Using the Document Class
    Object Oriented Scrollbar 1
    Object Oriented Scrollbar 2

    Edit: Are you using CS4 now?

  10. The Following User Says Thank You to Medyman For This Useful Post:

    evan (11-10-2008)

  11. #7
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default How do I create more than one script and appy it to an fla?

    I did catch something I missed from the document class tutorial in the properties I forgot to set up the script in the Document class window. It figures it would be something dumb like that.

    How do I create more than one script and appy it to an fla?
    Last edited by evan; 11-10-2008 at 09:31 PM. Reason: update

  12. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Medyman View Post
    Blizz, that would be true for AS2. I'm pretty sure Evan is using AS3 and CS3's OOP techniques.
    So attaching an external .as file is different in AS3? Or am I missing the actual question?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  13. #9
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    So attaching an external .as file is different in AS3? Or am I missing the actual question?
    Yup, it's different and it really depends on what you want to do. You can "include" external ActionScript using the include directive.

    AS3 gets rid of the the # in front though. So, to include regular AS3, you might do something like:

    Code:
    include "myactionscript.as"
    However, these included bits should really not be classes. If you're creating a Document class, you can attach it via the properties panel. Or, if you're attaching classes to objects, you can set it in the object's linkage properties.

  14. #10
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    hmmm... interesting. In 3 versions of Flash we went from not using .as at all to relying on them completely.. funny.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

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