1 Reply Latest reply on Nov 16, 2007 6:18 AM by BSpero

    Pathing to MovieClips from within a class

    BSpero Level 1
      So I decided that I was not going to learn AS3 unless I did a project with it, so here I am, pretty frustrated. I am getting the hang of how the classes work, the events listeners, etc. But, what was once easy for me, is proving quite frustrating. My document class loads an XML document that includes 20 items. Each item has a photo, text file, and a few other things associated with it. I extract them and feed them to other classes to do what I need to do. For instance, I have a photo attribute in the XML that I feed to a PhotoImport class. It sizes it, places it on the stage,and adds event handlers for mouse clicks etc. I want to have another that deals with the text portion, but can't seem to direct the text to an already existing movie clip on the stage. I load a file "myText.txt" into a variable, and then want to set a text field on the stage (or an MC on the stage) to that text. But I can't seem to figure out how to navigate to it through code. Using the parent properties to work my way up isn't working, and I can reference the stage, but if I try to reference a movie clip on the stage, that doesn't work. I keep getting AS errors like:

      1119: Access of possibly undefined property mcMovieClip through a reference with static type Class.

      I dunno, I have found some postings about it, but can't seem to nail what I need to do. I am sure someone out there can help me out. Thanks...

      - B
        • 1. Pathing to MovieClips from within a class
          BSpero Level 1
          I figure I'll bump this by adding some more detail. When I click on a certain sprite, I want to to affect another sprite on the stage somehow. Maybe change text in a text box and move its position. So, on a mouseEvent, I have something like...

          var myText:String = "Some loaded text";
          var myClip:Sprite = parent.getChildByName("myOtherSprite");
          myClip.textField.text = myText;
          myClip.x +=100;

          This throws an error about implicit coercion with a static type flash.display...etc.
          I know I'll have an "A-HA" moment if I can get some basic understanding of how this works. I actually have Mook's Essential Actionscript 3 book here, and can't extract out of it what I am supposed to do. I would appreciate any nudges in the right direction.