dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: AS problem

  1. #1
    When I am using AS like this:

    namerica_btn.onRollOver=showHint("North America");
    europe_btn.onRollOver=showHint("Europe");

    function showHint(Text)
    {
    _root.hint._visible=true;
    _root.hint.text=trace(Text);
    }

    When I run the movie, First what I get in my trace window are those two lines:
    North America
    Europe

    And when I move my mouse cursor over europe_btn or namerica_btn I get absolutely nothing!!! What am I doing wrong?

    Btw. Is this the right way of dealing with buttons? Because I will have the lot of them and all will have the same actionscript (the difference is only in hint text).

    I appresciate your help

    devoted FK user

  2. #2
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    Code:
    function showHint(txt){
      _root.hint._visible = 1;
      _root.hint.text = txt;  // this will assing value of txt variable to the text variable lied in hint mc.
      trace(txt);  // this will generate trace for you to see the value of txt while you developing the movie.
    }
    
    put this code on buttons: [example for nAmerica Button]
    
    on(rollOver){
      showHint(nAmerica);
    }
    remove you code what you wrote ... try this code in new movie ... hope this'll help u.

  3. #3
    Thanks for your reply.
    I know this way would all work, but I don't want to put that script on(RollOver) on ALL my buttons. I would like to keep all those in one place and that code I worte should work. I don't get where's the problem


  4. #4
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    you were close,
    try this:
    Code:
    namerica_btn.onRollOver = showHint("North America"); 
    europe_btn.onRollOver = showHint("Europe"); 
    
    function showHint(hint) // note I changed the param name to hint
    { 
        _root.hint._visible = true; 
        _root.hint.text = hint; // and use the parameter "hint" here
    }
    trace simply shows values in the output window. that is it's sole function.
    assigning a value to a textfield's .text property is done with simple dot syntax as above - textField.text = value;

    the parameter name doesn't matter at all,
    I just changed it to "hint", because "hint" reflected it's purpose better (in my opinion)
    the word "text" is a property of the TextField() object, an instance of which you are using within the function.
    Thus I didn't think it was appropriate to use "text" as a parameter name.
    semantics I know. take from it what you will.



  5. #5
    I used trace to see the results in trace window.
    As I said before, stil not working. When I go mouseover the buttons stil nothing happens!

    if use this code on the button it works perfectly
    on(rollOver)
    {
    hint._visible=true;
    hint.text="North America";
    }

  6. #6
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    oh sure,
    a slight alteration:
    [code]
    namerica_btn.onRollOver = function() {
    showHint("North America");
    }
    europe_btn.onRollOver = function() {
    showHint("Europe");
    }

    function showHint(hint) // note I changed the param name to hint
    {
    _root.hint._visible = true;
    _root.hint.text = hint; // and use the parameter "hint" here
    }

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