• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

injurai

Banned
VS is actually one of the more 'easier' ones. It's just mainly not used for more experienced C++ programmers. I would have a look at VS and also Code::Blocks.

Hmm ok, I'll give it a try. It just seems lees intuitive than eclipse and java, which is my only experience with an IDE.
 

Spoo

Member
I think the question "Hey, I want to learn how to program! What do I start with?" is typically the wrong question to ask.

It's more important to be interested in making something; anything, that would impossible to create without programming ability, and then to thoroughly investigate that part of the programming world either in tandem with CS coursework, or to be aware that the "theory" of CS is out there, and that there are resources that exist for that.

I know you can go your entire programming career (professional or hobbyist) without being exposed to the "bits" as I like to call it (lower level programming, academic programming, theory) and be perfectly content with your knowledge so long as what you are trying to do is often "solved problem programming" -- that is, you aren't expected to do anything for which there are few resources available to help you with. Or none, for that matter.

I think you can become an accomplished web programmer, or "retro game coder", or software engineer by picking a book that gets you started on that topic, and letting the author's choice of language be your entry -- assuming the book doesn't take the approach that you've programmed before.

On the other hand, there are certain fields where not just anyone can reasonably be expected to go off and do things effectively without having a heavy list of per-requisites met, and this generally includes a lot of academic know-how (Data structures, algorithms, those kinds of things), a strong grasp on mathematics, and simply a lot of experience. These are the kinds of things where a very specific skill-set comes into play, and that's the kind of skill-set that one gets from a long period of study, exploration, and failing enough that they've learned how to succeed. The point of a CS degree, in my opinion, is to help programmers become aware of problem-solving techniques that have existed in theory since before you could write code to do it! These are things where you run into a problem and say "Ah! I've seen this before!" or "I've been here before" and you instinctively know the tool for the job, and the theory cements your rightness about the choice for the direction you take on solving that problem. Maybe you haven't seen the problem before, and you can take an amalgam of other things which form a "new" solution. All of this is a result of learning how to be a "thinking" programmer. a White-box programmer instead of a Black-box one. Heavy academics and training can help here.

So the question of "learning to program" is faulty by nature of the beast. Some people want to learn enough to get done a particular task, others are much more dedicated to the field itself and want to know the ins-and-outs. I've been programming for 8 years, and I never feel like I know enough, and I'm always catching mistakes that academics tried (and continue to try) to drill out of my head, and in my spare time I'm generally experimenting with mathematics, and games programming, and just constantly learning. I learn something new nearly every day, and it gets me thinking about things I couldn't do in the past that I may be able to do later.

The greatest singular piece of advice I could give to another learning programmer (and you should always be learning) is to, when you are ready, teach. Learning by teaching is one of the most powerful tools, I think, so if you have the option to TA, or something, do it. If you have a friend who wants to learn how to code, and you just started, "act as if" and help him learn. Get involved with other people who program, and share what you know, and learn from them. Try to forget about language rivalries, and other things that aren't at the core of the (loosely defined) science.

And obviously write code a lot. Don't ever turn down writing something because you think you can do it; write it, so that you know you can. The small skills and insights you develop from writing the simplest of things can stick with you forever.
 

The Technomancer

card-carrying scientician
Okay, incredibly stupid question time: I've been doing some complex programming for so long that I've completely forgotten the stupidly simple stuff, to the point where I can't figure out how to stop
Code:
#include "stdafx.h"
#include <iostream>


int _tmain(int argc, _TCHAR* argv[])
{
	using namespace std;
	cout << "test" << endl;
	return 0;
}
from terminating imminently. I just want the terminal window to stay up with "test" displayed.

EDIT: In C++
 
Okay, incredibly stupid question time: I've been doing some complex programming for so long that I've completely forgotten the stupidly simple stuff, to the point where I can't figure out how to stop
Code:
#include "stdafx.h"
#include <iostream>


int _tmain(int argc, _TCHAR* argv[])
{
	using namespace std;
	cout << "test" << endl;
	return 0;
}
from terminating imminently. I just want the terminal window to stay up with "test" displayed.

EDIT: In C++

cin.get(); forces you to push enter and is cross platform.

Windows specific - system("pause");
 

Septimius

Junior Member
Hmm ok, I'll give it a try. It just seems lees intuitive than eclipse and java, which is my only experience with an IDE.

