From Action Script 2.0 to 3.0 compiling errors - actionscript-3

From the errors above what should I change in the code? I'm new to AS3 and a point in the right direction will help a lot, thanks!
Scene 1, Layer 'Script Layer', Frame 18, Line 62, Column 19 1084: Syntax error: expecting rightparen before add.
Scene 1, Layer 'Script Layer', Frame 18, Line 62, Column 29 1084: Syntax error: expecting rightparen before eq.
Scene 1, Layer 'Script Layer', Frame 18, Line 68, Column 24 1084: Syntax error: expecting rightparen before add.
Scene 1, Layer 'Script Layer', Frame 18, Line 68, Column 48 1084: Syntax error: expecting rightbrace before rightparen.
leng = 52;
q = 0;
while(Number(q) < Number(leng))
{
rand = random(52);
if(eval("c" add rand) eq "empty")
{
q = q - 1;
}
else
{
set("shuffle" add q,eval("c" add rand));
set("c" add rand,"empty");
}
q = Number(q) + 1;
}
q = 0;
}
ShufflePloy();

I don't know much about AS2, but first I'd try changing rand = random(52); to:
rand = Math.floor(Math.random()*52);
and then if(eval("c" add rand) eq "empty")
to
if(this["c"+rand] == "empty")
and the contents of the else block to
this["shuffle"+q] = this["c"+rand];
this["c"+rand] = "empty";

Related

Run Octave function form shell

It is possible to write a function directly in the octave shell?
A=147;
B=26.3;
C=5.4;
d=0.35*A;
function S=function_test(A,B,C,d)
S=2*A*B*C*d;
end
I tried this but if I wanted to know the value of "S", this error appears:
error: 'S' undefined near line 1, column 1
Yes it is possible. You does it correctly. But you missed indicating how you call the function. For me, no error occurs:
≫ function_test(1,2,3,4)
ans = 48
≫ res = function_test(1,2,3,4)
res = 48
≫ S = function_test(-1,3,5,7)
S = -210
≫

Error when creating animation from graph in Octave

I am trying to make an animation from a graph and save the result as GIF or video.
The graph and the animation work well in MATLAB but I cannot save it as GIF.
imread gives this error:
Magick: "gswin32c" "-q" "-dBATCH" "-dSAFER" "-dMaxBitmap=50000000" "-
dNOPAUSE" "-sDEVICE=ppmraw" "-dTextAlphaBits=4" "-dG
raphicsAlphaBits=4" "-r72x72" "-dFirstPage=1" "-dLastPage=1" "-
sOutputFile=C:\Users ...
I tried the solution from here, but that error pops up.
This is my code:
clear all;
clc;
for m = 1:10
n = m.*100;
x = linspace(0,1500,1500);
x2 = linspace(n,1000+n,500);
y2 = [((20e-6.*n + 0.008).*(sin(pi/1000.*(x2-n))).^2) ];
y1 = zeros(1,n);
y3 = zeros(1,1000-n);
y7 = [y1 y2 y3];
y8 = y7 + 0;
y1 = (sin(pi/150*x)).^2;
y3 = exp((x/400)-5);
y5 = (y1.*y3)+y8;
plot( x,y5);
drawnow;
#pause(0.01);
endfor
im = imread ("animation.pdf", "Index", "all");
imwrite (im, "animation.gif", "DelayTime", .5);
EDIT:
This is the complete error. Directory name redacted for privacy.
Magick: "gswin32c" "-q" "-dBATCH" "-dSAFER" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=ppmraw"
"-dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r72x72" "-dFirstPage=1" "-dLastPage=1" "-sOutputFil
e=C:\Users\XXXXXXXXXXXXXXXXXXXXXXXXXX" "--" "C:\Users\XXXXXXXXXXXXXXXXXXXXXXXXXX" "-c
" "quit" [No such file or directory].
error: Magick++ exception: Magick: Postscript delegate failed (F:\XXXXXXXXXXXXXXXXXXXXXXXXXX\animation.pdf) reported by coders/pdf.c:434 (ReadPDFImage)
error: called from
__imread__ at line 78 column 10
imageIO at line 118 column 26
imread at line 106 column 30
test_animation2 at line 6 column 4
I had the same problem.
For me, the solution was to install or reinstall the GhostScript program.
This was the error message I received:
Magick: "gswin32c" "-q" "-dBATCH" "-dSAFER" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=ppmraw"
"-dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r72x72" "-dFirstPage=1" "-dLastPage=1" "-sOutputFil
e=C:\Users\xxxxxx\AppData\Local\Temp\gmncleNd" "--" "C:\Users\xxxxxx\AppData\Local\Temp\gmEh1Xv4" "
-c" "quit" [No such file or directory].
error: Magick++ exception: Magick: Postscript delegate failed (C:\Users\xxxxxx\Desktop\TexML2.0\IN
entrada\in.pdf) reported by coders/pdf.c:434 (ReadPDFImage)
error: called from
_imread_ at line 80 column 10
imageIO at line 118 column 28
imread at line 106 column 33

