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

    Full control of id tagged <img>??

      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,

        • 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.

          • 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.

            • 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 {

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

              • 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) {
                // Scroll continuously down at frame rate of movie
                function continuousScrollDown2() {
                this.onEnterFrame = function() {
                if (ref_txt.scroll<ref_txt.maxscroll) {
                // 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"

                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"

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


                • 5. Re: Full control of id tagged &lt;img&gt;??
                  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.

                  • 6. Re: Full control of id tagged &lt;img&gt;??
                    dan_vaughan Level 1
                    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 {

                    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

                      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.

                      • 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.

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

                          Glad to hear that you got the code working.