I recently started using Visual Studio, coming from Eclipse. VS is a lot more thorough, I'd say. Less intuitive, maybe, but it is a way bigger system. Debugging works like it always did in Eclipse, and intellisense is fantastic.
 

IceCold

Member
Okay, incredibly stupid question time: I've been doing some complex programming for so long that I've completely forgotten the stupidly simple stuff, to the point where I can't figure out how to stop
Code:
#include "stdafx.h"
#include <iostream>


int _tmain(int argc, _TCHAR* argv[])
{
	using namespace std;
	cout << "test" << endl;
	return 0;
}
from terminating imminently. I just want the terminal window to stay up with "test" displayed.

EDIT: In C++

Are you using visual studios? Just run the code in debug mode.
 
Hello, Programming-GAF!

Just graduated on Sunday with a BS in Computer Science! Now for the job hunt.

I'm a little worried, I've never done large scale programming before. Just class projects and an internship. Any advice on the things I should emphasize in a interview for a software engineering position?
 

injurai

Banned
Okay, incredibly stupid question time: I've been doing some complex programming for so long that I've completely forgotten the stupidly simple stuff, to the point where I can't figure out how to stop
Code:
#include "stdafx.h"
#include <iostream>


int _tmain(int argc, _TCHAR* argv[])
{
	using namespace std;
	cout << "test" << endl;
	return 0;
}
from terminating imminently. I just want the terminal window to stay up with "test" displayed.

EDIT: In C++

Are you using visual studios? Just run the code in debug mode.

ctr-F5 i believe
 

BlueMagic

Member
I consider myself to have a fairly basic game development knowledge. But I still would love books on basic game development (I read a little from Game Engine Architecture and thought it was quite good, but it still focuses a lot on advanced AAA game engines), so if you know any, let me know!
Also Game AI by Example is great.
 

Misguided

Banned
Wow, the existence of this thread right now is too convenient.

Is anyone good with ActionScript 3? Basic stuff, I know, but I'm having a bit of an issue.

So, I have this code in my class:

Code:
package
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	
	[SWF(width="550", height="400", backgroundColor = "#FFFFFF", frameRate ="60")]
	
	public class Ball extends MovieClip
	{
		public var ball:MovieClip = new MovieClip();
		public var vx:int = 0;
		public var vy:int = 0;
		
		public function Ball()
		{
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
			stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
			
			stage.addChild(ball);
			ball.x = 350;
			ball.y = 250;
		}
		public function keyDownHandler(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.LEFT)
			{
				vx = -5;
			}
			else if (event.keyCode == Keyboard.RIGHT)
			{
				vx = 5;
			}
			else if (event.keyCode == Keyboard.UP)
			{
				vy = 5;
			}
			else if (event.keyCode == Keyboard.DOWN)
			{
				vy = -5;
			}
		}
		public function keyUpHandler(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.LEFT || event.keyCode == Keyboard.RIGHT)
			{
				vx = 0;
			}
			else if (event.keyCode == Keyboard.UP || event.keyCode == Keyboard.DOWN)
			{
				vy = 0;
			}
		}
		public function enterFrameHandler(event:Event):void
		{
			ball.x += vx;
			ball.y += vy;
		}
	}
}

In this class I of course have my ball variable with the defined keyboard movements, and syntax is correct. But I'm having trouble actually getting this into my movieclip. Whenever I try this code:

Code:
import Ball;
var ball:Ball = new Ball();
stage.addChild(ball);

I get this error:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Ball()
at Untitled_fla::MainTimeline/frame1()

Could anybody lend me some assistance? Thanks so much.
 

Septimius

Junior Member
Wow, the existence of this thread right now is too convenient.

Is anyone good with ActionScript 3? Basic stuff, I know, but I'm having a bit of an issue.

So, I have this code in my class:

<snip>

In this class I of course have my ball variable with the defined keyboard movements, and syntax is correct. But I'm having trouble actually getting this into my movieclip. Whenever I try this code:

Code:
import Ball;
var ball:Ball = new Ball();
stage.addChild(ball);

I get this error:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Ball()
at Untitled_fla::MainTimeline/frame1()

Could anybody lend me some assistance? Thanks so much.

In the Ball-class constructor, you call "stage.addChild(ball);":

Code:
		public function Ball()
		{
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
			stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
			
			[B]stage.addChild(ball);[/B]
			ball.x = 350;
			ball.y = 250;
		}

