A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: variables / input text question

  1. #1
    Junior Member
    Join Date
    Jul 2001
    Posts
    27
    Right then boys &girls,

    i have a button with one dynamic text (varaible) assigned to it already. Is is possible to get another two to it?

    what i mean is that if you click once on the button you will get the letter a. If you clivk on the same button twice you get the letter b. if you then click on that button again for the last time you get the letter c.

    how is it possible to assign three different letter on three different clicks?

    many thanks for all the time you have read this and any comments and answers to this question

    fred

  2. #2
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    I think the easiest way would be to store the letters in an array like:

    var letters = new Array("a","b","c", ....);

    then have a counter which you increment each time you click the button like this:

    on(release)
    {
    myTextField = letters[i];
    if(i<letters.length-1)
    {
    i++;
    }
    }

    Then if you clicked the button three times (assuming that you had initialised i to zero somewhere), myTextField would go from a to b to c.

    Ta da.

  3. #3
    Junior Member
    Join Date
    Jul 2001
    Posts
    27

    reply

    Originally posted by julianj
    I think the easiest way would be to store the letters in an array like:

    var letters = new Array("a","b","c", ....);

    then have a counter which you increment each time you click the button like this:

    on(release)
    {
    myTextField = letters[i];
    if(i<letters.length-1)
    {
    i++;
    }
    }

    Then if you clicked the button three times (assuming that you had initialised i to zero somewhere), myTextField would go from a to b to c.

    Ta da.

    okay then. how do you store the letters in the array?
    what i'm doing is trying to do the same thing as when you text message so if you click once you get letter a then you click on another button to get the letter n and so on to spell "andy" all in the same text field input.

    many thanks for the reply i'm still a virgin with all this action script stuff so be soft on me as i'm not on the same level as you lot!!!

    fred

  4. #4
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    Oh I see. Sounds quite cool. I would have a MC for each phone button. Each MC can then contain its own array initialised with the appropriate letters.

    So the button2 MC would have something like:

    onClipEvent(load)
    {
    var letters = new Array("a","b","c");
    }

    and button3 MC would have something like:

    onClipEvent(load)
    {
    var letters = new Array("d","e","f");
    }

    Your only problem is going to be deciding when to append the new letter to the textfield (i.e. we have got the letter we want) and when to replace the last letter with the next one in the array (i.e. we are still scrolling through the options). I guess to do that you would have to create some sort of timer function to measure the time between button presses to mimic the function of a real phone.

    Quite interesting I think.



  5. #5
    Junior Member
    Join Date
    Feb 2001
    Posts
    16

    Re: reply

    I think you can do it easier..
    first click on button gives you letter "a" & at same time goes to next frame where another action (display letter "b") attached to button and so on...
    - hope it helps -

  6. #6
    Junior Member
    Join Date
    Jul 2001
    Posts
    27

    i thought that you would be intrested.

    Mr julian,

    my dear friend, this is an intresting and complex problem i have. i might as well slam that door infront of my face as LUXFX has also been a great help with this little script:



    \\ frame script \\
    bttnArray = new Array();
    bttnArray[0] = "a";
    bttnArray[1] = "b";
    bttnArray[2] = "c";

    baIndex = 0;

    \\ the button \\
    on(release)
    {
    output += bttnArray[baIndex];
    baIndex = (baIndex >= bttnArray.length)?(0)baIndex + 1);
    }
    now the problem is that i think it doesnt work, because i is a plonker in actionscripting.

    will try what you mentioned keep you posted

    thanks again for this sherlock!!!

    fred

  7. #7
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    Presumably what this does is just keep adding "abcabcabc..." to the text field?

    I may have a tinker with this over the weekend. I'm pretty sure it won't prove too difficult.

  8. #8
    Junior Member
    Join Date
    Jul 2001
    Posts
    27

    i will too

    I will have a go on it aswell, but not sure whether i can do much as im asking you what to do.
    tricky little thing. in exchange i will give you the fla file that i will be working on. if we share its half yours.

    fred

  9. #9
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    Dude,

    I have made a start. It should demonstrate the technique enough to finish it off. Just need to add the other buttons.

    You can download the fla from http://www.casalia.co.uk/mobile.fla

    It's set to work with a 2 second pause between button presses but you can change that.

    There's no need for anything in return but I'd be interested to see the end result.

    Good luck.

  10. #10
    Junior Member
    Join Date
    Jul 2001
    Posts
    27

    what the hell!

    Easy tiger!!!!!!,

    IOU a drink, since you r in london. nice one. I was reading the friends of the earth foundation actionscripting. quite intresting. so how long have you been doing this. I wouldnt mind getting to your level.

    weeeeeyyyyyyy hayyyyyyyyyyyyyyy

    i really didnt think that this was possible. what can i say!
    u r the dude. god dam it. this is not right....

    nice one will post you the final one when i get to grips with the script.
    i assume that you duplicate the button and then chaneg the frame script withibn to the letters.

    I think that we have both pushed the boundries of using flash. will have to challange you to a harder mission i think.

    fred

    ps can we keep in contact?

  11. #11
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    I haven't been doing this that long (but a background in C++ and a good book helps).

    Anything's possible (nearly). Getting it to actually send the text message would be a good one. Have a look at the code; it's nothing complicated (or particularly elegant).

    Feel free to post any other questions.

  12. #12
    Junior Member
    Join Date
    Jul 2001
    Posts
    27

    right lets go for it.

    How would you be able to post a text message from this? would you also be able to make a phone call from it as well.

    so the green phone icon on your mobile would be the sender and receiver. how would we be able to implement this.

    Case study.

    person types in what they want to say......"hello bob".

    they would then type the number that it was going to.

    press the green mobile icon on the phone and presto it sends.

    what is intresting about this is that if you can connect to the internet and be able to send it from there. for example http://www.genie.co.uk has a similar type of thing going on.

    would you also be able to make calls from this?

    what is possible and what isnt? hmmm

    any comments?

  13. #13
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    I've no idea if it's possible or how to do it. But, like you, I know it can be done through the internet, so why not from Flash? The only thing that makes me suspicious is that texting is not usually a free service. I suspect that someone like genie can do it through their association with BT Cellnet.

    Would need some investigation. Someone must have tried it???

  14. #14
    Junior Member
    Join Date
    Jul 2001
    Posts
    27

    we didnt get to how we would be

    we didnt get to how we would be able to clear the text or individually clear the text like the backspace.

    is this still possible? which bit of the code do i need to mess with?

    i have posted a quick note on whether is is possible to send sms using flsh.

    will wait

    fred

  15. #15
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    To clear the text would be easy. Just have a button which sets the dynamic text field to "".

    To clear the last letter would be nearly as easy. If you repeatedly press the same button it already does that, but it then adds on the next letter. So all you'd need is a button that chops the last character off the dynamic text string. Something like:

    textField = textField.slice(0, texField.length-1);

    I seriously doubt whether you will be able to send an SMS message from flash though. That would allow you to create a comletely free text messaging service which I think mobile phone companies will have done all they can to prevent. In fact, have alook at one of Lycos' terms and conditions for use of their SMS service:

    8. The use of scripts or software to send SMS messages via this service is forbidden.

    I expect they've all got it sown up.

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