• Register
  • TOS
  • Privacy
  • @NeoGAF
  • Like

injurai
Banned
(05-28-2012, 11:58 PM)

Originally Posted by DodgeAnon

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.
soultron
Banned
(05-29-2012, 12:08 AM)
soultron's Avatar
Subscribed. Gonna be all up in this. Looking to add some languages and such to my toolbelt.
Spoo
Member
(05-29-2012, 12:13 AM)
Spoo's Avatar
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
(05-29-2012, 12:48 AM)
The Technomancer's Avatar
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++
mugurumakensei
Member
(05-29-2012, 12:51 AM)
mugurumakensei's Avatar

Originally Posted by The_Technomancer

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
(05-29-2012, 12:53 AM)
Septimius's Avatar

Originally Posted by injurai

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
(05-29-2012, 01:07 AM)
IceCold's Avatar

Originally Posted by The_Technomancer

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.
Spehornoob
Member
(05-29-2012, 01:11 AM)
Spehornoob's Avatar
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
(05-29-2012, 01:14 AM)

Originally Posted by The_Technomancer

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

Originally Posted by IceCold

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

ctr-F5 i believe
BlueMagic
Member
(05-29-2012, 01:19 AM)
BlueMagic's Avatar
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
(05-29-2012, 01:22 AM)
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.
Tashi
343i Lead Esports Producer
(05-29-2012, 01:24 AM)
Tashi's Avatar
^^^ use the [code ] [/code ] tags. It's much nicer :)
Misguided
Banned
(05-29-2012, 01:31 AM)

Originally Posted by Tashi0106

^^^ use the [code ] [/code ] tags. It's much nicer :)

Thanks!
Septimius
Junior Member
(05-29-2012, 01:41 AM)
Septimius's Avatar

Originally Posted by Misguided

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);
			
			stage.addChild(ball);
			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
(05-29-2012, 01:45 AM)

Originally Posted by Septimius

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);
			
			stage.addChild(ball);
			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
(05-29-2012, 02:02 AM)
The Technomancer's Avatar
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
(05-29-2012, 02:05 AM)
usea's Avatar

Originally Posted by Misguided

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.



Originally Posted by The_Technomancer

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
(05-29-2012, 02:28 AM)

Originally Posted by usea

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.
(05-29-2012, 02:52 AM)
Haly's Avatar
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
(05-29-2012, 02:56 AM)
usea's Avatar

Originally Posted by Misguided

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
(05-29-2012, 02:56 AM)

Originally Posted by Haly

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.
Luigiv
Member
(05-29-2012, 02:59 AM)
Luigiv's Avatar
Assembly for life!
Haly
One day I realized that sadness is just another word for not enough coffee.
(05-29-2012, 03:01 AM)
Haly's Avatar
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...lass-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
(05-29-2012, 03:03 AM)
santouras's Avatar
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.
ghostofsparta
Member
(05-29-2012, 03:10 AM)
ghostofsparta's Avatar
I have some experience in PHP how hard will it be for me to pick up Ruby?
tokkun
Member
(05-29-2012, 03:15 AM)
tokkun's Avatar

Originally Posted by Luigiv

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
(05-29-2012, 03:15 AM)

Originally Posted by Haly

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...lass-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
(05-29-2012, 03:22 AM)
Luigiv's Avatar

Originally Posted by tokkun

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
(05-29-2012, 03:25 AM)
usea's Avatar

Originally Posted by tokkun

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.
(05-29-2012, 03:27 AM)
Haly's Avatar

Originally Posted by Misguided

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
(05-29-2012, 03:30 AM)
jvalioli's Avatar
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
(05-29-2012, 03:39 AM)
Slavik81's Avatar

Originally Posted by SteveWinwood

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.

Originally Posted by Luigiv

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
(05-29-2012, 03:42 AM)
Subscribing to this thread.

Whoooo programming time!

Also the title really should have been "I 'C' what you did there"
Swig_
Member
(05-29-2012, 03:56 AM)
Swig_'s Avatar
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.
(05-29-2012, 03:57 AM)
Haly's Avatar
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.
jeremy70583
Member
(05-29-2012, 03:59 AM)
jeremy70583's Avatar

Originally Posted by Kod1ak

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
Rez
(05-29-2012, 04:05 AM)
Rez's Avatar
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
(05-29-2012, 04:06 AM)
Luigiv's Avatar

Originally Posted by Kod1ak

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
(05-29-2012, 04:08 AM)

Originally Posted by Haly

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
(05-29-2012, 04:10 AM)
tokkun's Avatar

Originally Posted by usea

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
(05-29-2012, 04:10 AM)
usea's Avatar

Originally Posted by Misguided

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
(05-29-2012, 04:12 AM)
Dragon's Avatar

Originally Posted by Rez

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
(05-29-2012, 04:13 AM)

Originally Posted by usea

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
(05-29-2012, 04:15 AM)
rpmurphy's Avatar

Originally Posted by Haly

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?

Originally Posted by Spehornoob

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.
(05-29-2012, 04:16 AM)
Haly's Avatar

Originally Posted by usea

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
(05-29-2012, 04:16 AM)
usea's Avatar

Originally Posted by Misguided

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
(05-29-2012, 04:42 AM)
The Technomancer's Avatar
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
(05-29-2012, 05:32 AM)

Originally Posted by The_Technomancer

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
(05-29-2012, 07:08 AM)
Linkhero1's Avatar
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.
SuicideUZI
Member
(05-29-2012, 07:39 AM)
SuicideUZI's Avatar
Does anyone know a good place for a beginner to start with Objective-C with a focus on creating iOS apps?

Thread Tools