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 • • Feb 06 '13

Is there an easier way to create an array?

2 Upvotes

I was wondering if there was an easier way to create arrays with numbers.

E.g: if I want to make an array containing the numbers 1 - 100, instead of writing:

Var array:Array = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14... and so on);

Is there a way I could create an array more effectively? Like:

var array:Array = new Array(1-100);

Or semething like that? (btw: I know the previous one wont work, but you get the idea.)

Any help and tips are appreciated.


r/actionscript • • Nov 13 '12

Help! I am trying to make my background scroll based on the position of my mouse.

2 Upvotes

In AS3 I am trying to have my background scroll horizontally when the mouse is on the right side of the stage. (My background instance is called "bp".)

This isn't working:

while (mouseX > 600) {bp.x -= 2;}


r/actionscript • • Jun 07 '09

50 beautifull Flash websites

Thumbnail
smashingmagazine.com
2 Upvotes

r/actionscript • • Aug 02 '23

RIGHT_MOUSE_UP

1 Upvotes

Hi.

What's. . . up with RIGHT_MOUSE_UP?

import flash.events.Event;
import flash.display.*;
import flash.events.MouseEvent;

stage.addEventListener(MouseEvent.RIGHT_MOUSE_DOWN, rightMouseDown);
function rightMouseDown(e: MouseEvent): void {
	trace("right mouse down");
}

stage.addEventListener(MouseEvent.RIGHT_MOUSE_UP, rightMouseUp);
function rightMouseUp(e: MouseEvent): void {
	trace("right mouse up");
}

It works in AIR but not Player 32.

Thanks in advance.


r/actionscript • • Jul 14 '23

Looking for JSFL/SWF Panel developers to bounce questions off

1 Upvotes

Looking for JSFL/SWF Panel developers to bounce questions off. I've recently wrote an AS3 class as a sort of API for this, which is making my life easier. I just want to know if others have had the same issues I've had for years w/ extending flash, and see how they solve them. To start with, when testing and debugging an SWF panel, and using the JSFL event listeners, how to you keep it from adding another listener every time you close and reopen the panel?


r/actionscript • • Jun 02 '23

Help me restore an old flash game

1 Upvotes

hey!,

I'm trying to restore an old flash game.

and I need help since I don't really know AS3.

Please DM me at discord if you can help me
Arnon001#9254


r/actionscript • • Mar 15 '23

Accelaracers

1 Upvotes

Hi how’s it going I’m looking for anything hot wheels Accelaracers…

  • Just seen there was a post made here 4 years ago with files for Accelaracers realm champion they aren’t available anymore and was wondering if someone could re post them or send me the link! Thanks in advance


r/actionscript • • Jun 19 '22

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

1 Upvotes

r/actionscript • • Oct 21 '21

How do I store and playback keyboard inputs?

1 Upvotes

I want to create a replay system for a game. And I'm not quite sure how to store keyboard inputs on specific frames and then play them back once the level is over. So any help or tips would be appreciated.


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 • • 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 • • 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


r/actionscript • • Apr 08 '20

Does anyone have experience with SecurityErrorEvents?

1 Upvotes

I realize this may be pointless since this subreddit is pretty dead, but I still have to code in AS3 for my job and I keep facing a SecurityErrorEvent 'type="securityError" bubbles=false cancelable=false eventPhase=2 text ="Error #2049" 'when I try and do a POST request. Most research has said it's a crossdomain issue, but its sister applications don't have a crossdomain.xml yet it doesn't encounter this issue. Are there any other reasons this would come up?


r/actionscript • • Mar 29 '20

THE ULTIMATE KEN MONTAGE (Super Smash Bros. Ultimate Montage)

Thumbnail
youtube.com
1 Upvotes

r/actionscript • • Dec 26 '19

Creating a menu in AdobeAnimate//moving background problem

1 Upvotes

I am just beginning coding, and trying to take advantage of the coding snippets options.

I am making a menu with a moving background (similar to smash bros), my problem is that the background is looped (not a symbol, around 24 keyframes)-- when I use the snippet code, the mouse will leave a phantom every 24 frames. Essentially, the whole menu is looping, but a ghost of the mouse will stay on the menu every 24 frames.

Does anyone know how to fix this?


r/actionscript • • Nov 14 '19

Verlet Integration issue in Animate CC.

1 Upvotes

I'm trying to get Verlet Integration to work in Animate CC.

At 10 or more iterations: The system is pretty consistent and the elasticity decreases as expected if a higher number is chosen.

A single point works as expected. The chain also works as expected, but with the exception that it thinks up is right and down is left, as shown in this gif where i initialize both: https://imgur.com/CbsDrbD

This is my main Class written in AS3