Getting error in ActionsScript for a file that doesn't exist and that file is tempInit

So, I'm converting a flash file from 10 years ago that used actionscript 2.0. Now, I'm down to the last two errors but the top and bottom ones don't exist and the errors regarding bytes_loader are invalid.
Here are the errors:
Here are the errors listed here that are in the picture in the order of their appearance:
tempInit, Line 1, Column 15 1086: Syntax error: expecting semicolon before ECHO.
tempInit, Line 2, Column 15 1086: Syntax error: expecting semicolon before flowin.
Symbol 'bytes_loader', Layer 'Layer 2', Frame 1, Line 4, Column 22 1084: Syntax error: expecting rightbrace before leftbrace.
Symbol 'bytes_loader', Layer 'Layer 2', Frame 2, Line 8, Column 23 1084: Syntax error: expecting rightbrace before leftbrace.
tempInit, Line 1, Column 15 1086: Syntax error: expecting semicolon before implode.
tempInit, Line 1, Column 15 1086: Syntax error: expecting semicolon before lightflash.
Now the code for the two that I can get to in bytes_loader;
UPDATE:
added line numbers as it appears in the action editor
Identified that tempInit does not exist anywhere in the action editor
the first frame in the movie is "STOP" then SYMBOL DEFINITIONS then the very first element is: bytes_loader with its three frames.
That's all there is...
1) frloaded = _root.getBytesLoaded();
2) frtotal = _root.getBytesTotal();
3) if (frloaded < frtotal) {
4) tellTarget("_root") {
5) stop();
6) }
7) }
AND
1) frloaded = _root.getBytesLoaded();
2) frtotal = _root.getBytesTotal();
3) if (frloaded < frtotal) {
4) percentloaded = int((frloaded / frtotal) * 100) + "%";
5) setProperty("wbar", _xscale, (frloaded/frtotal) * 100);
6) setProperty("bbar", _xscale, (frloaded/frtotal) * 100);
7) } else {
8) tellTarget ("_root") {
9) play();
10) }
11) }
The reference to tempInit I can't find.
So, what's wrong with the code that doesn't error out...

Syntax error: expecting identifier before this. expecting colon before leftparen. expecting identifier before rightbrace

