A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: how to create a text box using AS or API

  1. #1
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462

    how to create a text box using AS or API

    Hey im trying to make a text box using only action script for a api test game.

    Heres the code so far that im working on purely my code off by heart.

    s=10;

    _root.createEmptyMovieClip("char",1);
    char.lineStyle(0,0x0,0);
    char.beginFill(0x55575,100);
    char.moveTo(200,200);
    char.lineTo(200,250);
    char.lineTo(250,250);
    char.lineTo(250,200);
    char.lineTo(200,200);
    char.endFill();


    _root.createEmptyMovieClip("wall",2);
    wall.lineStyle(0,0x000,0);
    wall.beginFill(0x0,100);
    wall.moveTo(0,0);
    wall.lineTo(0,550);
    wall.lineTo(100,550);
    wall.lineTo(100,0);
    wall.lineTo(0,0);
    wall.endFill();

    _root.createEmptyMovieClip("wall2",3);
    wall2.lineStyle(0,0x0,0);
    wall2.beginFill(0x0,100);
    wall2.moveTo(0,0);
    wall2.lineTo(0,550);
    wall2.lineTo(100,550);
    wall2.lineTo(100,0);
    wall2.lineTo(0,0);
    wall2.endFill();
    _root.createEmptyMovieClip("wall3",4);
    wall3.lineStyle(0,0x0,0);
    wall3.beginFill(0x0,100);
    wall3.moveTo(0,350);
    wall3.lineTo(0,400);
    wall3.lineTo(550,400);
    wall3.lineTo(550,350);
    wall3.lineTo(0,350);
    wall3.endFill();

    _root.createEmptyMovieClip("top",5);
    top.lineStyle(0,0x0,100);
    top.beginFill(0x0,100);
    top.moveTo(0,0);
    top.lineTo(0,50);
    top.lineTo(550,50);
    top.lineTo(500,0);
    top.lineTo(0,0);
    top.endFill();

    _root.createEmptyMovieClip("enemy",6);
    enemy.lineStyle(0,0x0,0);
    enemy.beginFill(0x99999,100);
    enemy.moveTo(200,200);
    enemy.lineTo(200,250);
    enemy.lineTo(250,250);
    enemy.lineTo(250,200);
    enemy.lineTo(200,200);
    enemy.endFill();
    _root.enemy._y=80;
    _root.char._y=-80;

    onEnterFrame=function(){
    _root.wall2._x=450;

    if(Key.isDown(Key.RIGHT)){
    _root.char._x+=s;
    }
    if(Key.isDown(Key.LEFT)){
    _root.char._x-=s;
    }
    if(Key.isDown(Key.DOWN)){
    _root.char._y+=s;
    }
    if(Key.isDown(Key.UP)){
    _root.char._y-=s;
    }
    if(_root.char.hitTest(_root.wall)){
    _root.char._x+=s;
    }
    if(_root.char.hitTest(_root.wall2)){
    _root.char._x-=s;
    }
    if(_root.char.hitTest(_root.wall3)){
    _root.char._y-=s;
    }
    if(_root.char.hitTest(_root.top)){
    _root.char._y+=s;
    }
    if(_root.char._x<_root.enemy._x){
    _root.enemy._x-=5;
    }
    if(_root.char._x>_root.enemy._x){
    _root.enemy._x+=5;
    }
    if(_root.char._y<_root.enemy._y){
    _root.enemy._y-=5;
    }
    if(_root.char._y>_root.enemy._y){
    _root.enemy._y+=5;
    }
    }
    i know the code is a bit messy but ill fix that later im justing api and i want to beable to make a text box appear when you hit the enemy(that other square)
    please help =).

  2. #2
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    Code:
    var textBox = this.createTextField("textBox", 7, 0, 0, 0, 0)
    textBox.selectable = false
    textBox.border = true
    
    function showText(x, y, txt){
    	
    	textBox._x = x
    	textBox._y = y
    	textBox.autoSize = true
    	textBox.text = txt
    }
    
    if(char.hitTest(enemy)) showText(enemy._x, enemy._y, "you hit the enemy")
    don't say i never help you, there are many property's available for textFields, look it up in help, also look up TextFormat
    lather yourself up with soap - soap arcade

  3. #3
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462
    so now you try and help me =). Theres a first for everything i guess, lets see if this will work=P

  4. #4
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    http://board.flashkit.com/board/sear...earchid=472420

    from this search you've posted two problems, one which i have helped you with

    what are you complaining about
    lather yourself up with soap - soap arcade

  5. #5
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462
    nothing but i found another way

    score=50;
    this.createTextField("score_txt", 1001, 70, 10, 100, 100);
    score_txt.multiline = false;
    score_txt.embedFonts = false;
    score_txt.selectable = false;
    score_txt.variable = "score";
    score_txt.setTextFormat(format);

    thanks any way =)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center