if you wanted to do this here, not knowing Action Script, it might be stage.addChild(this);, but I'm guessing you didn't mean to call that there, since you make the same call later, the appropriate way
 

Misguided

Banned
In the Ball-class constructor, you call "stage.addChild(ball);":

Code:
		public function Ball()
		{
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
			stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
			
			[B]stage.addChild(ball);[/B]
			ball.x = 350;
			ball.y = 250;
		}

if you wanted to do this here, not knowing Action Script, it might be stage.addChild(this);, but I'm guessing you didn't mean to call that there, since you make the same call later, the appropriate way

Thanks for the advice, but I'm still confused. Can you tell me how I should rework this code for the ball variable to not be null? Sorry if I'm asking a bit too much.
 

The Technomancer

card-carrying scientician
So I need to generate a lot of random numbers basically instantaneously, so using time as the seed isn't going to work. Anyone got any suggestions for how to generate seeds?

EDIT: I may not have thought this through...
 

usea

Member
Thanks for the advice, but I'm still confused. Can you tell me how I should rework this code for the ball variable to not be null? Sorry if I'm asking a bit too much.
I'm not an actionscript expert, but I see a few odd things.

Your Ball class extends MovieClip, but it also contains a MovieClip. Why is that?

You're adding your class-level variable "ball:MovieClip" to the stage in the Ball constructor. Then you're also adding ball:Ball to the stage? Why both?

It seems to me you should drop the ball:MovieClip variable in your Ball class entirely, and naturally don't add it to the stage.

However, I don't know why you're getting a null object in Ball(). I'm pretty sure that the ball:MovieClip variable should get initialized before the constructor, so it seems weird to me. If you're really going to keep your class-level MovieClip variable, try initializing it in the constructor instead like this:
Code:
public class Ball extends MovieClip
{
	public var ball:MovieClip;
	public var vx:int = 0;
	public var vy:int = 0;
	
	public function Ball()
	{
		this.ball = new MovieClip();
	
		stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
		stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
		stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		
		stage.addChild(ball);
		ball.x = 350;
		ball.y = 250;
	}
...
But again, I think you're getting confused with both inheriting and composing a MovieClip and adding both to the stage.



So I need to generate a lot of random numbers basically instantaneously, so using time as the seed isn't going to work. Anyone got any suggestions for how to generate seeds?

EDIT: I may not have thought this through...
You should not re-seed your random generator every time you want a number. Seed it once (probably way earlier, like when the program first runs) and then when you want your random numbers, just get them. Don't re-seed.

In C#:
Code:
var rgen = new Random(); //<--this seeds with the time. Do this at some point separate from actually needing the numbers.

//later on:
var numbers = new List<double>();
for (int i = 0; i < 100000; i++)
{
	numbers.Add(rgen.NextDouble());
}
//now numbers contains a list of 100,000 random doubles.
 

Misguided

Banned
I'm not an actionscript expert, but I see a few odd things.

Your Ball class extends MovieClip, but it also contains a MovieClip. Why is that?

You're adding your class-level variable "ball:MovieClip" to the stage in the Ball constructor. Then you're also adding ball:Ball to the stage? Why both?

It seems to me you should drop the ball:MovieClip variable in your Ball class entirely, and naturally don't add it to the stage.

However, I don't know why you're getting a null object in Ball(). I'm pretty sure that the ball:MovieClip variable should get initialized before the constructor, so it seems weird to me. If you're really going to keep your class-level MovieClip variable, try initializing it in the constructor instead like this:
Code:
public class Ball extends MovieClip
{
	public var ball:MovieClip;
	public var vx:int = 0;
	public var vy:int = 0;
	
	public function Ball()
	{
		this.ball = new MovieClip();
	
		stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
		stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
		stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		
		stage.addChild(ball);
		ball.x = 350;
		ball.y = 250;
	}
...
But again, I think you're getting confused with both inheriting and composing a MovieClip and adding both to the stage.

You're definitely right that the variable should (does) get initialized before the constructor.

So the Ball() class extends MovieClip; does that mean that it's not supposed to contain variables that are made into MovieClips? I'm confused...

I tried not adding my ball to the stage from the class file, only from the timeline actions, but it still isn't working.

But I'm still having troubles; this is of course very confusing for you as it is for me. Thanks again for all your help.

BTW: Alone that code in the class executes and works perfectly; it's just calling it into the stage that I'm really having trouble with, for some reason.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
When you say "Ball extends MovieClip", it means your ball is a MovieClip and possesses all its properties and methods. You don't need to include another MoveClip object inside the ball unless you want parented MovieClips.

So if somewhere else in the code you have something like:

Code:
Ball testBall = new Ball();

You can manipulate it as though it was a generic MovieClip using properties like testBall.x or methods like testBall.gotoAndPlay().

So cutting out the redundancies in your code, it would look like:

Code:
public class Ball extends MovieClip
{
	public var vx:int = 0;
	public var vy:int = 0;
	
