View Full Version : very basic question
meenkster
12-23-2002, 03:36 PM
hi,
i am new to actionscript, but i kind of experienced in many other languages... some ppl told me that actionscript is similar to jscript which do very well but i dont get along with that strange "editor" macromedia provides in flash5(using flash5 cos mx wont run on the specified device....) so here is my question... i need to have a script that would put letters into an input after the button of that letter has been clicked. in js it would look like this but i have no idea how to do that in actionscript:
---------js
<script>
function addchar(c)
{
document.forms.bogus.bogusinp.value += c;
}
</script>
<div id=key_a onclick="addchar('a')">
--------js
if anyone has an idea, or know a good source or can help me anyways.. thanks!
Mortimer Jazz
12-23-2002, 04:17 PM
on your button:
on(release){
myText = "a";
}
...where myText is the variable name of your textbox.
Hope this helps :)
Mortimer Jazz
12-23-2002, 04:19 PM
*reads thread properly!*
or if you want to use a function
put this function on the main timeline
function myFunc(letter){
myText = letter;
}
and on the button:
on(release){
myFunc("a")
}
meenkster
12-23-2002, 05:21 PM
thanks, but i am t00 stupid.
i dont get the function of the editor?
how do i actually WRITE a line of code with that thing that appears after i made a "symbol" by pressing f8 out of something and then rightclicking and selecting "action"?? i managed to create that event handler if it is one by clicking "+" but no there only
on (release)
{
}
and it wont let me put in a single line of code and i cannot define my vars anywhere... is there an alternative method to build those scripts?!?!??!
meenkster
12-23-2002, 06:00 PM
ok... i figured that out now:) but nothing happens after i run that script when i click the button...
jcgodart
12-23-2002, 06:15 PM
Originally posted by meenkster
is there an alternative method to build those scripts?!?!??!
Yes, switch to expert mode (little options popup menu at top-right hand side of actions window).
Can't really help you without looking your fla. Please put it here.
meenkster
12-23-2002, 06:56 PM
hi again
i cant show you my fla since i have because i dont know how to do what i want to do.
I want build a web-app for an ipaq, where flash comes in handy because it supports nice graphics and a potential good scripting language, unlike the build-in IE 3.0. the problem (no problem in fact, rather nice) is that the text-input boxes of flash are not recognised as such by the system and so i have to do my own keyboard (which does not support all keys, only alphanumeric..) input system. This is no problem for in any language but action script. In fact it is pretty nice because i can skin the keyboard myself but i do not get how to make an certain amount of keys (some shapes or images) execute a simple actionscript function that would put the right char in the input box.
what i am trying to build are some keys that can be clicked and each runs the function addchar(c); which would look like:
function addchar(c)
{
mytextbox += c;
}
i have already found out that AS seems to use those inputboxes' values as simple variables but i just cant make my buttons which i have made symbols and put the code
on (release)
{
mytextbox = "CHAR"; //<- this being the "set variable" action
}
and yes, i have setted the maxlength property to longer than zero and what not...
:(
meenkster
12-23-2002, 07:42 PM
it now works but i where to put my functions?
is it possible to generate buttons with function, taking their positions and sizes from an array?
like :
buttons = [];
buttons["key"] = ("q","w",...
buttons["posx"] = (0,20,...
...
for (i=0;i<buttons["key"].length;i++)
{
document.write("<button left="+buttons["posx"][i]+" ... onmouseup=\"addchar('"+buttons["key"][i]+"'\">");
}
?????
i know i suck with my javascript examples but...
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.