Professional Web Applications Themes

Syntax again - Help! - Macromedia Flash Sitedesign

I have a movie clip instance named 22mc. Can anyone tell me why this is not good syntax: on (release) { with (_root.22mc) { play(); } } If I change the name of the movie clip instance to "mc", works fine. on (release) { with (_root.mc) { play(); } } How do I hold the name of a movie clip as a string variable, and use it in a path? Thanks Geoff...

  1. #1

    Default Syntax again - Help!

    I have a movie clip instance named 22mc. Can anyone tell me why this is not
    good syntax:

    on (release) {
    with (_root.22mc) {
    play();
    }
    }

    If I change the name of the movie clip instance to "mc", works fine.

    on (release) {
    with (_root.mc) {
    play();
    }
    }


    How do I hold the name of a movie clip as a string variable, and use it in a
    path?

    Thanks
    Geoff


    Geoff Guest

  2. #2

    Default Re:Syntax again - Help!

    Hey,

    Ok, I think this should help:
    Your movie clip name can't start with a number, according the flash syntax it either has to start with an underscore, letter, or dollar sign. <-- I don't know why the hell they made it a dollar sign, but that's how it is.

    For holding the name of the clip, you can store it like this using the movieclip._name property
    For your instance that we name mc22.

    var movieClipName = mc22._name;

    the value of var is now movieClipName = "mc22";

    Hope this helps!

    Nick



    Skim Milk webforumsuser@macromedia.com Guest

  3. #3

    Default Re: Re:Syntax again - Help!

    Thanks heaps for that. I've played with it.. Do you mind clarifiying this
    for me. To store the currently playing movie clip instance name I'm doing
    this (thanks to your help):

    _global.myCurrentMovieClip = this._name;

    (the name is mc202)

    right?

    Now to target that on a stop button that is inside another movie:

    on (release) {
    with (_root.myCurrentMovieClip) {
    stop();
    trace(_root.myCurrentMovieClip);
    }
    }

    However, this returns undefined. I'm not sure why.

    Thanks again,
    Geoff




    "Skim Milk" <webforumsusermacromedia.com> wrote in message
    news:bpce5j$p4i$1forums.macromedia.com...
    > Hey,
    >
    > Ok, I think this should help:
    > Your movie clip name can't start with a number, according the flash syntax
    it either has to start with an underscore, letter, or dollar sign. <-- I
    don't know why the hell they made it a dollar sign, but that's how it is.
    >
    > For holding the name of the clip, you can store it like this using the
    movieclip._name property
    > For your instance that we name mc22.
    >
    > var movieClipName = mc22._name;
    >
    > the value of var is now movieClipName = "mc22";
    >
    > Hope this helps!
    >
    > Nick
    >
    >

    Geoff Guest

  4. #4

    Default Re: Re:Syntax again - Help!

    Geoff,
    The reason is because when you store the _name property of your movie clip. you're storing a string. Thus your variable, myCurrentMovieClip = "mc202" and your with function is actually given the parameter _root."mc202".

    As a work around you can simply assign the movie clip to the variable, something like this.

    myCurrentMovieClip = _this;

    with(_root.myCurrentMovieClip);

    That should give you the desired results.

    Best of Luck,
    Nick



    Skim Milk webforumsuser@macromedia.com Guest

  5. #5

    Default Re: Re:Syntax again - Help!

    Hey Skim!

    Thanks - that worked great, with one modification. I didn't need to use the
    _root. prefix, as the level0 was stored with the variable.

    Much appreciated.

    Geoff

    "Skim Milk" <webforumsusermacromedia.com> wrote in message
    news:bpd6kb$886$1forums.macromedia.com...
    > Geoff,
    > The reason is because when you store the _name property of your movie
    clip. you're storing a string. Thus your variable, myCurrentMovieClip =
    "mc202" and your with function is actually given the parameter
    _root."mc202".
    >
    > As a work around you can simply assign the movie clip to the variable,
    something like this.
    >
    > myCurrentMovieClip = _this;
    >
    > with(_root.myCurrentMovieClip);
    >
    > That should give you the desired results.
    >
    > Best of Luck,
    > Nick
    >
    >

    Geoff Guest

Similar Threads

  1. if/else tag syntax
    By negttid in forum Macromedia Flex General Discussion
    Replies: 8
    Last Post: March 20th, 02:15 AM
  2. Help with SYntax, Please!
    By Artspan in forum Macromedia ColdFusion
    Replies: 3
    Last Post: April 15th, 06:23 PM
  3. Need Help With Syntax!
    By Aaron Bertrand - MVP in forum ASP Database
    Replies: 10
    Last Post: August 7th, 03:44 PM
  4. Syntax
    By yma in forum ASP.NET General
    Replies: 1
    Last Post: July 3rd, 02:00 PM
  5. Help with DB2 Syntax.
    By sharads in forum IBM DB2
    Replies: 1
    Last Post: July 3rd, 09:04 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139