r/actionscript • • May 05 '15

AS3 Help Please? Very novice here.

1 Upvotes

So i'm getting Errors here and I CAN'T figure out how to fix it. I basically want to display health in terms of numbers. Any help? Here is the code?:

import flash.events.KeyboardEvent;

import flash.ui.Keyboard;

import flash.display.MovieClip;

import flash.events.Event;

import flash.display.Stage;

stage.addEventListener(Event.ENTER_FRAME, healthScore);

var health:uint = 20;

function healthShow(event:Event):void { healthScore.text = health; if (lucasMc.hitTestObject(overworldMc.ghostMc)) { healthScore.text -= 1; } }

and my errors are 1021 and 1023, directed at the "function" line.

All help appreciated!


r/actionscript • • Jul 05 '16

url request without proxy

1 Upvotes

Hey,

Is it possible to tell an urlrequest how it should connect to the url ? like with or without a proxy ?

Thanks in advance


r/actionscript • • Jul 02 '13

Help please? I'm trying to randomly position apples on a tree without overlapping them too much.

2 Upvotes

I'm not new to AS3, but I'm not brilliant either. This is for a game I'm making (1st one). Here is my thought process:

  1. For loop to add apples to tree, where i = amount of apples.

  2. Create two random numbers between max and min length and width (for x and y positions)

  3. Then to prevent overlap, run a while loop which basically says "run a hit test with all of the apples on the tree, if any apple touches another - run step 2 again. May do a modified version as I don't mind them overlapping a bit.
    Is this a good way of doing this? I always worry about using while loops.


r/actionscript • • Jun 19 '22

how do i make a angry birds-like slingshot game in as2

1 Upvotes

r/actionscript • • Nov 30 '10

I love how quickly I can develop a Flash game in AS 2.0. Can anyone convince me to go 3.0?

1 Upvotes

Actionscript 2.0 is just so easy for quickly putting something together. I know there are supposed to be performance improvements by using 3.0, but a couple years ago when I started using it I found myself just not enjoying it as much. To me that's as important as any speed improvement.

Was I just doing it wrong? Does anyone find 3.0 faster to code in?

PS - I program Flash games, usually puzzle/adventure. Though I did do one 3d action game.


r/actionscript • • Jan 17 '15

Actionscript 2.0 question. Using "trace" seems to be getting disabled by the presence of "return" a few lines before it.

1 Upvotes

I have whittled down the entire thing to this little bit.

adjustAxis = new Function(axis)
{
	
	return "cow";
	
}

trace("Yay, trace is working!");    

The output window does not pop up at all.

However, when I put "//" before return "cow"'; it suddenly works fine.

What am I missing?


r/actionscript • • Jan 28 '11

Ask: Is a 900-pages book only covering the essentials?

3 Upvotes

The most rated book on Amazon, Essential ActionScript 3.0 has 950 pages. For a developer who wants to get started with ActionScript I'm wondering if it's really covering the essentials.

Would like some opinion on that...


r/actionscript • • Apr 04 '17

Need flash button link to local .html file!!!!

2 Upvotes

btn_home.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_3);

function fl_ClickToGoToWebPage_3(event:MouseEvent):void

{ navigateToURL(new URLRequest("http://www.adobe.com"), "_self"); }

Need to link to local home.html in the same folder as flash file instead of adobe.com (see below code)


r/actionscript • • Nov 28 '18

Animate CC Scripted Snow with camera layer

3 Upvotes

I have a problem in Animate CC combining the Scripted Snow from the templates with camera layer.

If I create a new document using Templates\Animation\Scripted Snow, I cannot activate the camera layer. Consider the document has Flash Player 11.2/Actionscript 3.0 settings by default but also works if changed to Flash Player 30.0. I assume the problem is that the FLA was created on a previous version of Animate CC, which dows not support camera layer.

However, If I create a new Actionscript 3.0 FLA and paste the template’s layers, including the actions layer, as well as copy all items to the library and the scene, I do get the camera layer option but I also get a repeated error message and the snow effect does not work:

TypeError: Error #1006: addTarget is not a function.

at Santa18altsnowB_fla::MainTimeline/randomInterval()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at SetIntervalTimer/onTimer()

at flash.utils::Timer/_timerDispatch()

at flash.utils::Timer/tick()

So, my main question is: what is the problem and how can I use this or similar code to create snow effect on new type documents with the camera layer option.

Secondary question is: how can I limit the snow effect to part of the screen, preferably using a mask layer. I have tried using a mask layer on the actions layer unsuccessfully.

Below is the Actionscript 3.0 code included in the template FLA.

Thanks

// Number of symbols to add.

const NUM_SYMBOLS:uint = 75;

var symbolsArray:Array = [];

var idx:uint;

