Текст в текстовото поле на различен слой и различна рамка

Аз съм нов в програмирането; особено обектно-ориентираното програмиране и работим върху това от известно време.

Имам .fla файл; рамка 1 е контейнерът. Ако щракнете върху него, се показват още три кадъра (слой 1). Кадър 2 от слой 1 е правилната анимация; рамка 3 е неправилна. На рамка 2 (слой 2, мисля) има динамично текстово поле. Това е мястото, където искам да отиде моят _correctText (_incorrectText трябва да отиде на рамка 3 (слой 2). ЗАБЕЛЕЖКА: Успях да добавя текста динамично, но имам нужда от действително текстово поле, което нашите графични художници да могат да „докоснат“, така че тази техника беше забранено.

Чувствам, че трябва да „избухна“, да добавя слушатели и да правя дисплеи, но не мога да разбера как да приложа това.

Нито един код не може да живее на времевата линия; идеята е това да се "компонентира"; следователно, инспектируемите.

Всяка помощ е много ценена и ако можете да „заглушите“ терминологията, това би било страхотно...

Ето моят код:

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.DisplayObject;
    import flash.display.FrameLabel;
    import flash.display.SimpleButton;
    import flash.text.*

public dynamic class hotSpotContainer extends MovieClip
    {   
        var _incorrectText:String = ""; 
        var _correctText:String = "";

        public function hotSpotContainer()
        {
            stop();
            addEventListener (Event.EXIT_FRAME, onExitFrame);
        }

        protected function onExitFrame($event:Event):void
        {
            removeEventListener(Event.EXIT_FRAME, onExitFrame);
            ButtonClicks();
        }

        public function ButtonClicks()
        /*If the mouse is clicked on one of the buttons listed below, go to the appropriate function.*/
        {
            (this as MovieClip).correct_Btn.addEventListener(MouseEvent.CLICK, correctAnimation);
            (this as MovieClip).incorrect_Btn.addEventListener(MouseEvent.CLICK, incorrectAnimation);
        }

        public function correctAnimation($event:MouseEvent)
        /*If the correct_Btn is clicked, go to the correctScreen frame and stop.  
        The correctScreen frame includes the correct animation (Correct_anim) which tweens to a correct screen.*/
        {
            gotoAndStop("correctScreen");
            (this as MovieClip).reset_Btn.addEventListener(MouseEvent.CLICK, resetImage);
        }

        public function incorrectAnimation($event:MouseEvent)
        /*If the incorrect_Btn is clicked, go to the incorrectScreen frame and stop.  
        The incorrectScreen frame includes the incorrect animiation (Incorrect_anim) which tweens to an incorrect screen.*/
        {
            gotoAndStop("incorrectScreen");
            (this as MovieClip).reset_Btn.addEventListener(MouseEvent.CLICK, resetImage);           
        }

        public function resetImage($event:MouseEvent)
        /*If the reset_Btn is clicked, go to the startPoint frame and stop.  
        The startPoint frame brings the user back to the beginning.  Reinvoking ButtonClicks allows the user to start over.*/
        {
            gotoAndStop("startPoint");
            ButtonClicks();
        }

        [Inspectable(name = "01) Incorrect Message Text: ", type = "String", defaultValue = "")]
        /*Creates a parameter field in which to type the incorrect answer message.*/

        public function set incorrectTextBox ($value:String):void
        /*Puts the incorrect answer message in the incorrect text box.*/
        {
            _incorrectText = $value;
        }

        [Inspectable(name = "02) Correct Message Text: ", type = "String", defaultValue = "")]
        /*Creates a parameter field in which to type the correct answer message.*/

        public function set correctTextBox ($value:String):void
        /*Puts the correct answer message in the correct text box.*/
        {
            _correctText = $value;
//          correctTxtBox.text = _correctText
        }
    }

}

person Amy    schedule 24.07.2014    source източник


Отговори (1)


Ето отговора:

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.DisplayObject;
    import flash.display.FrameLabel;
    import flash.display.SimpleButton;
    import flash.text.*
public class hotSpotContainer extends MovieClip
{   
    var _incorrectText:String = ""; 
    var _correctText:String = "";

    public function hotSpotContainer()
    {
        stop();

        addEventListener(Event.EXIT_FRAME, onExitFrame);
    }

    protected function onExitFrame($event:Event):void
    {
        removeEventListener(Event.EXIT_FRAME, onExitFrame);
        ButtonClicks();
    }

    /*If the mouse is clicked on one of the buttons listed below, go to the appropriate function.*/

    protected function ButtonClicks() 
    {
        (this as MovieClip).correct_Btn.addEventListener(MouseEvent.CLICK, correctAnimation);
        (this as MovieClip).incorrect_Btn.addEventListener(MouseEvent.CLICK, incorrectAnimation);
    }

    /* If the correct_Btn is clicked, go to the correctScreen frame and stop.
    The correctScreen frame includes the correct animation (Correct_anim) which tweens to a correct screen.*/

    public function correctAnimation($event:MouseEvent)
    {
        gotoAndStop("correctScreen");

        (this as MovieClip).correct_mc.setResponseText(_correctText);

        (this as MovieClip).response_txt.text = _correctText;

        (this as MovieClip).reset_Btn.addEventListener(MouseEvent.CLICK, resetImage);
    }

    /* If the incorrect_Btn is clicked, go to the incorrectScreen frame and stop.  
    The incorrectScreen frame includes the incorrect animiation (Incorrect_anim) which tweens to an incorrect screen.*/

    public function incorrectAnimation($event:MouseEvent)
    {
        gotoAndStop("incorrectScreen");

        (this as MovieClip).incorrect_mc.setResponseText(_incorrectText);

        (this as MovieClip).response_txt.text = _incorrectText;

        (this as MovieClip).reset_Btn.addEventListener(MouseEvent.CLICK, resetImage);
    }

    /*If the reset_Btn is clicked, go to the startPoint frame and stop.  
    The startPoint frame brings the user back to the beginning.  Reinvoking ButtonClicks allows the user to start over.*/

    public function resetImage($event:MouseEvent)
    {
        gotoAndStop("startPoint");
        ButtonClicks();
    }

    [Inspectable(name = "01) Incorrect Message Text: ", type = "String", defaultValue = "")]
    public function set incorrectTextBox ($value:String):void
    {
        _incorrectText = $value;
    }

    [Inspectable(name = "02) Correct Message Text: ", type = "String", defaultValue = "")]      
    public function set correctTextBox ($value:String):void
    {
        _correctText = $value;
    }
}

}

И другият клас:

package
{
    import flash.display.MovieClip;
    import flash.events.Event;


public class ResponseAnimation extends MovieClip
{
    protected var _responseText:String = "";

    public function ResponseAnimation()
    {

    }

    public function setResponseText($value:String):void
    {

        var response:String = $value;

        (this as MovieClip).beginning_mc.response_txt.multiline = true;
        (this as MovieClip).beginning_mc.response_txt.wordWrap = true;
        (this as MovieClip).beginning_mc.response_txt.text = response;

        this.visible = true;

    }

}
}
person Amy    schedule 15.09.2014