Flash action script tweenlite 1084 - actionscript-3

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.

Related

Error Function Scene Adobe Animate Syntax Error

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;
}
}

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.

Strange issue with preloader

I have some problem with my preloader.
Preloader Code:
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
var game:MovieClip
var added:Boolean;
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("source.swf");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
function onCompleteHandler(e:Event):void {
game = e.currentTarget.content
game.alpha = 0;
}
function onProgressHandler(e:ProgressEvent):void {
loader.loadBar.setProgress(e.bytesLoaded, e.bytesTotal);
}
addEventListener(Event.ENTER_FRAME, function(e:Event):void {
if(game != null){
if(!added) {
addChild(game);
added = true;
}
if(game.alpha < 1) game.alpha += 0.1;
When I load my game console returns TypeError: Error #1009: Cannot access a property or method of a null object reference.
I turn on permit debugging in game and again load. Now console returns TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main()[C: \Users\Lukasz\Desktop\Flash\rs\main.as:141];
So I checked 141 line and since 141 to 155 I have keyboard events.
stage.addEventListener(KeyboardEvent.KEY_UP, function(e:KeyboardEvent):void {
if(e.keyCode == 32 && moveAvailable) {
startEvent();
}else if(e.keyCode == 32) {
moveAvailable = true;
}
moveSpeed = 70;
});
stage.addEventListener(KeyboardEvent.KEY_DOWN, function(e:KeyboardEvent):void {
if(e.keyCode == 32) {
moveSpeed = 140
if(!startBtn.enb) moveAvailable = false;
}
});
When I get comment /**/ between this code game load correctly.
By the way I try this.parent and parent. instead of stage. but nothing changed :(
Someone have idea on this problem ?
You need check stage before use it
if (stage) {
addStageEvent();
} else {
this.addEventListener(Event.ADDED_TO_STAGE, addStageEvent);
}
function addStageEvent(e:Event = null):void {
//put the 141-155 line code here
}

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.

1120: Access of undefined property

I am getting this error message when I try to access a button movieclip from inside a videoPlayer movieclip. They are not nested. When the videoPlayer button is clicked the buttons tween to the bottom of the screen out of the way whilst the videoPlayer sits in their previous location. On closing the videoPlayer I would like the buttons to tween back in from the right of the screen but I get the following error message "1120: Access of undefined property TweenMax.from(btn1, 3, {x:450, y:209.1, ease:Back.easeOut});. My question is what would I use in as3 to access control of the buttons so I can tween them on closing the videoPlayer movieclip. Any pointers would be greatly appreciated.
The flvPlayer script:-
stop();
closeBtn.addEventListener(MouseEvent.CLICK, closeVid)
closeBtn.buttonMode = true;
function closeVid(e:MouseEvent):void
{
video.stop();
gotoAndStop(1);
TweenMax.from(btn1, 3, {x:450, y:209.1, ease:Back.easeOut});
}
**********************************************************************
The script from outside the videoPlayer or scene1:-
import com.greensock.*;
import com.greensock.easing.*;
var numberOfButtons:Number = 3
var startX:Number;
var startY:Number;
var currentButton:MovieClip
for (var i:int = 1; i <= numberOfButtons; i++)
{
this["btn"+i].buttonMode = true;
this["btn"+i].mouseChildren = false;
this["btn"+i].addEventListener(MouseEvent.MOUSE_OVER, doRollover)
this["btn"+i].addEventListener(MouseEvent.MOUSE_OUT, doRollout)
this["btn"+i].addEventListener(MouseEvent.CLICK, showbtnContent);
}
function doRollover(e:MouseEvent):void
{
TweenMax.to(this[e.target.name], 1, {scaleX:1.1, scaleY:1.1, ease:Elastic.easeOut});
}
// This function handles the Rollout event
function doRollout(e:MouseEvent):void
{
TweenMax.to(this[e.target.name], 1, {scaleX:1, scaleY:1, ease:Elastic.easeOut});
}
function showbtnContent(e:MouseEvent):void
{
currentButton = this[e.target.name]
switch (currentButton)
{
case btn1:
TweenMax.from(audioPlayer, 1, {x:449, y:-112, ease:Back.easeOut});
audioPlayer.gotoAndStop(2);
audioPlayer.parent.setChildIndex(audioPlayer, audioPlayer.parent.numChildren-1);
break;
case btn2:
TweenMax.from(mcGallery, 1, {x:450, y:300, scaleX:1, scaleY:1, ease:Back.easeOut});
mcGallery.gotoAndStop(2);
mcGallery.parent.setChildIndex(mcGallery, mcGallery.parent.numChildren-1);
break;
case btn3:
TweenMax.to(btn1, 20, {x:450, y:777.1, ease:Elastic.easeOut});
TweenMax.to(btn2, 16, {x:450, y:777.1, ease:Elastic.easeOut});
TweenMax.to(btn3, 12, {x:450, y:777.1, ease:Elastic.easeOut});
TweenMax.from(flvPlayer, 3, {x:1060, y:280, ease:Back.easeOut});
flvPlayer.gotoAndStop(2);
flvPlayer.parent.setChildIndex(flvPlayer, flvPlayer.parent.numChildren-1);
break;
}
}
when you use gotoAndStop(1); it moves to the first frame, where the btn1,btn2 and btn3 did not exist.
fixing it will be tough, because you'll need to move the timeline into a separate MovieClip from the MovieClip or Sprite that is holding the buttons, so that this does not happen.