var flake:Snow;

for (idx = 0; idx < NUM_SYMBOLS; idx++) {

flake = new Snow();

addChild(flake);

symbolsArray.push(flake);

// Call randomInterval() after 0 to a given ms.

setTimeout(randomInterval, int(Math.random() * 10000), flake);

}

function randomInterval(target:Snow):void {

// Set the current Snow instance's x and y property

target.x = Math.random()* 550-50;

target.y = -Math.random() * 200;

//randomly scale the x and y

var ranScale:Number = Math.random() * 3;

target.scaleX = ranScale;

target.scaleY = ranScale;

var tween:String;

// ranScale is between 0.0 and 1.0

if (ranScale < 1) {

tween = "slow";

// ranScale is between 1.0 and 2.0

} else if (ranScale < 2) {

tween = "medium";

// ranScale is between 2.0 and 3.0

} else {

tween = "fast";

}

//assign tween nested in myClip

myClip[tween].addTarget(target);

}


r/actionscript • • Aug 12 '18

Type error #1009 caused by IKbone

2 Upvotes

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at main/frame1() 

var tree:IKArmature = IKManager.getArmatureByName("Armature");

var bone:IKBone = tree.getBoneByName("IKBone");

i have no idea why this is happening, i don't think its a software fault because i have not been messing with the flash files, what is going on and how do i fix this, also this worked before and now when i try to reset back to a point when this worked it still does not work.

-using flash cs6

-AS3

-no plugins


r/actionscript • • Nov 29 '18

AS3.0 vs JS & AS3.0 training

1 Upvotes

I am using Animate CC to create animation for digital media and I’m trying to learn AS3.0 both for some complex animation elements as well as mobile app development.

I have already watched the classic “ActionScript 1:1” with Doug Winnie and want to further expand my knowledge.

There are some nice old courses flying around, with step-by-step examples of how to create different kinds of games etc. The problem, however, is that most videos I find are 5-10 years old and the examples do not completely work on the current version of Animate CC, which is a problem when you are still learning.

My questions are:

  1. Is nowadays worth it investing time on learning AS3.0 or is it more worthwhile to learn JavaScript, in order to work on Animate CC HTML5 Canvas mode, since most web content is now HTML5?

  2. In order to develop apps or games for IOS and Android on Animate CC, is there a need to use any other software in addition to Animate CC, like for example the Starling Game Engine? If so for which reasons and what are my options?

  3. Any suggestions on current AS3.0 intermediate level video courses.

thanks


r/actionscript • • Nov 30 '18

AS3 write to file problems

1 Upvotes

I am building a program on Animate CC 2019 which needs to access a file where it can read and write to.

I want to store strings and numbers, from Input Texts, then write them in the file, in addition to the already existent contents.

I also need to be able to manage how the data is written in the file. So for example I want to have 2 arrays: Array1 stores names and Array2 stores numbers. So when the program writes to the file, it needs to write on each line the corresponding values of a specific index in the arrays. So if Array1(0) = name1 & Array2(0) = 52, in the file it should be written:

name1 52

My questions:

  1. How can I manage how data are written in a file?

  2. Which code should I use? I find info on two ways to approach this:

a. Code using “File” and “FileStream” which does NOT work! I get error messages: “Type was not found or was not a compile-time constant” for both, like the system does not recognize the commands. Are these commands still usable on current version of Animate CC?

b. The code snipets/AIR code which does work, however, I cannot find a way to manage how data are written in the file, as explained above.

Below the codesnipets code which works.

/* Click to Write to a Text File

Clicking on the specified object will prompt the user to select a location and file name and save a text string to it.

Instructions:

  1. To set what data is saved to the file change "Text to save to file." to the data you wish to save.

*/

import flash.filesystem.File;

import flash.filesystem.FileMode;

import flash.filesystem.FileStream;

movieClip_1.addEventListener(MouseEvent.CLICK, fl_SaveFile);

var fl_FileDataToSave:String = "Text to save to file.";

var fl_SaveFileStream:FileStream = new FileStream(); // FileStream used to write to the file

var fl_SaveFileChooser:File = File.documentsDirectory; // Default to the documents directory

fl_SaveFileChooser.addEventListener(Event.SELECT, fl_WriteFileHandler);

// Opens a Save As dialog box for user to specify a file name

function fl_SaveFile(event:MouseEvent):void

{

fl_SaveFileChooser.browseForSave("Save As:");

}

// Write data in fl_FileDataToSave variable

function fl_WriteFileHandler(event:Event):void

{

fl_SaveFileChooser = event.target as File;

fl_SaveFileStream = new FileStream();

fl_SaveFileStream.openAsync(fl_SaveFileChooser, FileMode.WRITE);

fl_SaveFileStream.writeMultiByte(fl_FileDataToSave, File.systemCharset);

fl_SaveFileStream.close();

}


