Error Function Scene Adobe Animate Syntax Error - actionscript-3

i tried to use adobe animate 2019 to make a quiz. there are some errors:
Scene 15, Layer 'Actions', Frame 1, Line 68, Column 7 1083: Syntax
error: else is unexpected.
Scene 15, Layer 'Actions', Frame 1, Line 63, Column 47 1084: Syntax error: expecting semicolon before rightparen. Scene 15, Layer
'Actions', Frame 1, Line 62, Column 53 1084: Syntax error: expecting
identifier before logicaland.
Here's my code:
import flash.events.MouseEvent;
//melakukan inisialisasi posisi awal dari object
//fungsi ini dibuat terutama untuk keperluan "me-reset posisi object"
function inisialisasi_posisi():void{ //
benar_mc.visible = false;
salah_mc.visible = false;
//posisi ayah
ayah_mc.x = posisiawal_ayah_mc.x;
ayah_mc.y = posisiawal_ayah_mc.y;
//posisi kakak
kakak_mc.x = posisiawal_kakak_mc.x;
kakak_mc.y = posisiawal_kakak_mc.y;
//posisi ibu
ibu_mc.x = posisiawal_ibu_mc.x;
ibu_mc.y = posisiawal_ibu_mc.y;
//posisi adik
adik_mc.x = posisiawal_adik_mc.x;
adik_mc.y = posisiawal_adik_mc.y;
} //
inisialisasi_posisi();
//DRAG & DROP OBJECT
function dragdrop(object_mc:MovieClip):void
{
object_mc.addEventListener(MouseEvent.MOUSE_DOWN, startdrag);
object_mc.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
}
function startdrag(e:MouseEvent):void
{
e.currentTarget.startDrag();
}
function stopdrag(e:MouseEvent):void
{
e.currentTarget.stopDrag();
}
//set dragdrop
dragdrop(ayah_mc);
dragdrop(kakak_mc);
dragdrop(ibu_mc);
dragdrop(adik_mc);
//result
test_btn.addEventListener(MouseEvent.CLICK, test);
function test(e:MouseEvent):void
{
//jika semua object berada pada tempat yang benar
if(ayah_mc.hitTestObject(ayahTarget_mc)== true &&
kakak_mc.hitTestObject(kakakTarget_mc)== true &&
ibu_mc.hitTestObject(ibuTarget_mc)== true) &&
adik_mc.hitTestObject(adikTarget_mc)== true) ;
{
benar_mc.visible = true;
salah_mc.visible = false;
}
else
{
benar_mc.visible = false;
salah_mc.visible = true;
}
}
//reset object ke posisi awal
reset_btn.addEventListener(MouseEvent.CLICK, reset);
function reset(e:MouseEvent):void
{
inisialisasi_posisi();
}
/* Click to Go to Scene and Play
Clicking on the specified symbol instance plays the movie from the specified scene and frame.
Instructions:
1. Replace "Scene 3" with the name of the scene you would like play.
2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
*/
button_nextquiz1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_16);
function fl_ClickToGoToScene_16(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "Scene 16");
}
/* Click to Go to Previous Scene and Play
Clicking on the specified symbol instance moves the playhead to the previous scene in the timeline and continues playback in that scene.
*/
button_previousquiz1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousScene_17);
function fl_ClickToGoToPreviousScene_17(event:MouseEvent):void
{
MovieClip(this.root).prevScene();
}
stop();
Thank you so much!

You have an extra parentheses and and extra semicolon in the if condition inside your test function. Change it to:
function test(e:MouseEvent):void
{
//jika semua object berada pada tempat yang benar
if(ayah_mc.hitTestObject(ayahTarget_mc) == true &&
kakak_mc.hitTestObject(kakakTarget_mc) == true &&
ibu_mc.hitTestObject(ibuTarget_mc) == true &&
adik_mc.hitTestObject(adikTarget_mc) == true)
{
benar_mc.visible = true;
salah_mc.visible = false;
}
else
{
benar_mc.visible = false;
salah_mc.visible = true;
}
}

Related

as3 flash gotoAndPlay

I am making a small platformer game at flash and I just added the first enemy.
I get this in the "output":
" TypeError: Error #1006: gotoAndPlay is not a function.
at scratch_theGame_nojumping_tryEnemy_fla::MainTimeline/fl_enemyAlerted() "
My code on the enemy layer is the following:
var enemyAlerted:Boolean = false;
var alerted:Boolean = false;
var enemy:Object = new Object();
stage.addEventListener(Event.ENTER_FRAME, fl_alerted);
stage.addEventListener(Event.ENTER_FRAME, fl_enemyAlerted);
function fl_alerted(event:Event):void
{
if (char.x > 400)
{
alerted = true;
}
}
function fl_enemyAlerted(event:Event):void
{
if (alerted = false)
{
enemy.gotoAndPlay("alert");
}
if (alerted = true)
{
enemy.gotoAndPlay("chase");
}
}
My goal here is to make the enemy loop the 'alert' animation from the start until my character has come close enough to be noticed, and then the enemy should play the 'chase' animation. Can anyone help? Thank you in advance.

