Recent posts by Phantasmagoria on Kongregate

Subscribe to Recent posts by Phantasmagoria on Kongregate

Nov 17, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Applying blur filters in actionscript 3?

I haven’t worked with filters myself, but according to the documentation, you’re not applying the filter correctly. See here for explanation.

Also, there’s no need to create variables for values you use only once. Just create the filter like this:

var filter:BlurFilter=new BlurFilter(10,10,BitmapFilterQuality.HIGH);

If you’re only using the one filter, you can probably easily apply the filter like this:

bosses.filters = [filter];

Or, if you only use the filter once, this would work to both create and apply it:

bosses.filters = [new BlurFilter(10,10,BitmapFilterQuality.HIGH)];

 
Nov 17, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Learnig AS 3; so confusing!

AS3 uses x and y with no underscores, yes.

I’m so used to .NET and C# that I crave having this.Property = something as opposed to abstract things like x, y, _x, _y, etc.

I’m not sure what you mean by “abstract things” – x and y are properties of all display objects. Specifically, they’re defined in the DisplayObject class, which both MovieClip and Sprite inherit from.

 
Nov 13, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Games not playing in IE Flash Player 9

Using IE and the debug version of FP9, I get this error:

Error: Error #2134: Cannot create SharedObject.
	at flash.net::SharedObject$/getLocal()
	at GameEngine$cinit()
	at global$init()

…and then the game gets stuck in a way similar to what Kalinium described.

—-

@Koko: Game loads for me in IE/Vista/FP8, and then gets stuck on the start of the intro animation, flashing between loading/that. Right click→Forward gets it to the intro animation, again stuck in a loop of the intro. Right click→Forward again moves it to a purple screen.

This is most likely because Flash Player 8 doesn’t support AS3. While it may look the same superficially, I doubt it has anything to do with the “not loading” problem.

 
Nov 10, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Globally turning off music - AS3

However, it seems like I’d have to add an If in front of every play to do that.

One of the most basic techniques in programming is abstraction. Rather than repeating the same logic at multiple places to decide whether or not a sound should be played, you should create a function which takes a sound and determines whether or not to play it, and then use that function everywhere you want your code to play a sound. Something like this:

class MusicPlayer {
    static var musicon = true;
    static var currentmusic;

    public static function play(music) {
        if(musicon){
            if(currentmusic) currentmusic.stop();
            currentmusic = music.play();
        }
    }

    public static function mute() {
        if(currentmusic) currentmusic.stop();
        musicon = false;
    }

    public static function unMute() {
        musicon = true;
    }
}

With that code, the function MusicPlayer.play becomes an abstraction containing all the logic you need to play music. Elsewhere in your program, instead of repeating this logic, you simply use the abstraction:

MusicPlayer.play(new Tanto_Ruido());

Calling MusicPlayer.mute and MusicPlayer.unMute will turn off and on the ability to play music, and MusicPlayer.play will behave as it should.

That code isn’t perfectly suitable the way it is; for instance, it won’t automatically start playing the music again when it’s unmuted. But, hopefully, this will give you an idea of how to use abstraction to handle this and similar tasks in your program.

 
Nov 8, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / AS2 Attaching Movie Clips

Use localToGlobal. Something like this should do it, I think:

var BlueLaser = _root.attachMovie(“BlueLaser”,“BlueLaser” + _root.getNextHighestDepth(), _root.getNextHighestDepth());
var coords = localToGlobal( {x:0, y:0} );
BlueLaser._x = coords.x;
BlueLaser._y = coords.y;

That may be wrong. I haven’t tested it.

 
Nov 8, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / onBlur (when deactivated)

AS3 has the deactivate event, but I don’t know if there’s an AS2 equivalent.

 
Nov 8, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / AS2 Attaching Movie Clips

I’m not all that familiar with AS2, but at a cursory reading, it seems like your code should work fine except that it will place the new movieclip at the wrong coordinates, since you attach the new clip to the stage but place it using coordinates which are relative to HLaser1’s parent. Could this be the problem?

If it isn’t, well, add more traces and simplify your code so you can figure out exactly what’s working and what might not be doing what you expect it to. It’s better to track down the exact problem than to take a chunk of code and try to guess.

 
Nov 5, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Junior College Flash Animation Class

AS2 and AS3 are not really that different. Especially if you turn off AS3’s strict mode.

magick: If you want to make a game on your own, you’ll have to learn programming as well as animation. If you want the game to look pretty, chances are you’ll have to go above and beyond your class’s requirements for animation as well. And if you want it to be a good game, you’ll have to learn game design, which is something that practically no one teaches because it’s such a new discipline and not many people are at all familiar with it yet.

Making a good game will take a love of creating games (not just playing them), a willingness to go beyond the requirements and guidance set forth by your class(es), and the patience to keep working even if you don’t always feel motivated or inspired. If you go for it, I wish you luck.

 
Nov 3, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Multiple control schemes

Well, take the code you have that’s currently responsible for handling input from one control scheme.

Write a new version of that code which handles a different control scheme.

Then write code to set which input-handling code is used. If the input-handling code is properly encapsulated, this should be simple.

It’s hard to say anything more specific without knowing what your existing code is like.

 
Nov 2, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Beginning ActionScript, Without Flash CS3

What do you need that Adobe Flash-oriented tutorials don’t provide? Actionscript is Actionscript; you should be able to learn from any half-decent tutorials or other articles, and apply that knowledge with whatever tools you’re using.

Why don’t you go over that Hello World application line-by-line and research what everything does until you understand exactly how it works? Then think up something new, figure out how to add it, experiment… you’ll learn a lot if you keep at it, even if you can’t find any tutorials that are tailored to your exact needs.

 
Oct 24, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / AI Arrow Ballistics