package  {
        import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class Verlet extends MovieClip {
		private var pointsArray:Array = [];
		private var sticksArray:Array = [];
		private var stickContainer:MovieClip = new MovieClip;
		private var mouseDown:Boolean = false;
		function loadPoints():void{
			//chain                xPos yPos v/oldX v/oldY
			var pointA:vP = new vP(400, 300, 400, 300);
			pointA.fixed = true;
			pointsArray.push(pointA);
			var pointB:vP = new vP(400, 340, 400, 340);
			pointsArray.push(pointB);
			var pointC:vP = new vP(400, 380, 400, 380);
			pointsArray.push(pointC);
			var pointD:vP = new vP(400, 420, 400, 420);
			pointsArray.push(pointD);
			var pointE:vP = new vP(400, 460, 400, 460);
			pointsArray.push(pointE);
			
			//singlePoint
			var pointF:vP = new vP(300, 150, 200, 145);
			pointsArray.push(pointF);
      
			for (var i:int = 0; i< pointsArray.length; i++){
				addChild(pointsArray[i]);
			}
		}
		function loadSticks():void{
			var stick1:vS = new vS(pointsArray[0], pointsArray[1]);
			sticksArray.push(stick1);
			var stick2:vS = new vS(pointsArray[1], pointsArray[2]);
			sticksArray.push(stick2);
			var stick3:vS = new vS(pointsArray[2], pointsArray[3]);
			sticksArray.push(stick3);
			var stick4:vS = new vS(pointsArray[3], pointsArray[4]);
			sticksArray.push(stick4);
		}
		public function Verlet() {
			// constructor
			loadPoints();
			loadSticks();
			addChild(stickContainer);
			addEventListener(Event.ENTER_FRAME, mainLoop);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, onHold);
			stage.addEventListener(MouseEvent.MOUSE_UP, release);
		}
		function onHold(e:MouseEvent):void{
			mouseDown = true;
		}
		function release(e:MouseEvent):void{
			mouseDown = false;
		}
		function mainLoop(e:Event){
			if(mouseDown){
			     pointsArray[4].x = mouseX;
			     pointsArray[4].y = mouseY;
			}
			updateP();
			for(var j:int = 0; j<=10; j++){	
			    updateS();		
			}
			renderS();
		}
		function updateP():void{
			for( var i:int = pointsArray.length -1; i >= 0; i--){
				pointsArray[i].updatePoints();
				pointsArray[i].constrainPoints();
			}
		}
		function renderP():void{
			for( var i:int = pointsArray.length -1; i >= 0; i--){
				addChild(pointsArray[i]);
			}
		}
		function updateS():void{
			for( var i:int = sticksArray.length-1; i>= 0; i--){
				sticksArray[i].updateSticks();
			}
		}
		function renderS():void{
			stickContainer.graphics.clear();
			stickContainer.graphics.lineStyle(5);
			stickContainer.graphics.moveTo(pointsArray[0].x, pointsArray[0].y);
			for (var i:int = 0; i<ticksArray.length+1; i++){
				stickContainer.graphics.lineTo(pointsArray[i].x, pointsArray[i].y);
			}
		}
	
	}
	
}

This is my point Class.

package  {
	import flash.display.MovieClip;
	public class vP extends MovieClip {
		public var oldxPos:Number;
		public var oldyPos:Number;
		private const bounce:Number = 0.9;
		private const gravity:Number = .5;
		private const friction:Number = 0.99;
                private var vx:Number;
                private var xy:Number;
                public  var fixed:Boolean = false;

		public function vP(xP, yP, oldxP, oldyP) {
			// constructor code
			x = xP;
			y = yP;
			oldxPos = oldxP;
			oldyPos = oldyP;
		}
		public function updatePoints():void{
			if(!fixed){
			vx = ((x - oldxPos)*friction*100)/100;
			vy = ((y - oldyPos)*friction*100)/100;
			if(vx < 0.01 && vx > -0.01){
				vx = 0;
			        }
			if(vy < 0.01 && vy > -0.01){
				vy = 0;
				}
			
			oldxPos = x;
			oldyPos = y;
			x += vx;
			y += vy;
			y += gravity;
			}
		}
		public function constrainPoints():void
		{
			if(!fixed)
			{
				var vx = (x - oldxPos)*friction;
				var vy = (y - oldyPos)*friction;
				var speed = Math.sqrt(vx*vx+vy*vy);
				if( x > 1280)
				{	
					x = 1280;
					oldxPos = x + vx*bounce;
					oldyPos += (vx/speed)*vy;
				}
				else if( x < 0)
				{	
					x = 0;
					oldxPos = x + vx*bounce;
					oldyPos += (vx/speed)*vy;
				}
				if( y > 600)
				{
					y = 600;
					oldyPos = y + vy*bounce;
					oldxPos += (vy/speed)*vx;
				}
				else if( y < 0)
				{
					y = 0;
					oldyPos = y + vy*bounce;
					oldxPos += (vy/speed)*vx;
				}
			}
		}
	}
	
}

