Results 1 to 4 of 4

Thread: calling external scripts with functions

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

    Default calling external scripts with functions

    Using AS 3.0..

    If I have a project, lets say that I want to manage more easilly without so much scrolling, (and more efficiency)can I call on certian scripts to execute with a function and event listener, it makes sense at a first glance.

    Then the question would be how.

    Any tutorials or examples that demonstrate this?

  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 sure what you mean. Can you provide some pseudo-code of what you would logically like to see happen?

    Specifically, what do you mean by "scripts" being called by functions?

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

    Default

    User scenario:

    clicks tool bar --icon changes(I have not shown that here) --script from external actionscript file added and will only become active with mouse_up -I imagine with a boolean value, or any kind of condition it doesn't matter


    I am thinking about keeping my project in pieces that I only need when I call them. It may make work easier later


    1--

    so here is what I more or less have in mind:

    var a:Number =1;

    if (a == 1);{
    trace("option a");}
    -saved it is "hello.as"in the same directory as "project.fla" and in the target window I selected "project.fla"

    could I then include some code like this (not exactly -because it's incorrect)
    hello
    //include hello.as file link here
    var confirm:Boolean = false;


    activate_btn.addEventListener(MouseEvent.MOUSE_UP,include_script);
    //call script
    function include_script(evt:MouseEvent):void{

    var confirm = true;

    }

    --that would use activate_btn to activate the code from hello.as

    is this done?

    2--

    not to mention am I attatching scripts the right way? Namely creating an .as script and "targeting" the .fla -Is there any code that needs to call that script as with classes?

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

    Default

    Ahh, I see.

    So you want to dive into Object Oriented Programming. Let me point you towards some video tutorials on the subject. If you have any more questions after watching these, feel free to ask.

    In "Introduction to Object Oriented Programming", Lee Brimelow of gotoAndLearn() goes over the basics of OOP in ActionScript 2.0. In it, he scripts a basic menu and explains how OOP can be a time/effort saver as well as allows for cleaner code.

    Flash CS3 is really intened to be used for OOP projects. At least, it allows for easier integrated OOP techniques -- hence the Document Class. In "Objected-Oriented Scrollbar" (part 1 and part 2), Lee goes over the implentation of OOP techniques in AS 3.0 to create a reusable scroolbar.

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

    evan (05-23-2008)

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
  •