	public function Ball()
	{
		x = 350;
		y = 250;
	}
...
 

usea

Member
You're definitely right that the variable should (does) get initialized before the constructor.

So the Ball() class extends MovieClip; does that mean that it's not supposed to contain variables that are made into MovieClips? I'm confused...

I tried not adding my ball to the stage from the class file, only from the timeline actions, but it still isn't working.

But I'm still having troubles; this is of course very confusing for you as it is for me. Thanks again for all your help.
You can put a movieclip as a variable of a class that extends movieclip if you want. It's just, I had a feeling that it wasn't your intention. It would seemingly result in two balls for each Ball object. But I'm no actionscript expert.

Let's start from scratch.

The error is that you have some null variable which has one of its methods or properties referenced. You need to track down exactly what line is calling a method/property on a null variable, and then find out why that variable is null when you expect it not to be.

Google tells me that you can do this to find out the line number in flash professional:
click file > publish settings > flash > tick "permit debugging" > ok
Is that what you're using? You mentioned timeline so I assume so.

Then, you'll have a stack trace after the error like this, which says where the error is coming from:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/frame1()[Untitled_fla.MainTimeline::frame1:5 8]
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at flash.display::MovieClip/gotoAndPlay()
at player1_fla::MainTimeline/nextsong()[Untitled_fla.MainTimeline::frame1 :15]
But this is where I get lost because I don't understand frames, timelines, etc. I've only done pure actionscript code in an IDE like flash develop. Posting the full stack trace will probably help though.

Also if you just google the error and look at some of the results, they have common problems and solutions that cause this error to crop up.
 

Misguided

Banned
When you say "Ball extends MovieClip", it means your ball is a MovieClip and possesses all its properties and methods. You don't need to include another MoveClip object inside the ball unless you want parented MovieClips.

So if somewhere else in the code you have something like:

Code:
Ball testBall = new Ball();

You can manipulate it as though it was a generic MovieClip using properties like testBall.x or methods like testBall.gotoAndPlay().

So cutting out the redundancies in your code, it would look like:

Code:
public class Ball extends MovieClip
{
	public var vx:int = 0;
	public var vy:int = 0;
	