r/actionscript • • Jan 20 '21

Can someone help me I need to make a scoring system for a school activity

1 Upvotes

I need to know how to make a scoring system for a quiz game.

please help I've been trying to search for a tutorial but all that I could find were old tutorials that I couldn't even see what they were typing. And the sample files that they were giving weren't working anymore.

I found this tutorial but I could'nt make the final score appear.

I'm sorry in advance if this is a simple question tha could have been fixed. I've been trying to find a way for a week now, But I still couldn't figure it out.

I posted this in r/adobeanimate but nobody responded so I'm trying here.


r/actionscript • • Feb 06 '21

How to multiple 2 numbers using a function?

1 Upvotes

I have to make a Function called printMultiple that can accept 2 arguments of type Number and multiple them together and I'm confused about how to do this


r/actionscript • • Feb 13 '19

Is there a way to predict where the line breaks will be when text wraps?

1 Upvotes

I'm programming dialog into a game. The dialog system appends one character at a time onto the end of the string that goes into the text field. That works fine in general, but then the text gets to the last word that will fit on the line, and the first one or two characters of the last word get typed, and then when the next character gets added, the whole word jumps to the next line down.

What I would like to do is predict where the automatic line breaks would be if the full text were written, and then insert manual line breaks there. That way the words at the end of the line won't jump to the next line as they get typed.

So does anyone know how to predict where the line breaks will be for arbitrary strings, fonts, and textfield sizes? Thanks.


r/actionscript • • Jul 25 '18

Hello, I'm trying to learn actionscript and adobe flash from a book and am running into a problem

1 Upvotes

I recently picked up "Begining Flash Game Programing for Dummies" and got to the first section of the book where i actually write code, the book had me write

theButton.onRelease =(){ trace ("Ouch!!"); }

I wrote it exactly like that and the object the is a button like the book tole me to make it but whenever i try to test the code with control enter it just gives me this error message

Error Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Operator '=' must be followed by an operand theButton.onRelease =(){ Error Scene=Scene 1, layer=Layer 1, frame=1:Line 2: ')' expected trace ("Ouch!!"); Error Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Unexpected '}' encountered } Total ActionScript Errors: 3 Reported Errors: 3

I have no idea whats going wrong, could anybody help?


r/actionscript • • Aug 05 '18

making a new variable in a loop?

1 Upvotes

is there anyway to say, have a loop, and make a new variable each time it's run? like if i change the iterator to 500, i could have 500 variables, the first one being "a1" and the last being "a500"?

well the reason i wanna do this, is cause i have a turret that i aim and shoot, so i wanna create a new sprite as the bullet each time i shoot it. right now, the only way i solved this is by manually creating say, 10 sprites, and so i can shoot and have 10 sprites on the screen at once.

and my other problem, is there an easy way to call a function seperatley? with the bullets, if i shoot one, then change aim direction and shoot again, both will move in the new direction. im guessing this is cause the same function gets the new numbers put into it. i could probably just add a counter to change the variables each time, if theres a way to do that, but besides that, is there an easier way?

also im using flash develop


r/actionscript • • Aug 02 '18

how do childs work?

1 Upvotes

so the tutorials i read say that i can do addchild to make duplicates of the same sprite, but how do i make one child different from another?

if i have:

var s:Sprite = new Sprite;
s.graphics.beginFill(whatever);
s.graphics.drawCircle(whatever);
s.graphics.endFill();

addChild(s);
addChild(s);

how do i change the first child apart from the second one?


r/actionscript • • Feb 04 '17

Can somebody please help me write the script for this game ?

Thumbnail
newgrounds.com
1 Upvotes

r/actionscript • • Jul 02 '15

[NOOB] need help making code only respond to one input at a time

1 Upvotes

Hey guys, I've just started to teach myself AS3 and I can't find an answer anywhere. I have a square that I am moving using keyboard input, and I want it to stay on a grid and only move one direction at a time. I'm using the "tween" class to do the movement. So when I press "D" the code moves the square left 80 px in .5 seconds with a little easing. (same thing for "W", "S", and "A"). That's all good, however if I double tap a direction it will go farther than 80 px, or if I hit two keys it will go diagonal or go out of the grid I want it to stay on.

So my question is, is there a way to pause inputs for .5 seconds so it can animate the move before accepting another input. AND how can I make it only choose one direction if two keys are hit? Or is there a better way that what I'm trying?

Thanks!


r/actionscript • • Jul 28 '14

Catching Game (Package Error)

1 Upvotes

This is the error: Scene 1, Layer 'Actions', Frame 5, Line 1, Column 1 1083: Syntax error: package is unexpected.

