9 Replies Latest reply on Apr 12, 2007 10:56 AM by kglad

    sound object is not accessable from a movieclip?

    Level 7
      I have soundManager created in Scene 1 using new Sound()
      with the relevant sound imported and attached so that
      on start() it plays OK if start() is called from Scene 1.
      Yet when I call it from a movieclip it does not no matter if I used _root.
      refix or not.
      trace(soundManager) from Scene 1 returnes _level0.soundManager"
      trace(soundManager) or trace(_root.soundManager) from this movieclip
      returnes "undefined"
      Does this mean that a sound object is not accessible from a movieclip or I
      do call it incorrectly?


        • 1. Re: sound object is not accessable from a movieclip?
          kglad Adobe Community Professional & MVP
          a sound object wouldn't return its path/name. show the code you used to create soundManager.
          • 2. Re: sound object is not accessable from a movieclip?
            Level 7
            As I said, it returns "_level0.soundManager"

            The code.
            ===========================================
            soundManager_depth=2;
            createSoundManager();
            function createSoundManager(){
            var sound_depth = 2;
            createEmptyMovieClip("soundManager",soundManager_depth);

            soundManager.createEmptyMovieClip("sound1", sound_depth++);
            soundManager.sound1.mySound = new Sound(soundManager.sound1);
            soundManager.sound1.mySound.attachSound("sound1");
            soundManager.sound1.mySound.setVolume(100);

            .......... these four lines are repeated many times, every time attaching
            another sound so that soundManager holds many different sounds
            }
            ===============================================
            this code is stored in an .as file which is included using #include
            directive
            As I said it works if soundManager.sound1.mySound.start() is placed in the
            main timeline and trace(soundManager) returns "_level0.soundManager"
            If soundManager.sound1.mySound.start() or
            _root.soundManager.sound1.mySound.start() and trace(soundManager) or
            trace(_root.soundManager)
            are placed in a movie clip, the sound does not play and "undefined" is
            returned

            "kglad" <webforumsuser@macromedia.com> wrote in message
            news:ev8uec$jao$1@forums.macromedia.com...
            > a sound object wouldn't return its path/name. show the code you used to
            create soundManager.


            • 3. Re: sound object is not accessable from a movieclip?
              kglad Adobe Community Professional & MVP
              and as i said, a sound object wouldn't return its path/name. the sound object you're creating is soundManager.sound1.mySound. soundManager is a movieclip.

              to reference a movieclip (like soundManager) you only need the correct path/name AND you must wait until the movieclip is created before trying to reference it.

              because _root.soundManager fails and _level0.soundManager succedes you can infer the the main timeline where you are using _root.soundManager is not _level0 (ie, you're using different levels) OR your movieclip doesn't exist at the time you're executing your movieclip reference.
              • 4. Re: sound object is not accessable from a movieclip?
                Level 7
                Thanks.

                "kglad" <webforumsuser@macromedia.com> wrote in message
                news:evb388$423$1@forums.macromedia.com...
                1. > and as i said, a sound object wouldn't return its path/name. the
                sound object
                > you're creating is soundManager.sound1.mySound. soundManager is a
                movieclip.
                Movieclip is an object, isn't it. Perhaps here this terminology does not
                matter for in both cases I am tracing trace(_root.soundManager)
                And again for the purpose of this discussion (i.e. accessability) it does
                matter what exactly it returns al long as it does not return "undefined".
                But it does return "undefined".

                2. > to reference a movieclip (like soundManager) you only need the correct
                > path/name AND you must wait until the movieclip is created before trying
                to
                > reference it.
                in my case the correct path/name is _root.soundManager isn't ?

                3. > because _root.soundManager fails and _level0.soundManager succedes

                I did not say that. I said that
                if trace(_root.soundManager) is placed in the main timeline, it returns
                "_level0.soundManager"
                if trace(_root.soundManager) is placed in a movieclip, it returns
                "undefined"


                4. >you can infer the the main timeline where you are using
                _root.soundManager is not
                > _level0 (ie, you're using different levels)

                I do not use levels explicitly. In my FLA file I have only one Scene1 and in
                this scene I have only one frame. I thought that a code I place there is
                _level0.
                The fact that trace(_root.soundManager) returns "_level0.soundManager"
                proves this, doesn't it?


                5. >OR your movieclip doesn't exist at the time you're executing your
                movieclip reference.
                The call to the function which creates soundManager preceeds attaching the
                movieclip in question. So the reference to _root.soundManager from the
                movieclip happens after soundManager is created?



                • 5. Re: sound object is not accessable from a movieclip?
                  kglad Adobe Community Professional & MVP
                  1. it might not matter to you whether soundManager is a sound object or a movieclip object, but it mattered to me and anyone else that would try and help.

                  we knew what you think you are doing is not the same as what you actually are doing. from my experience helping others, when i find inaccurate descriptions of what someone is doing it's best to not believe them and to ask to see a copy and paste of their code.

                  even when people are accurate with their descriptions of their issues it's often not clear what the problem is until they copy and paste their code. they often omit important pieces of information.

                  therefore, from my experience simply answering your question (answer: "no, the sound object is accessible from anywhere given the correct path") would not likely help you resolve the issue. i felt seeing your code was the quickest way to help.

                  2. that's still unclear. and if it's true, then you must have a timing issue where you are executing trace(_root.soundManager) before _root.soundManager exists.

                  3. i could be wrong. soundManager movieclip may not be in _level0 if some of your trace() statements are run before the timeline that contains createSoundManager() is loaded into another _level and some are executed after loading into another _level.

                  that seems a little far-fetched, but correct me if i'm wrong. are you loading anything into another _level?

                  4. seeing _level0.soundManager only proves THAT trace(_root.soundMananger) function is in _level0 when it executes. it doesn't prove the trace(_root.soundManager), which displays undefined, is in _level0.

                  5. if soundManager is created before a trace() function executes (that has the correct path/name) then you would not see undefined.

                  so, on the timeline that contains createSoundManager() place:

                  trace("createSM "+this);

                  and on the timeline where you have the trace() function that displays undefined place:

                  trace("trace "+this);

                  what do you see?
                  • 6. Re: sound object is not accessable from a movieclip?
                    Level 7
                    hi, kglad, thank you for your time.
                    1. Just general observations.
                    My aim is not to become a comprehensive expert in FLASH.
                    FLASH is a tool to get to my aim whch has nothing to do with programming.
                    For that reason I learn FLASH on a "need to know" basis. So of all FLASH I
                    selected a subset I need for my purpose and try not to confuse myself with
                    features irrelevant to my purpose. I appreciate that if I do not know the
                    whole FLASH, I may consider certain things irrelevant while they are
                    relevant indeed and that initial FLASH subset is bound to widen. That is why
                    I am here.
                    Also I do not feel comfortable asking other people to spend their time on
                    parsing through my code fishing out my errors, that is why I prefer asking
                    more or less general questions rather then uploading my code.
                    When you explicitly suggested to show my code, I did. The problem is that
                    different bits of the code are sitting in different places, so if you wanted
                    to examine the code you need the whole FLA file with external includes which
                    I could send to you provided I knew your email. But asking for personal
                    emails on public forums is not appropriate, is it?

                    2. I now approached the moment when understanding FLASH levels might be
                    relevant to what I am doing. I read FLASH Help on layers and still
                    understand neither their purpose nor how they work, but feel that they are
                    central to FLASH functioning. Therefore though term "loading something into
                    another _level" intuitively sounds like using another namespace, and the
                    purpose of using different namespaces is obvious, I still do not understand
                    it in FLASH context which has _root and movie clips hyerarchy for namespaces
                    purposes.
                    In my code I've never used "_level" syntax explicitly. Is there a chance
                    that I am loading something into different levels inadvertently? Could you
                    point me at an Internet resource on FLASH layers?

                    3. I need time to digest and try the other things you said. I'll revert



                    "kglad" <webforumsuser@macromedia.com> wrote in message
                    news:evbhnt$jbh$1@forums.macromedia.com...
                    > 1. it might not matter to you whether soundManager is a sound object or a
                    > movieclip object, but it mattered to me and anyone else that would try and
                    > help.
                    >
                    > we knew what you think you are doing is not the same as what you actually
                    are
                    > doing. from my experience helping others, when i find inaccurate
                    descriptions
                    > of what someone is doing it's best to not believe them and to ask to see a
                    copy
                    > and paste of their code.
                    >
                    > even when people are accurate with their descriptions of their issues
                    it's
                    > often not clear what the problem is until they copy and paste their code.
                    they
                    > often omit important pieces of information.
                    >
                    > therefore, from my experience simply answering your question (answer:
                    "no,
                    > the sound object is accessible from anywhere given the correct path")
                    would not
                    > likely help you resolve the issue. i felt seeing your code was the
                    quickest
                    > way to help.
                    >
                    > 2. that's still unclear. and if it's true, then you must have a timing
                    > issue where you are executing trace(_root.soundManager) before
                    > _root.soundManager exists.
                    >
                    > 3. i could be wrong. soundManager movieclip may not be in _level0 if
                    some of
                    > your trace() statements are run before the timeline that contains
                    > createSoundManager() is loaded into another _level and some are executed
                    after
                    > loading into another _level.
                    >
                    > that seems a little far-fetched, but correct me if i'm wrong. are you
                    loading
                    > anything into another _level?
                    >
                    > 4. seeing _level0.soundManager only proves THAT
                    trace(_root.soundMananger)
                    > function is in _level0 when it executes. it doesn't prove the
                    > trace(_root.soundManager), which displays undefined, is in _level0.
                    >
                    > 5. if soundManager is created before a trace() function executes (that
                    has
                    > the correct path/name) then you would not see undefined.
                    >
                    > so, on the timeline that contains createSoundManager() place:
                    >
                    > trace("createSM "+this);
                    >
                    > and on the timeline where you have the trace() function that displays
                    > undefined place:
                    >
                    > trace("trace "+this);
                    >
                    > what do you see?
                    >
                    > try using trace(_level0.soundManager) from your movieclip. is that
                    defined?
                    >


                    • 7. Re: sound object is not accessable from a movieclip?
                      kglad Adobe Community Professional & MVP
                      1. correct, it's best to wait for an offer instead of asking to send a fla and/or asking for an email.

                      2. layers have nothing to do with _levels. you could only create a _level if you use loadMovie(), or loadMovieNum() or loadClip() and use a target number instead of a target movieclip.

                      the results of those 2 trace() functions i suggested should reveal the problem and its solution.
                      • 8. Re: sound object is not accessable from a movieclip?
                        Level 7
                        Thans, the two trace() functions were of help. The prblem sorted out

                        "kglad" <webforumsuser@macromedia.com> wrote in message
                        news:evbhnt$jbh$1@forums.macromedia.com...
                        > 1. it might not matter to you whether soundManager is a sound object or a
                        > movieclip object, but it mattered to me and anyone else that would try and
                        > help.
                        >
                        > we knew what you think you are doing is not the same as what you actually
                        are
                        > doing. from my experience helping others, when i find inaccurate
                        descriptions
                        > of what someone is doing it's best to not believe them and to ask to see a
                        copy
                        > and paste of their code.
                        >
                        > even when people are accurate with their descriptions of their issues
                        it's
                        > often not clear what the problem is until they copy and paste their code.
                        they
                        > often omit important pieces of information.
                        >
                        > therefore, from my experience simply answering your question (answer:
                        "no,
                        > the sound object is accessible from anywhere given the correct path")
                        would not
                        > likely help you resolve the issue. i felt seeing your code was the
                        quickest
                        > way to help.
                        >
                        > 2. that's still unclear. and if it's true, then you must have a timing
                        > issue where you are executing trace(_root.soundManager) before
                        > _root.soundManager exists.
                        >
                        > 3. i could be wrong. soundManager movieclip may not be in _level0 if
                        some of
                        > your trace() statements are run before the timeline that contains
                        > createSoundManager() is loaded into another _level and some are executed
                        after
                        > loading into another _level.
                        >
                        > that seems a little far-fetched, but correct me if i'm wrong. are you
                        loading
                        > anything into another _level?
                        >
                        > 4. seeing _level0.soundManager only proves THAT
                        trace(_root.soundMananger)
                        > function is in _level0 when it executes. it doesn't prove the
                        > trace(_root.soundManager), which displays undefined, is in _level0.
                        >
                        > 5. if soundManager is created before a trace() function executes (that
                        has
                        > the correct path/name) then you would not see undefined.
                        >
                        > so, on the timeline that contains createSoundManager() place:
                        >
                        > trace("createSM "+this);
                        >
                        > and on the timeline where you have the trace() function that displays
                        > undefined place:
                        >
                        > trace("trace "+this);
                        >
                        > what do you see?
                        >
                        > try using trace(_level0.soundManager) from your movieclip. is that
                        defined?
                        >