dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: text box output

  1. #1
    Senior Member
    Join Date
    Jun 2006
    Posts
    136

    text box output

    I am very new at flash. I want to know how to output a varible in a text box.

    so...if my varible =h

    i want to show the h in a textbox every loop. I know u have to use a dynamic thingy but it just is not working. I read a tutorial and they put the word mount after the Var term.

  2. #2
    Junior Member
    Join Date
    Jul 2005
    Posts
    18
    give the text box a variable name in the properties inspector, in this sample call it "test"

    make a layer called actions

    in the first frame on that layer insert this code into actions
    test = "It works";

    that will get you started

  3. #3
    Senior Member
    Join Date
    Jun 2006
    Posts
    136
    yes thank you.
    So in order to program a text box to say stuff u have to program for that individual layer?

    For instance.... there is a ladybug thrust tortorial that came with flash. So.. i wanted the text box to show the current X and Y values of the ladbug as it moves. I would insert a new layer put the dynamic textbox in. Name it test. Then in the code i would write test=_x. (lets just do x only). Would this work? Is the _x vararible public and is there a way to just program for all the layers at once? So in this case i would have to have a separted thread for the new layer?

    im trying to convert all my programming knowledge to flash

  4. #4
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Yes, that is correct. But you would have to have a seperate layer for your action script. That way its nice and organized, plus easier to find. Heres an example that would go on one frame:
    code:
    _root.square.onEnterFrame = function(){
    square._x = _root._xmouse;
    square._y = _root._ymouse;
    table = ("X: " + square._x + " Y: " + square._y);
    }


    What this is doing is that the square(a moviecliop) is following the mouse around. And table is a dymanic textbox. The two words in "" are actual shown in text box. They don't change. But the x and y property of square are shown in the box as well. They change every time the square is moved.

  5. #5
    Senior Member
    Join Date
    Jun 2006
    Posts
    136
    How do i declare a public varible.

    ok now i have a rectangle moving _x+=1 to the right in one thread
    i also have circle moving by my controls via keyboard in another thread.


    now i want to do a collision, i know logically how it works, but which thread do i put it in and how do i acess the rectangle_x parameter from the circle thread?

  6. #6
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Variables are pretty easy to do.
    var rectangle:MovieClip = rectangle_mc

    That shows that the var rectangle is a movieclip and can be refured too in that variable name.

    As for collision. You'll want to use a thing called hitTest(). It basically checks to see if a obect has hit anything else. Here's an example I put on the maintime line.
    code:
     onEnterFrame = function(){
    if(_root.rectangle_mc.hitTest(_root.circle_mc)){
    trace("It hit the circle");
    }
    }


    So when the rectangle MC hits the circle it does a trace.

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