2 Replies Latest reply on Oct 17, 2009 12:12 PM by shintashi

    my popup Text (but not box) disappears?

    shintashi Level 1

      I based the following on an old code I barely understood while creating it, and decided to begin messing with it again in my "learn japanese kanji" minigame. When my sprite contacts a movieclip, (like a door or sign), I want the text screen to appear, and disappear when they are no longer in contact.

       

      The code below almost does that. When the sprite contacts the movieclip (contact code at the bottom of this post), the textbox appears, the text appears, and everything works... for about a split second, and then the text - but not the box, disappears. I think disappearing text has something to do with being loaded through an on EnterFrame, but I don't understand why the box remains.

       

       

       

      function textscreen(){
          //fftextbox goes here; parentheses probably changed to actual quotes or arrays.
          var FF2text:MovieClip = createEmptyMovieClip ("FF2text", getNextHighestDepth());

       

      pointx = 100;   
      pointy = 100;   
          import flash.filters.GlowFilter;
      var glowInstance:GlowFilter = new GlowFilter(0xFFFFFF, 0.6, 5, 5);
          FF2text.filters = [glowInstance];
          import flash.geom.Matrix;
      var FF2Box:Matrix = new Matrix();
      FF2Box.createGradientBox(100, 250, Math.PI/2);
      FF2text.lineStyle (3,0xFFFFFF,95,true,none,none,square,0)
      FF2text.beginGradientFill("linear", [0x2425DB, 0x0D0E51], [100, 100], [125, 255], FF2Box);
      FF2text.moveTo (105, 100);
      FF2text.lineTo (395, 100);
      FF2text.curveTo(400, 100, 400, 105);
      FF2text.lineTo (400, 195);
      FF2text.curveTo(400, 200, 395, 200);
      FF2text.lineTo (105, 200);
      FF2text.curveTo(100, 200, 100, 195);
      FF2text.lineTo (100, 105);
      FF2text.curveTo(100, 100, 105, 100);
      FF2text.endFill ();
         
      this.createTextField("tLabel", this.getNextHighestDepth(), pointx, pointy, 280, 70);
      this.createTextField("aLabel", this.getNextHighestDepth(), pointx, pointy + 75, 220, 50);
      this.createTextField("bLabel", this.getNextHighestDepth(), pointx + 80, pointy + 75, 220, 50);
      tLabel.textColor = 0xFFFFFF;
      tLabel.embedFonts = true;
      aLabel.textColor = 0xFFFFFF;
      aLabel.embedFonts = true;
      bLabel.textColor = 0xFFFFFF;
      bLabel.embedFonts = true;

       

      tLabel.text = "Insert Important Question here?"
      aLabel.text = "Yes";
      bLabel.text = "No";
      tLabel.multiline = true;
      aLabel.multiline = false;
      aLabel.wordWrap = false;
      aLabel.selectable = true;
      tLabel.wordWrap = true;
      tLabel.selectable = false;
      bLabel.multiline = false;
      bLabel.wordWrap = false;
      bLabel.selectable = true;

       


      var style_fmt:TextFormat = new TextFormat();
      style_fmt.font = "Monotype Corsiva";
      style_fmt.size = 18;
      style_fmt.align = "center";
      tLabel.setTextFormat(style_fmt);
      aLabel.setTextFormat(style_fmt);
      bLabel.setTextFormat(style_fmt);
      var glow2:GlowFilter = new GlowFilter(0xFFFFFF, 0.3, 5, 5, 2, 2);
      import flash.filters.DropShadowFilter;
      var shdw:DropShadowFilter = new DropShadowFilter(2, 45, 0x000000, 0.45, 0, 0, 2, 2);
      var filterList:Array = tLabel.filters;
      filterList[0] = shdw;
      filterList[1] = glow2;
      tLabel.filters = filterList;
      var filterList2:Array = aLabel.filters;
      filterList2[0] = shdw;
      filterList2[1] = glow2;
      aLabel.filters = filterList2;
      var filterList3:Array = bLabel.filters;
      filterList3[0] = shdw;
      filterList3[1] = glow2;
      bLabel.filters = filterList3;
         
          }

       

       

       


      onEnterFrame = function(){

       

          if(man.hitTest(pallete.gybrickdr44)){
          textscreen();}

        • 1. Re: my popup Text (but not box) disappears?
          Ned Murphy Adobe Community Professional & MVP

          If I run your code directly, substituting a buttton interaction for the enterframe handler to ignite the textscreen function,  I never see the text appear, but the textfields do not disappear.  I confirmed this by adding borders to them.  I cannot see why the text doesn't appear at all though.

           

          Oddly, if I reduce the code to just the box and the textfield with text, no text formatting, where the text appears, and then gradually add in the different portions of code, everything works by the time I have things back to the original code except when I add the following lines which cause the text to not appear again...

           

          tLabel.embedFonts = true;
          aLabel.embedFonts = true;
          bLabel.embedFonts = true;

          1 person found this helpful
          • 2. Re: my popup Text (but not box) disappears?
            shintashi Level 1

            i noticed I had a single object on the screen: a static textfield with the font I was using (corsiva) and the word "text". I think this was my way of saving the text format, because with this text item (even if it was just floating off the visible stage) the text displays normally (when outside a function or enterframe) but without the text item, no text appeared. I think the embedding problem is part of the reason I abandoned it last winter. I will try it without the embed fonts next.

             

            Edit: Tried it without the embed font codes and that allows display of the text without creating a "place holder" formatted text. The disadvantage is the reduction in resolution, and with italics, the last letter of some sentences are cut off. Discovered if I change the "get next highest depth()" to "1000" or any high number, the problem of the text vanishing after "reload" disappears. Also edited the function so the question and two possible answers can be edited, although I could use some advice on how to deal with multiple paragraphs.