A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Expert Coder Take A Look: Duplicate scripts?

  1. #1
    Restarting from Scratch
    Join Date
    Feb 2001
    Location
    Sacramento, CA
    Posts
    236

    Wink

    Are these scripts the same? They are to pass a code to another MC.

    Code:
    tellTarget ("_root.Controller") {
        Gotojail = 0;
    }
    and

    Code:
    _root.Controller:Gotojail = 0;
    or maybe this one

    Code:
    tellTarget (_root.Controller:Gotojail = 0);
    I dont know if I need the quotations around the address. Any knowledge you have on this would be greatly appreciated.

    Thanks,
    JZ

  2. #2
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    yes they are the same except fo one slip up . use the second one with a dot instaed of a colon thus :
    Code:
    _root.Controller.Gotojail = 0;
    "tell target" is depreciated syntax and may not survive the next version of flash

  3. #3
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    swampy-

    does : do anything in AS?


  4. #4
    Restarting from Scratch
    Join Date
    Feb 2001
    Location
    Sacramento, CA
    Posts
    236
    So would this also be ok using the same type of syntax? It originates in another MC off the main timeline.

    Code:
    If (_root.Controller:Gotojail = 0){
             gotoAndPlay ("Jail");
          }

  5. #5
    Restarting from Scratch
    Join Date
    Feb 2001
    Location
    Sacramento, CA
    Posts
    236
    Hmmm Im passing the variable to MC instance Controller and the variable in it is called Gotojail. In order to reference the variable it should be:

    Code:
    _root.Controller:Gotojail = 0
    or

    Code:
    _root.Controller.Gotojail = 0
    My Flash 4 book (sorry I havent saved enough for a Flash 5 one yet) tells me that it used to be the : method to reference a variable in a MC. But it is . method now in Flash 5??

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    yes you must use the period instead of the colon.


    ....this is starting to sound like high school sex ed class

    dan

  7. #7
    Restarting from Scratch
    Join Date
    Feb 2001
    Location
    Sacramento, CA
    Posts
    236
    LOL

    Sorry Im still trying to adjust to Flash 5 scripting.

    So I take it that when you use the . method Flash 5 automatically looks for a variable named whatever comes after the . What if you have a variable and a child MC both named the same thing, inside that MC?? How does it know which one?

    Thanks,
    JZ
    [Edited by Liquid Genius on 06-15-2001 at 04:39 PM]

  8. #8
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775

    broken down it means

    _root go up to the main timeline

    .controller look in the controller mc

    . Gotojail look in the Gotojail variable

    = 0

    all the dots do is seperate the objects and variables.

  9. #9
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    They should have different names, right. It makes for more readable and understandable code anyway. In version 5 it could be a variable, movieclip, or text box. They are all targeted the same way.

    Dan


  10. #10
    Restarting from Scratch
    Join Date
    Feb 2001
    Location
    Sacramento, CA
    Posts
    236

    Eureka!

    Thats great guys! Thanks for the help. It is all starting to make sense now.

    John

  11. #11
    Restarting from Scratch
    Join Date
    Feb 2001
    Location
    Sacramento, CA
    Posts
    236
    Not to bother you anymore than I have, but......


    When do I use the single = and when the == ?

  12. #12
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    i think the single = is to assign value to something like:

    var number = 5;

    and the two == is to determine equality:

    if ( number == 5 ) {
    movieOne.gotoAndPlay ();
    }


    dan

  13. #13
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    single are for when you assign a value to a variable:

    ie
    Code:
    _root.Controller:Gotojail = 0

    and == for comaprison i.e
    Code:
    if( _root.Controller:Gotojail == 0) {
    
    do this
    
    }
    beat me to it !

  14. #14
    Restarting from Scratch
    Join Date
    Feb 2001
    Location
    Sacramento, CA
    Posts
    236
    Awesome! Well thats all the questions I have for now...youve helped me immensely!

    JZ

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