A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: function(???)

  1. #1
    Flashkit Veteran joejoe2288's Avatar
    Join Date
    Apr 2004
    Location
    Hickville, Oregon
    Posts
    2,554

    function(???)

    what is the use of putting something inside those bracets
    So tired of all the fighting....

    http://joejoe2288.kawanda.net

  2. #2
    The epitomy of hip
    Join Date
    Jun 2004
    Location
    United States of America
    Posts
    77
    makes it look puuuurrty()
    J
    A
    Z
    Z

    Can you dig it?

  3. #3
    Retired SCORM Guru PAlexC's Avatar
    Join Date
    Nov 2000
    Location
    NJ
    Posts
    1,387
    Brackets? { }

    Or Parenthesis? ( )

    The brackets deliniate blocks of code. Without them you'd have line after line of code running together. The brackets tell the compiler where your function or conditional ends.

    Parenthesis are used to pass parameters to functions. If a function doesn't take a parameter, you don't put anything inbetween them.

    For instance: gotoAndPlay() is a global function. It tells the playback head to jump to a certain frame and start playing from there. You've got to have a way to tell that function which frame you want it to go to. Enter the parameter: gotoAndPlay(10).

    stop() doesn't take any parameters. However, since it's a function, it needs to follow the syntax rules, hence the empty parens.
    "What really bugs me is that my mom had the audacity to call Flash Kit a bunch of 'inept jack-asses'." - sk8Krog
    ...and now I have tape all over my face.

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Posts
    2,467
    Brackets: [ ]

    Curly Braces: { }

    Parentheses: ( )


    -james
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life."

    Image Popup Scripting Engine | Thumb PopUp Script | HTML Anchors w/Flash | Popup Script Generator | Seq. Img Swap | Img Swap | Browser Shake | Rand. Img Swap | Inline Img Swap | Screen Res. PopUp | Screen Resolution Popup Script


  5. #5
    Flashkit Veteran joejoe2288's Avatar
    Join Date
    Apr 2004
    Location
    Hickville, Oregon
    Posts
    2,554
    cha i know how to actionscript i was just wondering if liek a function says function dogfunc(kill) {
    what does the kill part do
    So tired of all the fighting....

    http://joejoe2288.kawanda.net

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Posts
    2,467
    i was just wondering if liek a function says
    function dogfunc(kill) {
    what does the kill part do


    It's an argument of the function. A variable whose value will be determined when the function is invoked. This comes in handy when you need to reuse the function.


    Let's look at a simple javascript, used for opening a new window:


    <script>
    <!--

    function newWin(){

    var myWin = window.open('http://www.msn.com','myWin0','width=400,height=400');

    }

    //-->
    </script>

    And the anchor tag:

    <a href="javascript:newWin();void(0);">Open New Window</a>

    Now, that script is fine...if you only want to open one new window But everytime you invoke the function newWin(), you're going to get a 400x400 window, named myWin0, directed at http://www.msn.com.

    But suppose you wanted to open many windows, all different sizes, with different names, and all going to different urls...

    Then you'd do something like this:

    <script>
    <!--

    function newWin(url,winName,w,h,top,left){

    var myWin = window.open(url,winName,'width='+w+',height='+h+', top ='+((screen.height-h)/2)+',left='+((screen.width-w)/2));

    }

    //-->
    </script>

    Then the anchor tag would look like this:


    <a href="javascript:newWin('http://www.msn.com','myWin0','300','300','top','left');vo id(0);">Open New Window</a>


    So from this one script, you could launch any number of new windows:


    <a href="javascript:newWin('http://www.flashkit.com','myWin1','500','250','top','left');void(0);">Open New Window</a>

    <a href="javascript:newWin('http://www.lycos.com','myWin2','600','500','top','left');void(0);">Open New Window</a>


    etc.



    -james
    Last edited by jamescover; 07-17-2004 at 04:39 AM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life."

    Image Popup Scripting Engine | Thumb PopUp Script | HTML Anchors w/Flash | Popup Script Generator | Seq. Img Swap | Img Swap | Browser Shake | Rand. Img Swap | Inline Img Swap | Screen Res. PopUp | Screen Resolution Popup Script


  7. #7
    The epitomy of hip
    Join Date
    Jun 2004
    Location
    United States of America
    Posts
    77
    WaAaAaAayYyYyYyYYy over my head


    LOOK!! UP THERE ^

    THERE IT IS!!

    WHOOSH!!!!

    ----------------->
    J
    A
    Z
    Z

    Can you dig it?

  8. #8
    Flashkit Veteran joejoe2288's Avatar
    Join Date
    Apr 2004
    Location
    Hickville, Oregon
    Posts
    2,554
    hmm that makes a little sense but i am bnot that god with any type of scripting except a/s so could you elate it too that i really appreciate your help james
    So tired of all the fighting....

    http://joejoe2288.kawanda.net

  9. #9
    Senior Member
    Join Date
    Jul 2001
    Posts
    2,467
    so could you elate it too that i really appreciate your help

    Okay, a simple AS example:


    You could a create a function like this:

    function getFrame(x){
    _root.gotoAndPlay(x);
    }

    Then, on a button, instead of:

    on(release){
    _root.gotoAndPlay(15);
    }

    You would use:

    on(release){
    getFrame(15);
    }

    makes sense, right?


    -james
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life."

    Image Popup Scripting Engine | Thumb PopUp Script | HTML Anchors w/Flash | Popup Script Generator | Seq. Img Swap | Img Swap | Browser Shake | Rand. Img Swap | Inline Img Swap | Screen Res. PopUp | Screen Resolution Popup Script


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