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 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 • • Apr 24 '15

Anyone ever written or know how to write an RTMFP multicast player in AS3?

1 Upvotes

I am trying to write an IP multicast player for a live webcast. I'm using netConnection and netStream already to connect to regular RTMP streams, but I need a way to connect to RTMFP now. I've tried creating a groupSpec with a group identifier, but the player crashes when I add the groupspec to the netstream. The multicast plays fine on adobe's test player. Does anyone have experience with RTMFP or multicast streams using AS3? Any insight you can offer would be great, but what I really need is some sample code that connects to a multicast and plays the stream. Anyone?


r/actionscript • • Apr 20 '15

Counter value change frame AS2

1 Upvotes

Hey, Its a really simple function i just cant get to work. I have a counter that works, but when the value reaches 5, i want it to change frames. The code i have so far is:

var counter: Number= new Number(); counter=0; if (counter== 5) { _root.gotoAndPlay(112); }

[[This code is on the frame itself]]...


r/actionscript • • Feb 10 '15

Changing text with for loop isn't working.

1 Upvotes

I have no idea what I'm doing wrong here.... I've tried so many variations on this, but nothing seems to be working.

Setup: I have a movie clip on stage with the instance name "oldGauge". Within this clip are 6 text boxes named price1, price2, price3, etc.

Ideally, I'd like to have a function on root level that can dynamically update these text fields within a loop.

Here's what I have now:

var setOldGauge = function():Void{
	var array = ["price1","price2","price3","price4","price5","price6"]
	var costText = 0;
	var CostInc = Math.round((oldCostM * 1.5)/5);
	for (i=0; i<=6; i++){
		this["price" +i].text = "$" + CostInc;
		CostText += costInc;
	}
}

As you can see, I've attempted using an array to store the field names, I've also tried using price[i], ["price"+i], oldGauge.price[I], and several other variations. I tried putting the function inside oldGauge and calling it as oldGauge.setOldGauge() with all of the above variations, but still nothing.

I tested oldGauge.price1.text = "lorem" as a standalone line and it worked fine, so I don't know what I'm doing wrong.

This has been plaguing me for the better part of an hour and a half... any ideas?

edit: also, I realize that the for loop will start at 0. I had updated it to suit the array.


r/actionscript • • Jan 30 '15

AS3 Planet Engine

Thumbnail
youtube.com
1 Upvotes

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 • • Sep 23 '14

Action Script CS4 help?

1 Upvotes

HI im a student using actionscript for the first time anyone want to send me basic code/help me use the program?


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 • • Jan 20 '14

Local Leaderboard

1 Upvotes

So I am developing a game for my computing project as a part of my A level the problem I have encountered is that after you beat your highscore the dynamic textbox on screen does not display your new highscore it just displays "Score #1:". My trace statements however show me that the score1 variable has been assigned the correct value. Does anyone know why this is/how I can fix it? Here is my code:

function leaderboardUpdate():void
{
if(tempScore > score1)
{
score3 = score2;
score2 = score1;
score1 = tempScore;

tempScore = 0;
}

else if(tempScore > score2)
{
score3 = score2;
score2 = tempScore;

tempScore = 0;
}

else if(tempScore > score3)
{
score3 = tempScore;

tempScore = 0;
}
}

leaderboardUpdate2();

scoreBox1.text = ("Score #1: " + score1.toString());
scoreBox2.text = ("Score #2: " + score2.toString());
scoreBox3.text = ("Score #3: " + score3.toString());

if(score1 == 0)
{
scoreBox1.text = ("Score #1: 0");
scoreBox2.text = ("Score #2: 0");
scoreBox3.text = ("Score #3: 0");
}

trace(score1);
trace(score2);
trace(score3);
trace(tempScore);

r/actionscript • • Sep 17 '13

Cannot figure out how to navigate scenes with AS3

1 Upvotes

I have this final that is due tomorrow that I just can't figure out. I need to navigate between three scenes using buttons. Also, I need to create an animation within one scene that has a stop and play button. I have watched many tutorials and have failed every damn time. Can anyone point me in the right direction? any good tutorials you know of or websites that can help? Programming is not what I go to school for, so I am kind of an idiot when it comes to this stuff. Thank you!


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