What is the error causing my character delay its response when press a key?

I have some problems with my character's walking command. It delays its movement for a bit before it actually moves. And then at times it completely ignores the command to stop walking when I released the key.
Code:
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Stage;
hero.gotoAndStop(1);
var rightPressed: Boolean = new Boolean(false);
var leftPressed: Boolean = new Boolean(false);
var upPressed: Boolean = new Boolean(false);
var downPressed: Boolean = new Boolean(false)
var heroSpeed: Number = 10;
var keys: Array = [];
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, gameLoop);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
function keyDownHandler(KeyEvent: KeyboardEvent): void {
if (keys[Keyboard.RIGHT]) {
rightPressed = true;
} else if (keys[Keyboard.LEFT]) {
leftPressed = true;
} else if (keys[Keyboard.DOWN]) {
downPressed = true;
} else if (keys[Keyboard.UP]) {
upPressed = true;
}
}
function keyUpHandler(KeyEvent: KeyboardEvent): void {
if (keys[Keyboard.RIGHT]) {
rightPressed = false;
hero.gotoAndStop(4)
} else if (keys[Keyboard.LEFT]) {
leftPressed = false;
hero.gotoAndStop(2)
} else if (keys[Keyboard.DOWN]) {
downPressed = false;
hero.gotoAndStop(1);
} else if (keys[Keyboard.UP]) {
upPressed = false;
hero.gotoAndStop(3);
}
}
function gameLoop(loopEvent: Event): void {
if (rightPressed) {
hero.x += heroSpeed;
hero.gotoAndStop(8)
}
if (leftPressed) {
hero.x -= heroSpeed;
hero.gotoAndStop(6)
}
if (downPressed) {
hero.y += heroSpeed;
hero.gotoAndStop(5);
}
if (upPressed) {
hero.y -= heroSpeed;
hero.gotoAndStop(7);
}
}
function onKeyDown(e: KeyboardEvent): void {
keys[e.keyCode] = true;
}
function onKeyUp(e: KeyboardEvent): void {
keys[e.keyCode] = false;
}
Warnings:
Scene 1, Layer 'Actions', Frame 1, Line 68, Column 10 Warning: 1090: Migration issue: The onKeyDown event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( 'keyDown', callback_handler).
Scene 1, Layer 'Actions', Frame 1, Line 72, Column 10 Warning: 1090: Migration issue: The onKeyUp event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( 'keyUp', callback_handler).
You should get rid of the two extra KeyboardEvent handlers (onKeyUp and onKeyDown), and move the code you have there into keyUpHandler and keyDownHandler. That will solve those migration warnings (because onKeyUp and onKeyDown were special methods in AS2), and it may be the solution to your other problem: I guess sometimes the onKeyDown handler gets executed after keyDownHandler, which means the boolean values in your array are not set yet and no movement will start.
Even better: also get rid of the array with booleans (and keys! you're abusing an Array for Dictionary use) and do it like this:
function keyDownHandler(KeyEvent: KeyboardEvent): void {
if (event.keyCode==Keyboard.RIGHT]) {
rightPressed = true;
}
//etc
}

Flash CS6 error: 1084

On flash CS6 Actionscript 3.0, I am getting this error code.
Scene 1, Layer 'good guy', Frame 1, Line 23 1084: Syntax error: expecting identifier before assign.
What is this error? I do not understand.
Here is my code.
`import flash.events.MouseEvent;
var mouseIsDown = false;
stage.addEventListener(MouseEvent.MOUSE_DOWN, clicked);
stage.addEventListener(MouseEvent.MOUSE_UP, unclicked);
function clicked (n:MouseEvent)
{
mouseIsDown = true;
}
function unclicked (n:MouseEvent)
{
mouseIsDown = false;
}
addEventListener(Event.ENTER_FRAME, mainLoop);
function mainLoop (e:Event)
{
if (mouseIsDown)
{
gg_mc.y -= 10
}
else
{
gg_mc.y +
= 10
}
for (var I = 0; I < numChildren; I++)
{
if (getChildAt(I) is bad)
{
var b = getChildAt(I) as bad;
if (b.hitTestObject(gg_mc))
{
trace ("You got hit! GAME OVER")
}
}
}
}
That error means you have a formatting error in your code.
This line:
gg_mc.y +
= 10
There should be no line break or space there
gg_mc.y += 10;
Also,
`import flash.events.MouseEvent;
That quote at the start is invalid, take it out.

Flash action script tweenlite 1084:

I'm new to action script
I have a problem with action script 3.0
I got the error
Scene 1, Layer 'actions', Frame 1, Line21 1084: Syntax error: expecting rightbrace before y
TweenLite.to(balk_mc, 1, {x:551 y:balk_mc.y});
i cant get to 1 screen its on a loop i thought that it would be over with the gotoandstop but it doesnt
import flash.events.MouseEvent;
import com.greensock.*;
stop();
button1.addEventListener(MouseEvent.CLICK, button1_clicked);
function button1_clicked(e:MouseEvent):void{
TweenLite.to(balk_mc, 1, {x:141.35, y:balk_mc.y});
gotoAndStop("page1");
}
button2.addEventListener(MouseEvent.CLICK, button2_clicked);
function button2_clicked(e:MouseEvent):void{
TweenLite.to(balk_mc, 1, {x:330.6, y:balk_mc.y});
gotoAndStop("page2");
}
button3.addEventListener(MouseEvent.CLICK, button3_clicked);
function button3_clicked(e:MouseEvent):void{
TweenLite.to(balk_mc, 1, {x:551 y:balk_mc.y});
gotoAndStop("page3");
}
var number:Number = 1;
next_btn.addEventListener(MouseEvent.CLICK, nextImage);
checkNumber();
function nextImage(event:MouseEvent):void {
//trace("next button geklikt!");
number++;
loader.source = "images/tommorrowland"+number+".png";
checkNumber();
}
previous_btn.addEventListener(MouseEvent.CLICK, previousImage);
function previousImage(event:MouseEvent):void {
//trace("previous button geklikt!");
number--;
loader.source = "images/tommorrowland"+number+".png";
checkNumber();
}
function checkNumber():void {
next_btn.visible = true;
previous_btn.visible = true;
if(number == 4){
next_btn.visible = false;
}
if(number == 1){
previous_btn.visible = false;
}
}
}
}
button4.addEventListener(MouseEvent.CLICK, button4_clicked);
function button4_clicked(e:MouseEvent):void{
TweenLite.to(balk_mc, 1, {x:735 y:balk_mc.y});
gotoAndStop("page4");
}
It's clear that you are new to not only Actionscript, but to StackOverflow too. This website isn't designed to help you find your spelling or typing mistakes. Please revise your code before asking a question every time you get an error. Do some research.
This is the last time I or anyone else will help you with this kind of question. You are missing a comma before y.
Change this line:
TweenLite.to(balk_mc, 1, {x:551 y:balk_mc.y});
with this one
TweenLite.to(balk_mc, 1, {x:551, y:balk_mc.y});
And next time read your own code yourself please.

Flash action script tweenlite 1084

I'm a beginner in flash i got an error in actions script 3.0
I'm using tween lite
I got the error 1084: Syntax error: expecting colon before comma.
its about this line
TweenLite.to(balk_mc, 1, {x:141,35, y:balk_mc.y});
And it says line 10 and 16
The whole code im using is:
import flash.events.MouseEvent;
import com.greensock.*;
stop();
button1.addEventListener(MouseEvent.CLICK, button1_clicked);
function button1_clicked(e:MouseEvent):void{
gotoAndStop("page1");
TweenLite.to(balk_mc, 1, {x:141,35, y:balk_mc.y});
}
button2.addEventListener(MouseEvent.CLICK, button2_clicked);
function button2_clicked(e:MouseEvent):void{
gotoAndStop("page2");
TweenLite.to(balk_mc, 1, {x:330,6, y:balk_mc.y});
}
button3.addEventListener(MouseEvent.CLICK, button3_clicked);
function button3_clicked(e:MouseEvent):void{
gotoAndStop("page3");
TweenLite.to(balk_mc, 1, {x:551, y:balk_mc.y});
var number:Number = 1;
next_btn.addEventListener(MouseEvent.CLICK, nextImage);
checkNumber();
function nextImage(event:MouseEvent):void {
//trace("next button geklikt!");
number++;
loader.source = "images/tommorrowland"+number+".png";
checkNumber();
}
previous_btn.addEventListener(MouseEvent.CLICK, previousImage);
function previousImage(event:MouseEvent):void {
//trace("previous button geklikt!");
number--;
loader.source = "images/tommorrowland"+number+".png";
checkNumber();
}
function checkNumber():void {
next_btn.visible = true;
previous_btn.visible = true;
if(number == 4){
next_btn.visible = false;
}
if(number == 1){
previous_btn.visible = false;
}
}
}
button4.addEventListener(MouseEvent.CLICK, button4_clicked);
function button4_clicked(e:MouseEvent):void{
gotoAndStop("page4");
TweenLite.to(balk_mc, 1, {x:551, y:balk_mc.y});
}
You have written 141,35 instead of 141.35. It's a typing error. Numbers in coding languages are written with a point. Same goes to 330,6 you've got in your code.