	public function Ball()
	{
		x = 350;
		y = 250;
	}
...

Thank you for your reply. Now, I have one more question that I'm having trouble with; how do I get this (that is, the ball) into the timeline code and then into the stage? I know that for the code in the timeline I need something like:

Code:
import BallKeyboard(the name of my class);

...but I'm not really sure where to go from there. Thanks again.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
Have you linked your ball class to your .fla document? I think that's the missing step and now that I look over your original question I think that's what you were asking in the first place.

You can find the tutorial here: http://active.tutsplus.com/tutorials/actionscript/quick-tip-how-to-use-a-document-class-in-flash/

Basically, it designates one of your source files as the "Main" class and will initialize an instance of those upon playback. In that class, you will initialize all your other classes, and add them to the stage. The reason why stage.addChild(ball); doesn't work with your class is because the environment isn't even calling it, only the "Main" class has direct access to the stage supervariable.

The Main class should, if I remember correctly, always extend a DisplayObject or a class that inherits from DisplayObject, since the program will be calling the draw method of that DisplayObject every frame. Usually it's a MovieClip but Sprites also work, although to get animation working with Sprite objects you need to jump through a lot of hoops.

And yes you can have MovieClip objects in other MovieClip objects. My confusion was thinking that your Ball class was supposed to represent a ball, though I now realize it is intended to be your "Main" class.
 

santouras

Member
PHP coder for about 10 years here, do want to learn a bit of python as well. Just want to throw my support behind Sublime as well. Most amazing text editor I've used. I can't code in it full time because of the lack of code completion over projects - it has a plugin but crashes indexing large projects - which keeps me going back to eclipse, but man, I love this thing so much. Git support, Gist support, PHPUnit plugins, there are just so many amazing plugins for this.
 

tokkun

Member
Assembly for life!

I learned x86 and x51 assembly, and in retrospect they were both mostly a waste of time unless you end up working in a really niche area.

I think the problem is that nowadays (at least for x86), the semantic gap between assembly and the microcode the architecture is designed around is pretty large, so you really don't learn as much about the architecture or optimization principles as you might think. The thing that is probably still a good takeaway is drilling in the idea of the overhead of a function call.
 

Misguided

Banned
Have you linked your ball class to your .fla document? I think that's the missing step and now that I look over your original question I think that's what you were asking in the first place.

You can find the tutorial here: http://active.tutsplus.com/tutorials/actionscript/quick-tip-how-to-use-a-document-class-in-flash/

Basically, it designates one of your source files as the "Main" class and will initialize an instance of those upon playback. In that class, you will initialize all your other classes, and add them to the stage. The reason why stage.addChild(ball); doesn't work with your class is because the environment isn't even calling it, only the "Main" class has direct access to the stage supervariable.

The Main class should, if I remember correctly, always extend a DisplayObject or a class that inherits from DisplayObject, since the program will be calling the draw method of that DisplayObject every frame. Usually it's a MovieClip but Sprites also work, although to get animation working with Sprite objects you need to jump through a lot of hoops.

And yes you can have MovieClip objects in other MovieClip objects. My confusion was thinking that your Ball class was supposed to represent a ball, though I now realize it is intended to be your "Main" class.

So if I have my main class extending DisplayObject, will I even need to have any more code/functions in my main class? As long as I have my public class Ball extending Main, which extends DisplayObject, I should be fine, right? Or am I missing something?
 

Luigiv

Member
I learned x86 and x51 assembly, and in retrospect they were both mostly a waste of time unless you end up working in a really niche area.

I think the problem is that nowadays (at least for x86), the semantic gap between assembly and the microcode the architecture is designed around is pretty large, so you really don't learn as much about the architecture or optimization principles as you might think. The thing that is probably still a good takeaway is drilling in the idea of the overhead of a function call.

You're taking me way too seriously, I was just kidding. :p

I only vaguely know MIPS Assembly, personally. Don't know a damn thing about X86 assembly.
 

usea

Member
I learned x86 and x51 assembly, and in retrospect they were both mostly a waste of time unless you end up working in a really niche area.

I think the problem is that nowadays (at least for x86), the semantic gap between assembly and the microcode the architecture is designed around is pretty large, so you really don't learn as much about the architecture or optimization principles as you might think. The thing that is probably still a good takeaway is drilling in the idea of the overhead of a function call.
I think it's very useful for having a general model of the process in your head, even if it's not precise to the architecture you're running on. Without a mental model, it can be hard to grasp why one thing is slower than another, or what is actually going on behind the scenes.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
So if I have my main class extending DisplayObject, will I even need to have any more code/functions in my main class? As long as I have my public class Ball extending Main, which extends DisplayObject, I should be fine, right? Or am I missing something?
Yes you should be fine, although the class you designate as your Document class does not have to be called "Main", it could be called anything. And your Ball class does not have to extend Main. What it does need to do is be in the same folder as your Main class so your Main class knows where to find the Ball.as source file.

So for example, you could type Ball.as in that textbox in the Document properties, and if your folders are set up the right way, your .fla file will look for Ball.as upon compiling, and then initialize an object of type Ball on playback and then add that to the stage. Or if you have another class, say, BallTest, you can set that as the Document class. In the BallTest constructor you would have lines like.

Code:
Ball ball1 = new Ball();
addChild(ball1);
You don't need to write stage.addChild() because BallTest is automatically added to the stage as the Document class.

You don't need any additional functions in your Document class, although you can always add them as desired. The .fla will automatically call the constructor of its Document class (if any) and nothing else, other methods will have to be called manually within the class.

At the minimum, this is all the code you'll need in order to get a ball onto your stage and moving forward every frame.
Code:
package
{
	import flash.display.*;
	
	public class Main extends MovieClip
	{
                private var:Ball ball1;

		public function Main()
		{
			ball1 = new Ball();
                        addChild(ball1);
                        addEventListener(Event.ENTER_FRAME, frameLoop);
		}

		public function frameLoop(event:Event):void
		{
			ball1.x += 1;  
		}
	}
}
 

jvalioli

Member
Programming OT was a long time coming I say. Just finished my Bsc in Computer Science and am moving to the west coast to become a full blown Software Engineer. OH yeah baby
 

Slavik81

Member
Which one is better (not necessarily easier) to go to c++ from? Ruby or python?

Or should I just say fuck it, i'm a smart kid and dive headfirst into c++ regardless?

I've not used Ruby, and only used a bit of Python, but looking at Ruby's style, you're probably much better off to go with Python. It appears Python is more similar to in style to C++ than Ruby is.

Assembly for life!
Motorola 68HC11 assembly was one of the simplest languages I learned. There's very little syntax and few leaky abstractions. I quite enjoyed it.
 

Gisk

Banned
Subscribing to this thread.

Whoooo programming time!

Also the title really should have been "I 'C' what you did there"
 

Swig_

Member
What language is used for web development for those slick web site animations.. For example, with twitter when a new tweet pops up, there's a little animation that drops down advising of a new tweet.. I can't think of many other examples.. I'm sure they're used with Facebook and other websites that use live updating.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
Javascript usually. And I guess eventually HTML5 as the web moves forward. There are open source Jscript blocks to achieve a wide variety of animations and effects, all free to use and modify. You don't really need anymore than a basic understanding of Jscript to make good use of those resources.

Mind you while they certainly look nice, they reduce usability because they can be memory intensive.
 
What language is used for web development for those slick web site animations.. For example, with twitter when a new tweet pops up, there's a little animation that drops down advising of a new tweet.. I can't think of many other examples.. I'm sure they're used with Facebook and other websites that use live updating.
Usually JavaScript
Or an AJAX call, but not good practice for that
 
D

Deleted member 30609

Unconfirmed Member
Self-teaching programming has always seemed like a really bad idea to me. I'd be interested in hearing success stories, but from my -- probably biased -- perspective, it seems like developing bad habits would be so damn easy. Programming itself has always seemed like a means to an end to me, rather than the end itself.
 

Luigiv

Member
What language is used for web development for those slick web site animations.. For example, with twitter when a new tweet pops up, there's a little animation that drops down advising of a new tweet.. I can't think of many other examples.. I'm sure they're used with Facebook and other websites that use live updating.

HTML5.

Edit: Oops forgot about Javascript existing.
 

Misguided

Banned
Yes you should be fine, although the class you designate as your Document class does not have to be called "Main", it could be called anything. And your Ball class does not have to extend Main. What it does need to do is be in the same folder as your Main class so your Main class knows where to find the Ball.as source file.

So for example, you could type Ball.as in that textbox in the Document properties, and if your folders are set up the right way, your .fla file will look for Ball.as upon compiling, and then initialize an object of type Ball on playback and then add that to the stage. Or if you have another class, say, BallTest, you can set that as the Document class. In the BallTest constructor you would have lines like.

Code:
Ball ball1 = new Ball();
addChild(ball1);
You don't need to write stage.addChild() because BallTest is automatically added to the stage as the Document class.

You don't need any additional functions in your Document class, although you can always add them as desired. The .fla will automatically call the constructor of its Document class (if any) and nothing else, other methods will have to be called manually within the class.

At the minimum, this is all the code you'll need in order to get a ball onto your stage and moving forward every frame.
Code:
package
{
	import flash.display.*;
	
	public class Main extends MovieClip
	{
                private var:Ball ball1;

		public function Main()
		{
			ball1 = new Ball();
                        addChild(ball1);
                        addEventListener(Event.ENTER_FRAME, frameLoop);
		}

		public function frameLoop(event:Event):void
		{
			ball1.x += 1;  
		}
	}
}

Thanks, but can you elaborate on what you meant by "private var:Ball ball1;"? It's bad code. At first I thought you meant "private var ball1:Ball", but that wouldn't make sense since later on in the Main() function you define ball1 as being a new Ball(). Thanks.
 

tokkun

Member
I think it's very useful for having a general model of the process in your head, even if it's not precise to the architecture you're running on. Without a mental model, it can be hard to grasp why one thing is slower than another, or what is actually going on behind the scenes.

I don't think it's any more useful than using C++ as the basis of your mental model.
 

usea

Member
Thanks, but can you elaborate on what you meant by "private var:Ball ball1;"? It's bad code. At first I thought you meant "private var ball1:Ball", but that wouldn't make sense since later on in the Main() function you define ball1 as being a new Ball(). Thanks.
He meant "private var ball1:Ball;"

Setting it to = new Ball(); makes perfect sense. It's a Ball variable. Setting it to an instance of Ball is about the only thing you can do.
 

Dragon

Banned
Self-teaching programming has always seemed like a really bad idea to me. I'd be interested in hearing success stories, but from my -- probably biased -- perspective, it seems like developing bad habits would be so damn easy. Programming itself has always seemed like a means to an end to me, rather than the end itself.
Guy I work with makes good money with one semester of college education because he spent the time to learn. He's an accomplished js guy and with the way the market is going for web dev being able to do server and client work like that has been a big advantage for him.
 

Misguided

Banned
He meant "private var ball1:Ball;"

Setting it to = new Ball(); makes perfect sense. It's a Ball variable. Setting it to an instance of Ball is about the only thing you can do.

Ah, I see. I'm just so used to condensing all that down to "private var ball1:Ball = new Ball();" (unless that wouldn't work in this case?)
 

rpmurphy

Member
Javascript usually. And I guess eventually HTML5 as the web moves forward. There are open source Jscript blocks to achieve a wide variety of animations and effects, all free to use and modify. You don't really need anymore than a basic understanding of Jscript to make good use of those resources.

Mind you while they certainly look nice, they reduce usability because they can be memory intensive.
What do you guys think about Ruby on Rails? Is it worth picking up?

Hello, Programming-GAF!

Just graduated on Sunday with a BS in Computer Science! Now for the job hunt.

I'm a little worried, I've never done large scale programming before. Just class projects and an internship. Any advice on the things I should emphasize in a interview for a software engineering position?
Those two areas are good topics to go over, since they'll certainly ask you questions about them. If you have done any projects on the side, you can talk about that too. If you think any of the languages or tools that you have used are relevant to the job at hand, highlight that. Good luck on your job hunt!
 

Haly

One day I realized that sadness is just another word for not enough coffee.
He meant "private var ball1:Ball;"

Setting it to = new Ball(); makes perfect sense. It's a Ball variable. Setting it to an instance of Ball is about the only thing you can do.
Right, this.
Code:
private var ball1:Ball;
This line says that the variable ball1 is of type Ball, and that it should have access to all public functions of type Ball.
Code:
ball1 = new Ball();
This calls the constructor of ball1, which is Ball().

This assumes that Ball extends MoveClip. Later on you're going to have functions exclusive to Ball, which is why ball1 needs to be instantiated as a Ball object. Otherwise bad things may happen.
Ah, I see. I'm just so used to condensing all that down to "private var ball1:Ball = new Ball();" (unless that wouldn't work in this case?)
You can, but I wouldn't recommend it. Initializing variables as they're declared, if they're meant to have class-wide scope, is usually considered bad practice. It's natural for local scope declarations (as in, you're only going to use the variable within the context of a single function), but for class-wide scopes (multiple functions within a class referring to the same variable of that class) it's better to declare ahead of time then initialize as needed.
 

usea

Member
Ah, I see. I'm just so used to condensing all that down to "private var ball1:Ball = new Ball();" (unless that wouldn't work in this case?)
It would work, but convention has variable initialization in the constructor. Most people would say it's easier to read, but that's subjective.
 

The Technomancer

card-carrying scientician
God I hate Microsoft sometimes. I wrote a short program for a friend in VS2010, little more then a command line interface, one .cpp file. When she tries to run it it turns out she needs the .NET framework but even after downloading and installing it and restarting it it doesn't run, saying that it needs the same file, MSCVR100
 

Ixian

Member
God I hate Microsoft sometimes. I wrote a short program for a friend in VS2010, little more then a command line interface, one .cpp file. When she tries to run it it turns out she needs the .NET framework but even after downloading and installing it and restarting it it doesn't run, saying that it needs the same file, MSCVR100
She needs to either download the VC10 runtimes (I think this is it?) or you can statically link against the runtimes. If you wanna statically link, right click on your project, go to Properties > C/C++ > Code Generation > change Run-Time Library to either Multi-Threaded or Multi-Threaded Debug, depending on what type of binary you're giving her.
 

Linkhero1

Member
Subscribed and bookmarked.

I need good sources for learning Java. I'm taking it next semester and never dabbed too much into it. I've tried reading a book and I can't get into the book, so I think some good, descriptive online sources would better suit me.
 
Top Bottom