Simple Errors in Flash CS6 - ActionScript 3.0 - actionscript-3

This is probably super simple. I have created a basic replay button in Flash CS6 Pro, ActionScript 3.0. The instance name is correct, but I get a syntax error and '{'expected. What an I doing wrong?
Code:
import flash.events.MouseEvent;
stop();
playAgain_btn.addEventListener(MouseEvent.CLICK, f_playAgain);
function f_playAgain (event:MouseEvent):void
{
gotoAndPlay(1);
}
EDIT:
The errors are as follows:
Scene=Scene 1, layer=actions, frame=1161, Line 1 Syntax Error.
Scene=Scene 1, layer=actions, frame=1161, Line 7 '{' expected.

I believe that removing the space in here:
f_playAgain (event:MouseEvent):void
might do the job
f_playAgain(event:MouseEvent):void

Related

submenus wont work action script 3 flash cc professional

Hi and sorry in advance I'm super new and took me like 5 hours to reach this point!
I'm working on a project to teach young and not so young how to use windows.
so far I'm almost done but I'm having trouble on making my submenus live.
Yet so far I've completed 2 mc's on flash cc 2015 professional, its a windows start button that calls all the menu or buttons like allapps, power, settings etc..
once the menu moves can give any action to the rest of the mc's allapps, power. settings etc... get "Scene 1, Layer 'actions', Frame 1, Line 16, Column 1 1120: Access of undefined property menu1_btn."
the current ac is the following:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
startbtn_mc.buttonMode=true;
dropdown_mc.buttonMode=true;
startbtn_mc.addEventListener(MouseEvent.CLICK,dropUp);
function dropUp(e:MouseEvent):void
{
var enterTween:Tween;
enterTween = new Tween(dropdown_mc,"y",Regular.easeOut, dropdown_mc.y, 15.3, 30, false);
}
menu1_btn.addEventListener(MouseEvent.CLICK, gotoMovie);
function gotoMovie(e:MouseEvent):void
{
var moviescene:MovieClip = new movie();
stage.addChild(moviescene);
}
enterTween.addEventListener(TweenEvent.MOTION_FINISH,dropUpEventListener);
}
function dropUpEventListener(e:TweenEvent):void
{
startbtn_mc.removeEventListener(MouseEvent.CLICK,dropUp);
startbtn_mc.addEventListener(MouseEvent.CLICK,dropdown);
}
function dropdown(e:Event):void
{
var enterTween:Tween;
enterTween = new Tween(dropdown_mc,"y",Regular.easeOut, dropdown_mc.y, 470, 30, false);
enterTween.addEventListener(TweenEvent.MOTION_FINISH,dropdownEventListener);
}
function dropdownEventListener(e:TweenEvent):void
{
startbtn_mc.removeEventListener(MouseEvent.CLICK,dropdown);
startbtn_mc.addEventListener(MouseEvent.CLICK,dropUp);
}
I realize there are 9 buttons to go and I'm not able to move forward.
Please help!!!!!
Layer 'actions', Frame 1, Line 16, Column 1 1120: Access of undefined
property menu1_btn.
The error messages have specific meanings and refer you to exactly where and why the error is occuring:
on Frame 1
in Layer "actions:"
on line 16
you are referencing menu1_btn
BOOM – it is undefined.
Does menu1_btn exist? Is it named something else? A great mystery.
None of us can tell just from the code you posted what is going on in your .fla file – e.g. how it is structured, what elements are in what frames, etc.
Half of programming is debugging. Tuck in.
(and it is completely unclear what this question has to do with "sub-menus")

Flash AS3 : HitTest unexpected error

