5 Replies Latest reply on May 28, 2007 9:50 AM by kglad

    movie clips selecting current target

    zibber Level 1
      Hi

      I am currently stuckon what i think has to be a simple problem:) the jist of it is as follows.

      I have a movie clip on stage that is clickable.
      Once clicked I creata new movie clip and attach a movie clip from the library.
      At this stage i also create a text field and add it as a child to the new movie clip.

      now my problem is that i want the movie clip to be clickable so that a user can maniuplate it. However if the click clicks on the text field i get an error saying it cant be converted to a movie clip. As yes i am casting the selcted object as a movie clip:) I just wondered if anyone could point me in the right direction of apporaching this, as its drivign me slowly insane.

      regards
      a
        • 1. Re: movie clips selecting current target
          kglad Adobe Community Professional & MVP
          why are you trying to cast your textfield as a movieclip?
          • 2. Re: movie clips selecting current target
            zibber Level 1
            Hi Kglad

            thats a very good question:) and im sure where img oign worng but cant work out how to do this:| Belwo is my code that creates the new clip once a icon has been clicked on stage.

            function addBubble(event:MouseEvent):void {
            bubbleNum ++; // increment bubble num to use as name of bubbles

            // add in bubble clip
            var bubbleClip:MovieClip;
            bubbleClip = new bubble_container()
            bubbleClip.name = "bubble" + bubbleNum;
            port.addChild(bubbleClip);

            // add in text field
            var myText = new TextField(); // initiate my text as textfield - CHANGED FROM DOING AS MOVIECLIP AS TEST
            myText.type = TextFieldType.INPUT;

            bubbleClip.addChild(myText); // add mytext to bubbleclip
            myText.text = "wahoo"; // CHANGED FROM >>> attach text field form library
            myText.autoSize = "left";
            myText.multiline = true;
            trace(bubbleClip.width);
            bubbleClip.x = 20;
            bubbleClip.y = 200;
            myText.x = 10;
            myText.y = 10;
            myText.width = 218; //bubbleClip.width; // THIS NEEDS WORK!!!!!!!!!
            trace("width of text=" + myText.width);
            bubbleClip.addEventListener(MouseEvent.MOUSE_DOWN, setSelect)
            }

            steSelect does very little at the minute but it here its is for completion.

            function setSelect(event:MouseEvent):void{

            SelectedObject = MovieClip(event.target);
            }

            All i really wnat to acheive is the following.

            user clicks an icon on the stage
            this creates a new bubble movie clip which houses a graphical asset(clip pulled from library) and a text field.
            sets up a listerner to see if this has been clicked. (i set the current target as selctedObject as there may be multiple bubbleClips)

            Once its been clicked it needs to be able to draggable and also scalable flippable etc(ive got the code on this working), a double click woud result int he text field inside being editable (havent got to this buit yet:))

            I jsuit cant get my head around casting and the best way to approach this, it works fine if the user clicks on the bbble graphic etc.Can u shine any light on this please?
            • 3. Re: movie clips selecting current target
              kglad Adobe Community Professional & MVP
              use event.currentTarget instead of event.target
              • 4. Re: movie clips selecting current target
                zibber Level 1
                many thanks Kglad that works perfectly. one day i will get used to as3;)

                thanks again.
                • 5. Re: movie clips selecting current target
                  kglad Adobe Community Professional & MVP
                  you're welcome.