7 Replies Latest reply on Aug 18, 2008 6:38 AM by Newsgroup_User

    variable in id value

    matchestheclown Level 1
      Hello,

      I posted a question about this about a week ago but haven't found an answer yet. So I decided to break down exactly what it is that I am trying to do in hopes that will help. Basically, I have multiple users streaming video in from their webcams. I have one video display that the users will take turns using. So I will need the id for that video display to be a variable. The code I have attached seems to be pretty much what I need except it doesn't work.

      Flex builder gives the error: pubVideo' + streamName.text is not a valid identifier

      What I'm trying to do seems pretty rudimentary to me so I am baffled to why the answer has been so hard to come by. Am I approaching the problem the wrong way?

      Thanks for any help.
        • 1. Re: variable in id value
          wyattbiker Level 1
          Have you tied using Actionscript code? This worked for me.

          <mx:VideoDisplay width="300" height="250" id="pubVideo" />

          then in some code event or function have it do the following.

          pubVideo.id=pubVideo.id+streamName.text;

          • 2. Re: variable in id value
            g-s-b Level 1
            In the MXML the id needs to be String constant, I believe. It is the parent's ref. to the class instance object and at compile time, the runtine variable is unknown. Since wyattbiker says that the AS way works, try his code in the creationComplete event handler:
            ... creationComplete="pubVideo.id=pubVideo.id+streamName.text;"
            if streamName.text is already set or defaulted.

            Maybe...


            • 3. Re: variable in id value
              Level 7

              "matchestheclown" <webforumsuser@macromedia.com> wrote in message
              news:g89rqs$klq$1@forums.macromedia.com...
              > Hello,
              >
              > I posted a question about this about a week ago but haven't found an
              > answer
              > yet. So I decided to break down exactly what it is that I am trying to do
              > in
              > hopes that will help. Basically, I have multiple users streaming video in
              > from
              > their webcams. I have one video display that the users will take turns
              > using.
              > So I will need the id for that video display to be a variable. The code I
              > have
              > attached seems to be pretty much what I need except it doesn't work.
              >
              > Flex builder gives the error: pubVideo' + streamName.text is not a valid
              > identifier
              >
              > What I'm trying to do seems pretty rudimentary to me so I am baffled to
              > why
              > the answer has been so hard to come by. Am I approaching the problem the
              > wrong
              > way?
              >
              > Thanks for any help.
              >
              > <mx:VideoDisplay width="300" height="250" id="{'pubVideo' +
              > streamName.text}"
              > />

              I'm pretty sure you were told that you need to use a repeater to do this.
              An ID, by its very nature, is not mutable in the way you are trying to use
              it. You can use a repeater to get it by index. Or you can use a dictionary
              or object to create instances that you can call out by name. But you can't
              set the ID like this. Can't.


              • 4. Re: variable in id value
                Level 7

                "wyattbiker" <webforumsuser@macromedia.com> wrote in message
                news:g8aa1m$5gr$1@forums.macromedia.com...
                > Have you tied using Actionscript code? This worked for me.
                >
                > <mx:VideoDisplay width="300" height="250" id="pubVideo" />
                >
                > then in some code event or function have it do the following.
                >
                > pubVideo.id=pubVideo.id+streamName.text;

                That doesn't then make it that you can reference

                pubVideoWhatever.property. It just changes the string assigned to the id
                property.


                • 5. Re: variable in id value
                  matchestheclown Level 1
                  Thanks for help all of you.

                  Amy:

                  Yeah, I was told to use the repeater. When I looked into it it didn't seem to be the solution I needed. I could see if I needed to repeat all of the streams and show multiple videos. But I only need to to see one stream at a time. I guess I can take a second look at the repeater to see if what I need.

                  One quick question though. Is this the kind of situation where I need to hack the way the repeater is intended to be used?

                  Thanks a lot
                  • 6. Re: variable in id value
                    g-s-b Level 1
                    Perhaps you should try a custom object Class instead of a simple renderer. You could have better control over the video display that way.

                    • 7. Re: variable in id value
                      Level 7

                      "matchestheclown" <webforumsuser@macromedia.com> wrote in message
                      news:g8arue$mvj$1@forums.macromedia.com...
                      > Thanks for help all of you.
                      >
                      > Amy:
                      >
                      > Yeah, I was told to use the repeater. When I looked into it it didn't seem
                      > to
                      > be the solution I needed. I could see if I needed to repeat all of the
                      > streams
                      > and show multiple videos. But I only need to to see one stream at a time.
                      > I
                      > guess I can take a second look at the repeater to see if what I need.

                      Seems like what you actually need is to change out the source of the
                      VideoDisplay, not the ID.