View Full Version : Correcting actionscript 3.0 coding
lovemail1356
12-31-2008, 07:30 AM
Hi
Can anyone help me here, on how to correct my coding?
because they keep telling me that my code is wrong
but i can't figure out what
stop();
oneB.addEventListener(MouseEvent.MOUSE_DOWN,mouseD ownHandler31);
function mouseDownHandler31(event:MouseEvent):void {
function _root.answer1.text = "Wrong Answer ";
}
What my code is meant to lead to is to link a button to a dynamic text.
chemicaluser
12-31-2008, 08:18 AM
if you look at line after the stop statement,
the function name is "mouseD ownHandler31"
notice the space ....
try this
stop();
oneB.addEventListener(MouseEvent.MOUSE_DOWN,mouseD ownHandler31);
function mouseDownHandler31(event:MouseEvent):void {
function _root.answer1.text = "Wrong Answer ";
}
lovemail1356
12-31-2008, 08:38 AM
nope...
still doesn't work
there are three errors now, all error 1084.
function _root.answer1.text = "Wrong Answer ";1084: Syntax error: expecting leftparen before dot.
}1084: Syntax error: expecting identifier before rightbrace.
}1084: Syntax error: expecting rightparen before rightbrace.
wvxvw
12-31-2008, 08:50 AM
function _root.answer1.text = "Wrong Answer ";
What did you want to write here? This line is incorrect and I cannot even imagine what was it meant to be...
lovemail1356
12-31-2008, 08:56 AM
what i really wanted to write is because my dynamic text is identified as "answer1", and the function bit is where the button is pressed, or on release, and when that happens in the "answer1", the words "wrong answer" would appear.
wvxvw
12-31-2008, 09:19 AM
then it should look like:
answer1.text = "Wrong Answer ";
instead of:
function _root.answer1.text = "Wrong Answer ";
lovemail1356
12-31-2008, 09:52 AM
my code is now:
stop();
oneB.addEventListener(MouseEvent.MOUSE_DOWN,mouseD ownHandler31);
function mouseDownHandler31(event:MouseEvent):void {
answer1.text = "Wrong Answer ";
}
however, i'm getting one error message:
1120: Access of undefined property oneB.
Is there anyway i can fix this?
Thank you!
wvxvw
12-31-2008, 10:25 AM
What is oneB?
lovemail1356
12-31-2008, 11:34 AM
oneB is the name of my button, and answer1 is the dynamic text
wvxvw
12-31-2008, 12:01 PM
Apparently it's not... because if it was it's name you wouldn't be getting this error. Check you've typed it correctly, "Automatically declare stage instances" is selected in the publish settings, the button exists in the frame where you've placed the script.
ryguyspk
12-31-2008, 07:26 PM
You're using an extra argument in your addEventListener called mouseD. I'm not sure what that is. Try something like the code below. Replace yourButton with the name of the button you're using and replace yourHandler with the name of the function handler you're using.
yourButton.addEventListener(MouseEvent.MOUSE_DOWN, yourHandler);
function yourHandler(event:MouseEvent):void
{
answer1.text = "Wrong Answer ";
}
james00bond00
12-31-2008, 07:53 PM
lovemail - I gave you the same code this morning in your other post... no need to start a new one. Just follow exactly what ryguyspk has, where you can substitute the name of yourhandler and yourbutton to what ever you need. And dont add in _root. :cool:
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.