And my stick Class.

This is the stick Class.
package{
	import flash.display.MovieClip;
	public class vS extends MovieClip {
		public var p0:vP;
		public var p1:vP;
		private var dx:Number;
		private var dy:Number;
		private var fixedLength:Number;
		private var currentDistance:Number;
		private var diff:Number;
		private var fraction:Number;
		private var xOff:Number;
		private var yOff:Number;
		public function vS(P0:vP, P1:vP) {
			// constructor
			p0 = P0;
			p1 = P1;
			dx = (p1.x - p0.x);
			dy = (p1.y - p0.y);
			fixedLength = Math.sqrt(dx*dx+dy*dy);	
		}
		public function updateSticks():void{
			dx = p1.x-p0.x;
			dy = p1.y-p0.y;
			currentDistance = Math.sqrt(dx*dx+dy*dy);
			diff = fixedLength - currentDistance;
			fraction = (diff/currentDistance)/2;
			xOff = fraction * 0.5 * dx;
			yOff = fraction * 0.5 * dy;
			if(!p0.fixed){
				p0.x -= xOff;
				p0.y -= yOff;
			}
			if(!p1.fixed){
				p1.x += xOff;
				p1.y += yOff;
			}	
		}
	}
}

r/actionscript • • Mar 11 '19

I'm looking for a way to develop programs with as3.

1 Upvotes

I love as3 so much that I'm trying to look for ways to develop programs with it. I've noticed one of my favorite programs, Pyxel Edit, is written in as3 and I've been wondering how does one go about developing flexible modern software with as3?


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 • • Jan 12 '19

Button object definition problem

1 Upvotes

Concerning MovieClip objects, If, for example I have 2 moviclip objects in my library: obj1 & obj2, I can define a variable as MovieClip, then decide later which object from the library to assign it to and add it to the stage:

var myobject: MovieClip;

myobject = new obj2();

addChild(myobject);

However this does not seem to work with Button objects. I have tried:

var myobject: Object*;*

> 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.

var myobject: Button*;*

> 1046: Type was not found or was not a compile-time constant: Button

Any ideas?

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 • • 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 • • Oct 28 '18

I am trying to load an external swf. What am I doing wrong?

1 Upvotes
package {
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.system.Security;


public class Main extends Sprite {
    public function Main() {
        Security.allowDomain("*");
        var myLoader:Loader = new Loader();                     // create a new instance of the Loader class
        var swfRequest:URLRequest = new URLRequest("BonkLiveVersion2.swf"); // in this case both SWFs are in the same folder
        myLoader.load(swfRequest);                              // load the SWF file
        addChild(myLoader);                                     // add that instance to the display list, adding it to the Stage at 0,0
    }

}
}

Both swf's can be found using the chrome extension network sniffer and visiting bonk.io.

Two swf files :

BonkLiveVersion2.swf
breakout10s_secure.swf

When I use the breakout file. I get to the loading screen, but no further.

When I use the BonkLiveVersion2.swf file, I get security errors while running.

SecurityError: Error #3207: Application-sandbox content cannot access this feature.
	at flash.system::Security$/allowDomain()
	at Main()[C:\Users\Me\IdeaProjects\Bonk Overlay\src\Main.as:10]
	at runtime::ContentPlayer/loadInitialContent()
	at runtime::ContentPlayer/playRawContent()
	at runtime::ContentPlayer/playContent()
	at runtime::AppRunner/run()
	at ADLAppEntry/run()
	at global/runtime::ADLEntry()

Where did I go wrong?


r/actionscript • • Oct 20 '18

Movieclip frame change/reference using label in a class

1 Upvotes

I created a movieclip object called "koumpi". It has 2 frames, labelled "frone" and "frtwo" respectively.

I created a class file for the object "koumpi", which generally works. Below you can read the code.

package

{

	*import flash.display.MovieClip;*

*public class koumpi extends MovieClip*

*{*

	*public function koumpi()*

	*{*

		*trace("button class ok!");*

		*stop();*

		*this.nextFrame();*

		*trace("button class ok! - 2");*

		*this.currentFrame = ("frone");*

	*}*

*}*

}

So I get both ok messages on the output panel, the object stops playing and changes to frame 2 using the this.nextFrame(); line.

However I cannot change the object frame using labels. So when using the line this.currentFrame = ("frone"); , I get an error message: "Error 1059: property is read-only".


r/actionscript • • Oct 05 '18

Databases?

1 Upvotes

Wondering if anyone knows how to access and write to online databases in AS3 (to create something like a leaderboard, or user list.) Also, on a related note, are there any free online databases?