If have a Problem with this bit of code in my Flash AS3 Project:
//Hit Test between Objects
function hitTest(a,b:DisplayObject):Boolean {
if (b.hitTestObject(a) == true) then {
return true;
} else {
return false;
}
}
I am calling it like so:
trace(hitTest(player, c_lvl.gold1));
Player is an Object created in my Code (instance of a movieclip):
player = new Player();
world.addChild(player);
gold1 is an instance of a movieclip packed in another movieclip called c_lvl.
Im getting 2 errors:
/Users/nicolasbrauch/Google Drive/info_1/script.as, Line 141 1008: Attribute is invalid.
/Users/nicolasbrauch/Google Drive/info_1/script.as, Line 143 1083: Syntax error: else is unexpected.
Line 141 is the first Line of my hitTest function.
What shall I do? Where is my error? I dont get it...
As akmozo said, you shouldn't have a then keyword after your if conditional. Once you remove that keyword, you will have fixed both errors.

Loading movie with a button

I am trying to load movies via buttons interaction with ActionScript 3.0. I am creating this movie from Flash CS 5.5.
I could get the first button (I called 'Preface') to work. When adding the second button, I got this error at runtime:
Scene 1, Layer 'Actions', Frame 1, Line 22 1023: Incompatible override.
Scene 1, Layer 'Actions', Frame 1, Line 22 1021: Duplicate function definition.
There dun seem to be any duplicate that could initiate any overrides:
//import flash.events.MouseEvent;
preface.addEventListener(MouseEvent.CLICK, preface1);
sq.addEventListener(MouseEvent.CLICK, sq);
function preface1(event:MouseEvent):void
{
// Start your custom code
// This example code displays the words "Mouse clicked" in the Output panel.
trace("Mouse clicked");
var preface:Preface= new Preface;
addChild(preface);
preface.removeEventListener(MouseEvent.CLICK, preface1);
// End your custom code
}
function sq(event:MouseEvent):void
{
//Get sample menus
}
Any pointers is highly appreciated.
You have an instance of a MovieClip named sq, and you declare a function with name sq. This is no longer possible to do with Actionscript 3. You have to name your function something other than sq or preface, as this name is occupied by your another MC.

Vectorian Giotto import flash.external.ExternalInterface syntax error?

I'm creating a scaleform HUD for UDK, and everything is created. The problem is that i want the healthbar and weapons bar to rotate slightly to give a 3d effect. When I try to do this i get 2 errors:
on line 1, Characters 1-2, Syntax Error: i
on line 6, CHaracters 1-10, Syntax error: intrinsic
import flash.external.ExternalInterface
import gfx.motion.Tween
_global.gfxExtension = true;
function init()
{
_root.HealthBar._yrotation = 30;
_root.Weapons._yrotation = 30;
}
init();
Is it because this is for actionscript 3.0? how would i convert it to 2.0? Thank You
Take a look at this thread, which talks about some challenges with using ExternalInterface: http://forums.epicgames.com/threads/802762-Developing-Scaleform-UI-with-Vectorian-Giotto

Flash Player 11.2 Video Events addEventListener

Has anyone been able to get an addEventListener working with Flash Player 11.2?
I always get this error:
Scene 1, Layer 'actions', Frame 1, Line 104 1119: Access of possibly
undefined property COMPLETE through a reference with static type
Class.
If I switch my flash player to output to
here is my code:
import flash.events.Event;
import fl.video.VideoEvent;
import fl.video.*;
myVideo.source ="videoName.flv";
myVideo.play();
myVideo.addEventListener(VideoEvent.COMPLETE, vidComplete)
function vidComplete(event:VideoEvent) {
trace("done");
}
For some reason, the AS3 compiler for Flash Player 11 in Flash CS6 seems to ignore the import statements for fl.video.*;
Source: http://forums.adobe.com/message/4699000
This person's solution implies that specifying the entire class package inline in the code as follows should alleviate the issue:
myVideo.source ="videoName.flv";
myVideo.play();
myVideo.addEventListener(fl.video.VideoEvent.COMPLETE, vidComplete)
function vidComplete(event:fl.video.VideoEvent) {
trace("done");
}