forked from: forked from: flash on 2009-12-30

by virtualex forked from forked from: flash on 2009-12-30 (diff: 164)
♥0 | Line 65 | Modified 2010-08-27 11:07:43 | MIT License
play

ActionScript3 source code

/**
 * Copyright virtualex ( http://wonderfl.net/user/virtualex )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qNRl
 */

// forked from buccchi's forked from: flash on 2009-12-30
// forked from buccchi's flash on 2009-12-30
package {
    import flash.display.Sprite;
    import mx.controls.Alert;
    import flash.text.TextField; 
    import flash.text.TextFormat;
     
    public class FlashTest extends Sprite {
             private const COLOR_PINK:Number = 0xFF3366;
             private const SCREEN_WIDTH:Number = 500;
             private const SCREEN_HEIGHT:Number = 500;
             
        public function FlashTest() {
            //mx.controls. 
            Alert.show("Hello, world!");
            //addMessage("hola");
            /*
            var form:Sprite = new MyForm(1, "aaaaaa");
            form.x = 10;//Math.floor(stage.stageWidth/2);
            form.y = 10;//Math.floor(stage.stageHeight/2 - form.height/2);
            addChild(form); 
*/


           
        }
        
        
  private function addMessage(message:String):void {
    var textField:TextField = new TextField(); 
    var textFormat:TextFormat = new TextFormat(null, 20, 0xFF0000, true);
    textField.defaultTextFormat = textFormat;
    textField.selectable = false;
    textField.width = SCREEN_WIDTH;
    textField.height = 256;
    textField.text = message;
    addChild(textField);
   
    textField.x = (SCREEN_WIDTH - textField.textWidth) / 2;
    textField.y = (SCREEN_HEIGHT - textField.textHeight) / 2;
  }
        
    }
}
        
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.Event;
import flash.events.MouseEvent;
    
class MyForm extends Sprite {
    private const COLOR_BLACK:Number = 0x000000;
        
    
    public function MyForm(num:Number, question:String) {
        
     /*   
        var numText:MyText = new MyText( MyTF.createTF("Question"+num, COLOR_PINK, 36, -1) );
        numText.x = -numText.w/2;
        addChild(numText);
         
     */   
    //    var questionText:MyText = new MyText( MyTF.createTF(question, COLOR_PINK, 18, 0, 400) );
    /*    questionText.x = -questionText.w/2;
        questionText.y = numText.h+20; */
    //    addChild(questionText);
            
         
        var dtf:TextField = MyTF.createDTF(COLOR_BLACK);
        addChild(dtf);
      
        dtf.x = 10;
        dtf.y = 10;
         
        /*
        var submit:Sprite = new Sprite();
        submit.graphics.beginFill(COLOR_PINK, 1);
        submit.graphics.drawRect(0, 0 , 80 , 19);
        submit.x = dtf.x+202;
        submit.y = dtf.y;
        var t:TextField = MyTF.createTF("入力", 0xFFFFFF, 14);
        var myText:MyText = new MyText(t);
        myText.x = submit.width/2 - myText.w/2;
        myText.y = submit.height/2 - myText.h/2;
        submit.addChild(myText);
        addChild(submit);
        
        submit.buttonMode = true;
        submit.mouseChildren = false;
        submit.addEventListener(MouseEvent.ROLL_OVER, overHandler);
        submit.addEventListener(MouseEvent.ROLL_OUT, outHandler);
    */ 
        
    }
        
    private function overHandler(e:MouseEvent):void {
        e.target.alpha = .6;
    }
    private function outHandler(e:MouseEvent):void {
        e.target.alpha = 1;
    }
    
}

import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldType;
  
class MyTF {
   /*
    public static function createTF(str:String, myColor:Number, size:Number=24, ls:Number=0, w:Number=0):TextField {
        
        var fmt:TextFormat = new TextFormat();
        fmt.font = "_明朝";
        fmt.color = myColor;
        fmt.size = size;
        fmt.bold = true;
        fmt.kerning = true;
        fmt.letterSpacing = ls;
        fmt.leading = 4;
        fmt.rightMargin = 1;
        var tf:TextField = new TextField();
        //tf.setTextFormat(fmt);
        tf.defaultTextFormat = fmt;
        //tf.text = str.toUpperCase();
        
        
        tf.text = str;
        tf.autoSize = "left";
        tf.selectable = false;
        
        if(w != 0){
            tf.width = w;
            tf.multiline = true;
            tf.wordWrap = true;
        }
        return tf;
    }
  */ 
    public static function createDTF(myColor:Number, size:Number=14):TextField {
        var fmt:TextFormat = new TextFormat();
        fmt.font = "_明朝";
        fmt.color = myColor;
        fmt.size = size;
        fmt.bold = true;
        var tf:TextField = new TextField();
        tf.defaultTextFormat = fmt;
        tf.type = TextFieldType.INPUT; 
        tf.width = 200;
        tf.height = 18;
        tf.border = true;
        tf.borderColor = myColor;
        return tf;
    } 
     
}
 

/*
    
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.display.Sprite;
import flash.display.Bitmap;

class MyText extends Sprite {
    private var _tf:TextField;
    private var _bound:Rectangle;
    
    public function get w():Number {
        return _bound.width;
    }
    public function get h():Number {
        return _bound.height;
    }
    
    public function MyText(tf:TextField) {
        _tf = tf;
        
        var bmd:BitmapData = new BitmapData(_tf.width, _tf.height, true, 0xFF000000);
        bmd.draw(_tf);
        _bound = bmd.getColorBoundsRect(0xFFFFFFFF, 0xFF000000, false);
        bmd.dispose();
        addChild(_tf);
        _tf.x = -_bound.x;
        _tf.y = -_bound.y;
    }
}*/