Scene 1, Layer 'script', Frame 1, Line 9 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 9 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 10 1084: Syntax error: expecting identifier before rightbrace.
Scene 1, Layer 'script', Frame 1, Line 16 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 16 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 17 1084: Syntax error: expecting identifier before rightbrace.
Scene 1, Layer 'script', Frame 1, Line 23 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 23 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 24 1084: Syntax error: expecting identifier before rightbrace.
Scene 1, Layer 'script', Frame 1, Line 30 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 30 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 31 1084: Syntax error: expecting identifier before rightbrace.
Scene 1, Layer 'script', Frame 1, Line 37 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 37 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 38 1084: Syntax error: expecting identifier before rightbrace.
Scene 1, Layer 'script', Frame 1, Line 44 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 44 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 45 1084: Syntax error: expecting identifier before rightbrace.
Scene 1, Layer 'script', Frame 1, Line 51 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 51 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 52 1084: Syntax error: expecting identifier before rightbrace.
Scene 1, Layer 'script', Frame 1, Line 58 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 58 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 59 1084: Syntax error: expecting identifier before rightbrace.
Scene 1, Layer 'script', Frame 1, Line 65 1084: Syntax error: expecting identifier before this.
Scene 1, Layer 'script', Frame 1, Line 65 1084: Syntax error: expecting colon before leftparen.
Scene 1, Layer 'script', Frame 1, Line 66 1084: Syntax error: expecting identifier before rightbrace.
these errors (27 of them) show up and my stop command wont work, whats wrong with my code?? i'm new to flash action script, and i used a youtube tutorial to create the buttons (knapp) i refere to.
here's my code
stop();
//knappane til dei forskjellige planetane
//solen
solenKnappen.addEventListener(MouseEvent.CLICK, goToSolen);
function goToSolen(event: MouseEvent);void {
this.gotoAndStop("solen")
}
//merkur
merkurKnappen.addEventListener(MouseEvent.CLICK, goToMerkur);
function goToMerkur(event: MouseEvent);void {
this.gotoAndStop("merkur")
}
//venus
venusKnappen.addEventListener(MouseEvent.CLICK, goToVenus);
function goToVenus(event: MouseEvent);void {
this.gotoAndStop("venus")
}
//jorden
jordenKnappen.addEventListener(MouseEvent.CLICK, goToJorden);
function goToJorden(event: MouseEvent);void {
this.gotoAndStop("jorden")
}
//mars
marsKnappen.addEventListener(MouseEvent.CLICK, goToMars);
function goToMars(event: MouseEvent);void {
this.gotoAndStop("mars")
}
//jupiter
jupiterKnappen.addEventListener(MouseEvent.CLICK, goToJupiter);
function goToJupiter(event: MouseEvent);void {
this.gotoAndStop("jupiter")
}
//saturn
saturnKnappen.addEventListener(MouseEvent.CLICK, goToSaturn);
function goToSaturn(event: MouseEvent);void {
this.gotoAndStop("saturn")
}
//uranus
uranusKnappen.addEventListener(MouseEvent.CLICK, goToUranus);
function goToUranus(event: MouseEvent);void {
this.gotoAndStop("uranus")
}
//neptun
neptunKnappen.addEventListener(MouseEvent.CLICK, goToNeptun);
function goToNeptun(event: MouseEvent);void {
this.gotoAndStop("neptun")
Your code's error is when using a semicolon ( ; ) to indicate the types of your functions instead of using a colon ( : ), so the code for your goToSolen() function, for example, should be like this :
function goToSolen(event: MouseEvent): void
{
this.gotoAndStop("solen");
}
And of course you should do that with all your functions.
For more about functions in ActionScript 3, take a look here.
Hope that can help.

Hi, creating a maze game and seriously cannot figure out how to fix this (I'm new to AS3) :)

addEventListener(Event.ENTER_FRAME, hitTest);
hitTest(evt:Event)
(Character.hitTestPoint(mouseX, mouseY, true)
{
MovieClip(this.root).gotoAndPlay(1, "Main Menu");
}
Keep getting errors like
Level 1, Layer 'Actions', Frame 8, Line 3, Column 13 1084: Syntax error: expecting rightparen before colon.
Level 1, Layer 'Actions', Frame 8, Line 5, Column 3 1084: Syntax error: expecting rightparen before leftbrace.
function hitTest(evt:Event) {
if(Character.hitTestPoint(mouseX, mouseY, true))
{
MovieClip(this.root).gotoAndPlay(1, "Main Menu");
}
}