If your physics are at all realistic, it’s somewhat more complicated than that, since the “amount moved down by the arrow per unit moved horizontally” is not constant – it depends on how fast the arrow is moving horizontally, which in turn depends upon the power and angle that the arrow is launched at. (If this were not true, then an archer could fire infinitely far with infinitesimal power, and an arrow fired straight up would never fall.) Still not a hard problem to solve if the arrow follows a simple parabolic path, but not quite that trivial.

 
Oct 24, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Question on screens and placement of objects

If it’s composed of linear chunks you probably won’t have much problem laying out the game along the timeline – just arrange it like a choose your own adventure book, e.g. “if(player jumps out of train to chase the rainbow) gotoAndStop(rainbow-chasing-chapter); else gotoAndStop(mundane-boring-life-chapter);”. Or whatever.

Personally, I think it would be simpler in FlashDevelop, but only if you’re already familiar with programming and can easily build a suitable system for the game. If you aren’t, which seems to be the case, the timeline and other basic tools that Flash provides will be good enough.

 
Oct 22, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Best way to dynamically link together a group of objects in ActionScript (2.0)?

since there are splice method in Array, then its too complex if you use linked list for simply groups some object.

Because everybody knows it doesn’t really matter if an operation is O(1) or O(n)! </sarcasm>

Josh: Still, it’s a decent example of how a linked list could be implemented, if you had to do it yourself. But since you found a library for AS2 you won’t have to.

…that said, looking at the contents of the libraries, I’m rather dismayed at how they implement linked lists. Both of them have one class for a list node and a separate class for the “entire” list… why? You can implement an entire list (and even trees) with just a list node class, and it’d probably be more convenient than their design.

 
Oct 22, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Question on screens and placement of objects

It’s one of those questions that doesn’t have just one answer. There are a lot of various ways to arrange things.

Personally, I work in Flash Develop and don’t use the timeline at all, so I’d just build a system of classes to display the right images and text at the right times based on the game’s data and on user input. Using the timeline to structure things could work, particularly if your game is more-or-less linear and thus can be represented in a movie-like structure, but I don’t know much about the details of such an implementation.

For the music, the class(es) you use to play it should have some functionality that you can control their volume with. Check the documentation.

 
Oct 22, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Best way to dynamically link together a group of objects in ActionScript (2.0)?

It’s entirely possible to use linked lists; you’ll just have to build them out of objects. This site has a whole bunch of data structures designed for AS3, and linked lists are simple enough that their implementation should work in AS2 as well with little or no modification.

Pointers don’t exist in Actionscript, yes, but that’s simply because Actionscript doesn’t allow C-like direct memory access. You can replicate 99% of the functionality of pointers with references and array indexes.

 
Oct 22, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Help with multi conditional if statement

Use <pre> </pre> tags to post code.

You don’t seem to understand the difference between the assignment operator (=) and the equality operator (==), since you use assignment in a place where equality would make a lot more sense. However, this wouldn’t change the result of your code. You also have mismatched parentheses, but I’m assuming they aren’t mismatched in your original program or it shouldn’t even compile.

What are you trying to do? The way you have it written now, it looks like you’re trying to make it trace “hello” whenever you press spacebar; however, due to your dismay at the program behaving like this, I imagine you have something else in mind for it.

 
Oct 21, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / [Solved] TimerEvent.Targets = what???

Moving the playFlow function to subclass of main script causes new problems….

So don’t move the whole function. Just create a small function which passes the necessary information along to your preexisting playFlow function.

 
Oct 21, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / This is all so confusing..

You can use another program to draw graphics and import them in Flash Develop.

 
Oct 20, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Function call

I’d have to see the code of that function to be sure, but it sounds like you’re misunderstanding how Actionscript is executed in Flash. Flash Player never “pauses” in the middle of running your code to wait for a button press, or anything else. You need to somehow set up your code so that it ends after it makes the window with the yes and no buttons appear, and make the buttons call another function (which contains all the code that should run after the choice is made) when they’re clicked.

 
Oct 16, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / AS3 - eventListener in a class?

Do note that all DisplayObjects have a stage property, which can be used to access the stage if the display object has been added to the display list. (If it hasn’t been added, the stage property will be null.) If you’re setting up the listener after adding the spaceship to the list, you won’t need to pass a stage reference to the spaceship.

 
Oct 16, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / How to use _currentframe

Equality tests if two things are identical, and returns true or false depending on the result. Assignment assigns the value on the right side to the place on the left side, and returns the value that was assigned.

In this case, your code is setting tile._currentframe to 2, and then returning 2 to the if statement. 2, naturally, is considered true, so the code within the if statement always runs.

(In Actionscript, false, null, void, undefined (oh the irony), 0, NaN, and "" are all considered false. Everything else is considered true.)

 
Oct 16, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / How to use _currentframe

In actionscript, == is the equality operator. = is the assignment operator. You’re using the wrong one.

Personally, I think = should be equality….

 
Oct 16, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Flashdevelop - graphics won't show [solved]

Actually, there is a plugin for FlashDevelop which makes normal traces show up. That’s what I use.

 
Oct 15, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Problems with textbox-rollOver relationship

I don’t see anything obviously wrong. I am somewhat unfamiliar with the nuances of AS2, though, and your description is a bit unclear in some parts.

Add some trace statements. Test if the on(rollOver) is getting called, test what the value of _root.changer is at that point in your code, and test if the code inside the if statement is running or not. Those should narrow it down for you.

 
Oct 15, 2008
avatar for Phantasmagoria Phantasmagoria 314 posts

Topic: Programming / Pixel-Copying Routine?

:)