A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [F8]Rookie parameter problems

  1. #1
    Member
    Join Date
    May 2007
    Posts
    39

    [F8]Rookie parameter problems

    I have declared a few Variables on the main timeline.These are Number type Variables .
    They are used to count and trigger events from a Switch statement ie:if the counter Variable is 30 (for example) do such and such.
    I have a number of movie clip "score keepers".These have nested movie clips that bold and recede in alpha as the score moves up or down. Graphically its something like a thermometer.
    Each clip will score 100 points in increments of 10.
    The "0" mark the "100" mark and the "200" mark in these three movie clips are text fields.
    My difficulty is:
    How do I assign textfields as parameters?
    When this is accomplished.
    How do I assign these "fields" a numeric parameter without the assignment throwing a type mismatch error.
    Thanks for looking it over!
    Mango

  2. #2
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    I honestly didn't understand a word out of all this... I'm quite sure that you don't understand the same thing by "assign textfields as parameters" as I do, so I won't comment on that just yet... Regarding the numeric parameter, well that's not clear either...

    Could you maybe explain the whole thing in a much clearer manner or maybe even put together a fast example that would demonstrate what you are trying to do... I'd like to help but I didn't understand a word about your problem...



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  3. #3
    Member
    Join Date
    May 2007
    Posts
    39

    parameter problem

    Sorry it is so unclear!
    The three movie clips I discussed all have a text field within them. What I want to do is write a function with parameters. It might look something like this but it would work.
    Var currentValue:Number
    function ThisandThat(myField:textfield,myNumber:number){
    myField.text=myNumber
    }
    ThisandThat(scoreText,currentValue)

  4. #4
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    That should work, I don't see any error in that way of thinking. I still don't understand what could you do with that... I think that you are only complicating yourself, since you know the text field that you'll be manipulating, I don't see why would you want to create a function that complicates the whole thing instead of simply saying: myField.text = myNumber...

    First of all, how will those numbers and text fields be passed ? Must the user click something ? I'm not seeing the logics behind this, I'm not saying it won't work, just that the way you are perceiving the problem is totally illogical to me...

    I'd use such function when I'm building my app considering abstraction, but when you know exactly the names of the fields and all the objects you'll be using then I'm not seeing any point in building such functions...



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  5. #5
    Member
    Join Date
    May 2007
    Posts
    39
    var currentValue:Number;
    currentValue = 15;
    function ThisandThat(myField:TextField, myNumber:Number) {
    myField.text = myNumber;
    }
    ThisandThat(myText, currentValue);
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 4: Type mismatch in assignment statement: found Number where String is required.
    myField.text = myNumber;

    Total ActionScript Errors: 1 Reported Errors: 1

    I have three movie clips that will perform the same tasks.I want to write a function that has parameters to identify 3 different text fields as well as 3 different numeric values.
    thanks
    Mango

  6. #6
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Hmm, so, if you are having a type mismatch then why don't you simply cast the value to the required type ?

    PHP Code:
    var currentValue:Number 15;

    ThisandThat(myTextcurrentValue);

    function 
    ThisandThat(myField:TextFieldmyNumber:Number):Void
    {
       
    myField.text String(myNumber);

    // end of ThisandThat 
    If that was the error then casting it should solve the problem.
    Last edited by fx.barrett; 06-01-2008 at 05:54 PM.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  7. #7
    Member
    Join Date
    May 2007
    Posts
    39
    The type of text field I am using is Dynamic.The value in the textfield is numeric.It is a value that is updated when the player scores.

  8. #8
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Just copy paste my code and see if it works ( it should ).



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


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