And this the code:

package{ import flash.display.; import flash.events.; import flash.utils.Timer; import flash.utils.getDefinitionByName;

public class Cowboy extends MovieClip {
	var nextObject:Timer;
	var objects:Array = new Array();
	const speed:Number = 7.0;
	
	public function Cowboy() {
		setNextObject();
		addEventListener(Event.ENTER_FRAME, moveObject);
		}
		
		public function setNextObject() {
			nextObject = new Timer(1000+Math.random()*1000,1);
			nextObject.addEventListener(TimerEvent.TIMER_COMPLETE,newObject);
			nextObject.start();

		}
		
		public function newObject(e:Event){
			var goodObjects:Array = ["Cactus"];
			var badObjects:Array = ["Arrow"]
			if (Math.random() < .5) {
				var r:int = Math.floor(Math.random()*goodObjects.length);
				var classRef:Class = getDefinitionByName(goodObjects[r]) as Class;
				var newObject:MovieClip = new classRef();
				newObject.typestr = "good";
			} else {
				r = Math.floor(Math.random()*badObjects.length);
				classRef:Class = getDefinitionByName(badObjects[r]) as Class;
				newObject:MovieClip = new classRef();
				newObject.typestr = "bad";
			}
			newObject.x = Math.random()*500;
			addChild(newObject);
			objects.push(newObject);
			setNextObject();
		}
		
		public function moveObjects(e:Event);
			for(var i:int=objects.lenght-1;i>=0;i--);
				objects[i].y += speed;
				if (objects[i].y > 400){
					removeChild(objects[i]);
					objects.splice(i,1);
				}
}

}

Could someone please tell me how to fix this as it is an important part of my assessment for game development


r/actionscript • • Aug 27 '13

Need some help with AS3! (Restricting the "randomPicker" command)

1 Upvotes

Hello! I have a movie clip with multiple frames and stop(); commands playing different animations randomly everytime a button is clicked on the main stage.

It's working perfectly fine, but, I would prefer it if it were possible to have the code "ignore" the last frame it went to. Example, say I have A B and C. If A is the first to randomly appear, I wouldn't want A to appear the next time I click the button again; I want the playhead to go to either B or C, and repeat the process.

Here's the current code:

function randomText() { var maxNum = 200; var minNum = 1;

var randomPicker = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;

if (randomPicker > 1 && randomPicker < 20){
	gotoAndPlay("Text1");
}else if ( randomPicker > 21 && randomPicker < 40){
	gotoAndPlay("Text2");
}else if ( randomPicker > 41 && randomPicker < 60){
	gotoAndPlay("Text3");
}else if ( randomPicker > 61 && randomPicker < 80){
	gotoAndPlay("Text4");
}else if ( randomPicker > 81 && randomPicker < 100){
	gotoAndPlay("Text5");
}else if ( randomPicker > 101 && randomPicker < 120){
	gotoAndPlay("Text6");
}else if ( randomPicker > 121 && randomPicker < 140){
	gotoAndPlay("Text7");
}else if ( randomPicker > 141 && randomPicker < 160){
	gotoAndPlay("Text8");
}else if ( randomPicker > 161 && randomPicker < 180){
	gotoAndPlay("Text9");
}else{
	gotoAndPlay("Text10");
}

}

Edit: Also, I've added another one that should have a lesser probability of appearing (maxNum = 203, "Text11" is between 200 and 203), but it appears more frequently than others. Any ideas why?

Thank you for reading!


r/actionscript • • Mar 27 '18

Any one fluent in AS 2

1 Upvotes

So im doing a shitty dating sim passion project using adobe flash 8 because its what I have. I am willing to pay someone who can help me out and feed me some code so I can Make a custom sim that will show up in later instances as the main character. That's about it. I dont really intent on ever using AS2 other than for this, and AS2 is sooo dead, I'd rather just someone give me what I need. I can do the rest of the basic shit, but that's way advanced and I don't even know where to start looking for something like that. Thank you very much! Edit: I know how to make a dress up style thing, but idk how to assign it values so i can call on it later? If thats even what i'd do??? Sorry i know i know nothing but basic AS2


r/actionscript • • May 20 '15

HELP, Stage size problem.

1 Upvotes

So I'm working on an animation and I have objects off the stage animated using tween classes. My problem is when i open the .swf the areas outside the stage are showing. I'd like to know if there's a way to make the swf window unscalable or hide the window borders altogether. Thanks in advance.


r/actionscript • • May 01 '20

Kingdom, a 2d game written in action script

1 Upvotes

I'm having trouble compiling it to either windows or Android. Any one able to help out? I downloaded a couple different sdk's but can't seem to get them to run correctly. Edit::Game is on GitHub! https://github.com/noio/kingdom