9 Replies Latest reply on May 16, 2006 5:03 AM by TimSymons

    Full control of id tagged <img>??

    daniel_vaughan
      Hi,
      First forum question...
      I've managed to embed a number of jpg's into a dynamic text field and create id tags for each of them using <img> tags loaded from an external text file.
      I've been able to adjust the alpha on the images using the full qualified path. However, I can't seem to control the clips in other ways.. as in using onPress, onRollOver etc...
      Is this level of control possible? If so, what am I missing?

      Thanks for any help,
      Daniel

        • 1. Re: Full control of id tagged &lt;img&gt;??
          TimSymons Level 1
          As long as none of the parents have any of these events defined, you should be able to do that. But if in your path, one of the parents has even just one of those events defined then the ones you defined on the images won't work.

          Tim
          • 2. Re: Full control of id tagged &lt;img&gt;??
            daniel_vaughan Level 1
            I'm quite sure the dynamic text box has no events defined except for a scroll.

            It's not something to do with levels is it? Not that I know what that really means. I'm just thinking conceptually.

            Daniel
            • 3. Re: Full control of id tagged &lt;img&gt;??
              TimSymons Level 1
              It's not just the textbox you have to worry about but also if that textbox is contained in another movieclip. If that container movieclip has any onPress, etc. events defined for it then none of the events you defined for you image will work.

              I tried this quickly and it worked for me. The src for the <img> is a library element with a linkage name of "sample".

              var myStr:String = "<img src='sample' id='mymc' />";
              sample_txt.html = true;
              sample_txt.htmlText = myStr;
              sample_txt.mymc.onPress = function():Void {
              trace("clicked");
              };
              stop();

              Also, how are you defining the scrolling for the textfield. Maybe that is capturing the events before they can reach your image.

              Tim
              • 4. Re: Full control of id tagged &lt;img&gt;??
                daniel_vaughan Level 1
                Hi Tim,
                For me, the code is becomming quite involved. I'll try and outline it as clearly as possible without leaving too much out.
                I have a simple XML driven menu system. The XML file i load contains a link (amongst others) to a simple tab-delimited TXT file that ive created using Excel. I then use a function called "generatetable" that splits the TXT file into columns (determined by the TABs in the TXT file). Those columns are then sent to a series of manually created dynamic, multiline, html eanabled text fields. These fields are not embedded within any other clip - they are simply on the main stage.

                The manually created text field that I am specifically using for the loaded <img> tags has an instance name of buy_txt. The first code I use on the buy_txt instance is to vary the height of the text field based on h=number of rows & fsize=fontsize, both determined my me previously.

                buy_txt._height = h*(fsize+4);

                The second code that I apply to the buy_txt instance places the html text within the text box. In this case it loads the jpg's from the <img> tags.

                buy_txt.htmlText += table[row][6]+"\r";

                I then determine whether or not to display two little scroll buttons based on whether my table length is longer that the variable h (see above - used to set the height of the text box in rows).

                if (table.length>h) {
                s_dn._visible = true;
                s_up._visible = true;
                } else {
                s_dn._visible = false;
                s_up._visible = false;
                }

                The remaining code controls the scrolling as follows:

                function continuousScrollUp2() {
                this.onEnterFrame = function() {
                if (ref_txt.scroll>0) {
                ref_txt.scroll--;
                model_txt.scroll--;
                link_txt.scroll--;
                stock_txt.scroll--;
                price_txt.scroll--;
                buy_txt.scroll--;
                }
                };
                }
                // Scroll continuously down at frame rate of movie
                function continuousScrollDown2() {
                this.onEnterFrame = function() {
                if (ref_txt.scroll<ref_txt.maxscroll) {
                ref_txt.scroll++;
                model_txt.scroll++;
                link_txt.scroll++;
                stock_txt.scroll++;
                price_txt.scroll++;
                buy_txt.scroll++;
                }
                };
                }
                // Stop continuous scroll
                function stopScroll() {
                delete this.onEnterFrame;
                }

                I hope this is all clear enough.


                I can list variables while testing and the following items come up (depending on how many rows are in the table):

                Movie Clip: Target="_level0.buy_txt.addcart1"
                Movie Clip: Target="_level0.buy_txt.addcart2"
                Movie Clip: Target="_level0.buy_txt.addcart3"
                Movie Clip: Target="_level0.buy_txt.addcart4"
                etc....

                I also get the following items listed once the "addcarts" above become active. I'm not sure what they are specifically:
                Movie Clip: Target="_level0.buy_txt.clipper-o-Depth0"
                Movie Clip: Target="_level0.buy_txt.clipper-o-Depth1"
                Movie Clip: Target="_level0.buy_txt.clipper-o-Depth2"
                Movie Clip: Target="_level0.buy_txt.clipper-o-Depth3"
                etc....

                Like I said, I can control the alpha etc. I just can't seem to control mouse overs.

                Daniel

                • 5. Re: Full control of id tagged &lt;img&gt;??
                  dan_vaughan
                  Hi Tim,

                  I really should print my code out more often. Having it on a big sheet really helps to analyse the code structure.
                  What I was doing wrong:

                  I was declaring the onPress function for the movie clip instance *before* the movieclip instance existed.

                  I've solved my problem with some temporary code. I'll now try and get it integrated to my real code. Thanks for bouncing ideas around.

                  Regards,
                  Daniel
                  • 6. Re: Full control of id tagged &lt;img&gt;??
                    dan_vaughan Level 1
                    Aaaarrrgghhh!
                    I spoke too soon. Tin, I can get your sample AS to work to a degree with my code.. ie using a library graphic with linkage "sample". But when I try and load my image externally ie. insert the html text : <img src='addcart.jpg' width='55' hspace='0' vspace='3' id='addcart1'><br> into the dynamic text field, i'm back to square one.

                    I can _alpha the buy_txt.addcart1 instance, however, using your varied sample code:

                    buy_txt.addcart1.onPress = function():Void {
                    trace("clicked");
                    };

                    It doesn't work.
                    I'm going to fall off my chair!
                    • 7. Re: Full control of id tagged &lt;img&gt;??
                      TimSymons Level 1
                      Dan,

                      Sorry I didn't reply sooner, busy weekend.

                      Not sure if I will be able to point you to a solution without seeing the code. Do you think you would be able to send me the FLA that you are having problems with? If so, I could take a look at it and maybe with a fresh pair of eyes help more with this issue.

                      Tim
                      • 8. Re: Full control of id tagged &lt;img&gt;??
                        dan_vaughan Level 1
                        Hi Tim,

                        Sorry also, for not responding too quickly. I've solved the problem. Well, I think i've solved the problem - it's hard to tell the exact answer sometimes, particularly when you're changing a million variables, settings and values to solve the problem.

                        I think the solution is to set the dynamic text field as multiline. I had it set to multiline-no wrap.

                        In any case, the code is working very well.

                        Thanks for the offer to look at the code.

                        Regards,
                        Dan
                        • 9. Re: Full control of id tagged &lt;img&gt;??
                          TimSymons Level 1
                          Dan,

                          Glad to hear that you got the code working.

                          Tim