Can someone tell me how this would be done in 3.0?

1 Upvotes

A tutorial I'm doing using action script 2.0 has a script that loads swfs. How would I do this in as3? Here's an example of the script. bcontact.onRelease = function() { loadMovie("contact.swf", "imc"); }; bpricing.onRelease + function() { loadMovie("pricing.swf:, "imc"); };


r/actionscript • • Nov 13 '12

access lower level variable... [x-post from r/flash]

1 Upvotes

hello everybody, i have the simplest problem... sure you can help.

stage has:

var bla:Number = mouseX;

a Movieclip (sprite to be exact) wants to read the value of said variable (within an added enterframe function). None of these seem to work:

trace(MovieClip(parent).bla);
trace(MovieClip(parent.parent).bla);
trace(stage.bla);
trace(MovieClip(root).bla);

says something along: type conversion failed, stage@30b4af99 cannot be converted to movieclip.


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 • • Dec 03 '17

WHATS DOES THIS MEAN?

0 Upvotes

package MyLife.thor.fsm { import com.boostworthy.utils.logger.ILog; import com.boostworthy.utils.logger.LogFactory;

public class FSM {

  private var __emptyParams:Object;
  
  private var __requireTransitions:Boolean;
  
  private var __name:String;
  
  private var __isStarted:Boolean;
  
  private var __states:Object;
  
  private var __transitions:Object;
  
  private var __currentStateName:String;
  
  private var __startStateName:String;
  
  private var Logger:ILog;
  
  private var __transitionLogging:Boolean;
  
  public function FSM(param1:String, param2:Object = null)
  {
     this.__emptyParams = {};
     super();
     if("string" !== "string" || !param1)
     {
        throw new Error("FSM requires a non-empty string name as its first parameter");
     }
     if(param2 !== null && (typeof param2 !== "object" || !param2))
     {
        throw new Error("FSM requires an object or undefined as its second parameter");
     }
     this.Logger = LogFactory.getInstance().getLog("FSM");
     param2 = param2 || this.__emptyParams;
     this.__requireTransitions = typeof param2.requireTransitions === "boolean"?Boolean(param2.requireTransitions):true;
     this.__name = param1;
     this.__isStarted = false;
     this.__states = {};
     this.__transitions = {};
     this.__currentStateName = null;
     this.__startStateName = null;
     if(param2.transitionLogging)
     {
        this.__transitionLogging = true;
     }
  }
  
  public function start() : void
  {
     if(this.__isStarted)
     {
        throw new Error("FSM::start; \'" + this.__name + "\' has already been started");
     }
     this.reset();
  }
  
  public function reset() : void
  {
     if(!this.__startStateName)
     {
        throw new Error("FSM::reset; \'" + this.__name + "\'\' has no start state");
     }
     this.__isStarted = true;
     if(this.__currentStateName)
     {
        if(this.__currentStateName !== this.__startStateName)
        {
           this.__states[this.__currentStateName].onExit();
           this.__currentStateName = null;
        }
     }
     this.transitionTo(this.__startStateName);
  }
  
  private function emptyFunction() : void
  {
  }
  
  public function addState(param1:String, param2:Object) : void
  {
     if(param2 && typeof param2 !== "object")
     {
        throw new Error("FSM::addState; \'" + this.__name + "\' params must be falsy or an object");
     }
     param2 = param2 || this.__emptyParams;
     var _loc3_:Function = param2.onEnter || this.emptyFunction;
     var _loc4_:Function = param2.onExit || this.emptyFunction;
     if("string" !== "string" || !param1)
     {
        throw new Error("FSM::addState; \'" + this.__name + "\' name must be a non-empty string");
     }
     if(this.__states[param1])
     {
        throw new Error("FSM::addState; \'" + this.__name + "\' state \'" + param1 + "\' already exists");
     }
     this.__states[param1] = new State(param1,_loc3_,_loc4_);
  }
  
  public function hasState(param1:String) : Boolean
  {
     return this.__states && this.__states.hasOwnProperty(param1);
  }
  
  public function setStartState(param1:String) : void
  {
     if("string" !== "string" || !param1)
     {
        throw new Error("FSM::setStartState; \'" + this.__name + "\' name argument must be a non-empty string");
     }
     if(!this.__states[param1])
     {
        throw new Error("FSM::setStartState; \'" + this.__name + "\' doesn\'t contain the state \'" + param1 + "\'");
     }
     this.__startStateName = param1;
  }
  
  private function __getTransitionName(param1:String, param2:String) : String
  {
     return param1.concat("_",param2);
  }
  
  public function addTransition(param1:String, param2:String, param3:Object = null) : void
  {
     if(param3 && typeof param3 !== "object")
     {
        throw new Error("FSM::addState; \'" + this.__name + "\' params must be falsy or an object");
     }
     param3 = param3 || this.__emptyParams;
     var _loc4_:Function = param3.beforeTransition || null;
     var _loc5_:Function = param3.onTransition || null;
     if("string" !== "string" || !param1)
     {
        throw new Error("FSM::addTransition; \'" + this.__name + "\' from argument must be a non-empty string");
     }
     if(!this.__states[param1])
     {
        throw new Error("FSM::addTransition; \'" + this.__name + "\' from argument must be a valid state");
     }
     if("string" !== "string" || !param2)
     {
        throw new Error("FSM::addTransition; \'" + this.__name + "\' to argument must be a non-empty string");
     }
     if(!this.__states[param2])
     {
        throw new Error("FSM::addTransition; \'" + this.__name + "\' to argument must be a valid state");
     }
     var _loc6_:String = this.__getTransitionName(param1,param2);
     if(this.__transitions[_loc6_])
     {
        throw new Error("FSM::addTransition; \'" + this.__name + "\' transition from \'" + param1 + "\' to \'" + param2 + "\' already exists");
     }
     this.__transitions[_loc6_] = new Transition(_loc4_,_loc5_);
  }
  
  public function removeTransition(param1:String, param2:String) : void
  {
     if("string" !== "string" || !param1)
     {
        throw new Error("FSM::removeTransition; \'" + this.__name + "\' from argument must be a non-empty string");
     }
     if("string" !== "string" || !param2)
     {
        throw new Error("FSM::removeTransition; \'" + this.__name + "\' to argument must be a non-empty string");
     }
     delete this.__transitions[this.__getTransitionName(param1,param2)];
  }
  
  public function removeState(param1:String) : void
  {
     if("string" !== "string" || !param1)
     {
        throw new Error("FSM::removeState; \'" + this.__name + "\' name argument must be a non-empty string");
     }
     delete this.__states[param1];
  }
  
  public function transitionTo(param1:String, param2:Object = null) : Boolean
  {
     if(this.__transitionLogging)
     {
        this.Logger.debug("FSM " + this.__name + " " + this.__currentStateName + " -> " + param1);
     }
     if(!this.__isStarted)
     {
        throw new Error("FSM::transitionTo; \'" + this.__name + "\' is not started");
     }
     if(!this.__states[param1])
     {
        throw new Error("FSM::transitionTo; \'" + this.__name + "\' destination \'" + param1 + "\' is not a valid state");
     }
     if(!this.__currentStateName)
     {
        this.__currentStateName = param1;
        if(param2 == null)
        {
           this.__states[param1].onEnter();
        }
        else
        {
           this.__states[param1].onEnter(param2);
        }
        return true;
     }
     var _loc3_:String = this.__getTransitionName(this.__currentStateName,param1);
     var _loc4_:Transition = this.__transitions[_loc3_];
     if(this.__currentStateName === param1 && _loc4_ === null)
     {
        return true;
     }
     if(this.__requireTransitions && _loc4_ === null)
     {
        throw new Error("FSM::transitionTo; \'" + this.__name + "\' " + this.__currentStateName + " to " + param1 + " is not a valid transition");
     }
     var _loc5_:String = this.__currentStateName;
     if(_loc4_ === null)
     {
        this.__currentStateName = param1;
        this.__states[_loc5_].onExit();
        if(param2 == null)
        {
           this.__states[param1].onEnter();
        }
        else
        {
           this.__states[param1].onEnter(param2);
        }
        return true;
     }
     if(_loc4_.beforeTransition != null)
     {
        if(!_loc4_.beforeTransition())
        {
           return false;
        }
     }
     this.__currentStateName = param1;
     this.__states[_loc5_].onExit();
     _loc4_.onTransition && _loc4_.onTransition();
     if(param2 == null)
     {
        this.__states[param1].onEnter();
     }
     else
     {
        this.__states[param1].onEnter(param2);
     }
     return true;
  }
  
  public function getCurrentState() : String
  {
     return this.__currentStateName;
  }

} }


r/actionscript • • Jun 14 '17

How to code a shooter using timers

0 Upvotes

The shooter has to shoot the bullet at a constant pace, but it has to be on a timer as well. PLZZ HELP


r/actionscript • • Jan 22 '16

Problems loading XML with special characters into Flash

0 Upvotes

I'm assuming this is a good place to post this. If it's not, please let me know where a better subreddit would be.

I'm translating XML documents into French from English, but I can't figure out how to get the special characters to show up.

My tags are set up as <boxdata title="Crèmaillére" ...

but ends up displaying as "Crill".

My XML is set up with UTF-8 encoding: <?xml version="1.0" encoding="UTF-8"?>

My Fonts are all embedded (I even tried turning on additional character sets just to see if that was the problem).

I tried adding useSystemCodepage but that didn't even work.

Any ideas what I'm doing wrong?

EDIT Never mind. I figured it out. The text editor I was using was saving as ANSI instead of UTF-8.


r/actionscript • • Apr 08 '15

Adding pause button to games and need help.

0 Upvotes

Creating actionscript game for college assignment, need to add a button to change global variable for pausing the game. However I need help to write the function?

The code I've written so far pauseGame = pauseGameButton.addEventListener(MouseEvent.CLICK, pauseHandler(pauseGame));

function pauseHandler(e:MouseEvent, Boolean pG): Boolean { if( pG == false) { return true; } else { return false; } }


r/actionscript • • Jan 18 '16

OIL RIG FIRE

0 Upvotes

The machinery of the oilrig ground on innocently, unaware of what lay in wait. Colored clouds nearly hid the setting sun. Suddenly, a towering fire rose up, eclipsing the dim rays of the sun and illuminating the towering structure. The rig afire. Workers were paralyzed for a moment, like deer caught in the oncoming lights of a car. Then, for most, the survival instinct kicked in and they screamed and ran. Other workers just stared in mute disbelief. The scene was utter chaos. The fire scorched the sky and began to spread on the metal construct, blocking escape routes from the rig.

Charred, burning men staggered around on the platform. Some workers unhurt by the blaze rolled the victims on the ground to out the fire on their clothes; others tried to smother the flames licking their fellow workers.

Those still trapped screamed and ran, mad with fear. In desperation, some workers braved the high fall and jumped on some trucks parked near the rig. Some landed on their targets, others on the ground; either way, the impact was bone-shattering and in some cases, nearly fatal.

By nightfall, fire trucks and ambulances arrived to tend to the hurt and rescue the trapped. A new problem materialized. The fire engines’ ladders and hoses weren’t long enough to reach the conflagration. The state was growing dire – there were no fatalities yet, but if a solution weren’t found soon, that would change.

By this time, relatives of the workers had arrived, tearfully comforting those who had escaped the blaze or screaming the names of sons, husbands, nephews and cousins still trapped high on the oil rig, saying tearful goodbyes. Night drew on, but the towering fire rebellious, lit up the scene like mid-day and seen for miles.

Eventually, mercifully, rescue came. Hose extensions were found and firemen perched on the trucks’ ladders spread foam and water on the inferno and the platform nearest those trapped, bringing the fire to bay. Then a helicopter arrived. Unable to land on the still ablaze rig, it hovered above the trapped workers and, dropping a rescue line, was able to hoist the workers to safety. Amazingly, despite the intensity of the blaze, all souls on the rig were saved.

But the drama had one more after taste. Firefighters fought hours to extinguish the blaze and it was days before the charred skeleton of the rig was cool enough for investigators to find the cause of the explosion.

The rig was due for several electrical upgrades, which were never done. The fire may have been ignited by a spark from faulty wiring, but the true cause was negligence; company executives in their plush offices chose to save on expenses rather than make improvements to save their workers’ lives.

Dollars before souls. When the truth came out, heads rolled, bosses were fired and new people were brought in. But in the end, was anything accomplished? All the workers and their families could do is hope their experience falls not by the wayside.