Be a Supporter!

I think Flash MX pro is Action Script. Anyway, I'm a java programmer looking to create a Flash game. Thus far I have created a class file called Vehicle.as that looks like:

class Vechicle extends MovieClip {
	public  var vehicle:MovieClip;
	private var speed:Number;
	private var accel:Number;
	
	function Vehicle(passed:MovieClip) {
		this.vehicle = passed;
		this.speed = 5;
		this.accel = 5;
	}
	
	function getSpeed():Number {
		return this.speed;
	}
	
	function setSpeed(spd:Number) {
		this.speed = spd;
	}
	
	function getAccel():Number {
		return this.accel;
	}
	
	function setAccel(acl:Number) {
		this.accel = acl;
	}
	
}

Basically just accessor methods. Now, on my main flash page, I want to link this class to a movie clip. Also, I want to be able to control this movie clip with the arrow keys. Should the eventhandlers be within the class file? If not, should they be in their own interface/class? How do I link it all together?

Response to: Javascript/Ajax/P hp/Mysql chatroom Posted June 18th, 2010 in Programming

Have you ever seen on your facebook wall how it updates without refreshing the page? This is what I want to do I know it can be done with AJAX that is the whole point

Response to: Javascript/Ajax/P hp/Mysql chatroom Posted June 18th, 2010 in Programming

At 6/18/10 06:22 AM, henke37 wrote: This concept is flawed by design. HTTP is simply not suitable for chatrooms. It only allows the server to send data when the client has requested it.

Albeit there are other protocols better suited for my purpose however I know this is possible. I merely want to use the setTimeout function to continuously send requests to the server ever 3 or 4 seconds. I've seen it done a few times (I think it's what facebook chat uses).


I'm trying to make a plug in less chat room using javascript php and mysql. Now, the only part I can get to work is to autoupdate the board. Basically I want the board to autoupdate every 2 seconds to display any new messages that may have been posted. The two functions that are suppose to do this are blankReq() and handleBlankReq(). I have posted both my javascript page and my backend php page. The code is self explanatory but just to clarify the mode parameter I send to my php pages tells whether to insert a new message / display the chat log or to just display the chat log. heres the code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="PRAGMA" content="NO-CACHE">
<title></title>
</head>

<body onLoad="blankReq();">

<form name="mFor" method="get">
	<table>
		<tr>
			<td><textarea rows="10" cols="50" id="log1" readonly></textarea></td>
		</tr>
		
		<tr> 
			<td><input type="text" name="message" id="message" onBlur="sendNewMess()" /><input type="reset" value"Reset" onClick="clearForm()" /></td>
		</tr>
	</table>
</form>


<script language="javascript" type="text/javascript">
xmlHttpReqMess = createReqObj();

function createReqObj() {
	var requestObj; 
	try{
		requestObj = new XMLHttpRequest();
		return requestObj;
	} catch (e){
		try{
			requestObj = new ActiveXObject("Msxml2.XMLHTTP");
            return requestObj;
		} catch (e) {
			try{
				requestObj = new ActiveXObject("Microsoft.XMLHTTP");
				return requestObj;
			} catch (e){
				alert("Incompatible browser");
				return false;
			}
		}
	}
}

function blankReq() {
	var getString = "process.php?mode=2";
	if(xmlHttpReqMess.readyState==4) {
		try {
			xmlHttpReqMess.open("GET", getString, true);
			try {
				xmlHttpReqMess.send(null);
			} catch (e) {
				alert(e.toString());
			}
		} catch (e) {
			alert(e.toString());
		}
	xmlHttpReqMess.onreadystatechange = handleBlankReq;
	}
	setTimeout(blankReq(), 2000);
}

function handleBlankReq() {
	if(xmlHttpReqMess.readyState==4) {
		try {
			document.mFor.log1.value=xmlHttpReqMess.responseText;
		} catch(e) {
			alert(e.toString());
		}
	}
	setTimeout(blankReq(), 2000);
}

function sendNewMess() {
	var getString = "process.php?mode=1&message="+document.mFor.message.value;
	try {
		xmlHttpReqMess.open("GET", getString, true);
		try {
			xmlHttpReqMess.send(null);
		} catch(e) {
			alert(e.toString());
		}
	} catch (e) {
		alert(e.toString());
	}
	xmlHttpReqMess.onreadystatechange = handleIncomingMess;
}

function handleIncomingMess() {
	if(xmlHttpReqMess.readyState==4) {
		if(xmlHttpReqMess.status==200) {
			try {
				document.mFor.log1.value=xmlHttpReqMess.responseText;
			} catch(e) {
				alert(e.toString());
			}
		}
	} 
}

</script>
</body>
</html>

and

<?php

$timeStamp = date("H:i:s");
$mode = $_GET['mode']; //1 = insert, 2 = retrieve 

$conn = mysql_connect("localhost","root","") or die(mysql_error());
$db = mysql_select_db("main_db");

$sql="";
$result="";

if($mode==1) {
    $message = $_GET['message'];
	insertMessage($timeStamp, $message);
	displayTable();
} else if($mode==2) {
	displayTable();
} else {
	die("error");
}

function insertMessage($tempTime, $tempMess) {
	$sql = "INSERT INTO chatlog (time, message) VALUES('".$tempTime."', '".$tempMess."')";
	$result = mysql_query($sql);
	
	if($result) {
		return true;
	} else {
		return false;
	}
}

function displayTable() {
	$result = mysql_query("SELECT * FROM chatlog ORDER BY id DESC");
	
	while($row=mysql_fetch_array($result)) {
		echo $row['time'].": ".$row['message']."\n";
	}
}

mysql_close($conn);
?>

I have a method that takes a string as a parameter and checks out many characters in that string are digits. When I run it I get a char cannot be dereferenced error. Here is the code
[code]
public static int checkDigit(String str) {
int numOfDigits = 0;
char[] charArr = str.toCharArray();
for(int i=0; i<str.length(); i++) {
if(charArr[i].isDigit()) {
numOfDigits++;
}
}
return numOfDigits;
}
[/code]
It's fucking making me so angry

Need help w/ simple VBScript Posted April 25th, 2010 in Programming

I need to open a file and find the first instance of a given string. So if I decided to search "the" it would have to return the index of the first instance of "the".

I can't figure this out plz help!

Response to: Best way for make 10x10 grid of MC Posted April 18th, 2010 in Game Development

At 4/18/10 10:52 PM, CaptainPoncho wrote: Just use nested loops to create a 10x10 array.

Yea okay so I have an array of movieclips now how to i display those clips on the screen?

....

Response to: Best way for make 10x10 grid of MC Posted April 18th, 2010 in Game Development

Ok so I populated an Array with movieclips

myArray = [];
myArray.push(_root.a1);
for (var i = 1; i < 10; ++i) {
_root.firstClip.duplicateMovieClip("newC lip" + i, i);
myArray.push(_root["newClip" + i]);
}

Now how do I write those clips to the stage??

for (int x=0;x<myArray.length;x++) {
myArray[x]. // wtf do i put here?!?!
}


I need to make a 10x10 grid of MC's. Each MC will inherit the same class. I have another MC (a car) that will have a hitTest code to see if it is touching any of t he 10x10 MC's. Is there an easier way to represent these 100 parts of the grid (each its own MC) without creating 100 movie clips and linking them all to the same class?

Response to: Several movie clips w/ same funct Posted April 18th, 2010 in Game Development

At 4/18/10 04:19 PM, HDXmike wrote: Create a class for the sqaure with all the square variables/functions/eventListeners then you can just add in as many as you like and they will all be independent :)

Can you explain to me how to link a class to an MC? I'm using as 2.0 and I'm familar with oop but in java not flash. How does my MC inherit the class?


I have 10 movie clips which are all identical squares. I want them all to have the same functions / variables. However, i dont want them to act the same. What i mean is if mc1 is clicked I don't want mc2 or mc3 to be affected.

How do i do this

Response to: Oop As 2.0 Simple Prob (_rotation) Posted January 5th, 2010 in Game Development

That's the first thing I tried but it didn't fix it. I also added the extends MovieClip but it didnt change anything


Controls.as

class Controls {
	private var speed:Number;
	private var rotation:Number;
	function Controls() {
	}
	function spin():Void {
		_rotation+=5;
	}
}

Game.fla

var obj:Controls = new Controls();
obj.spin();

I have my movieclip linked with Controls.as. The code in Game.fla is on the main time line. Does nothing. When I put it in the movieclip it spins but spins around an imaginary circle(it spins around a center point away from the mc)

HELP

Response to: College burnout Posted December 31st, 2009 in Programming

.... and stop putting fucking words in my mouth. A degree is completely different then a HIGH SCHOOL EDUCATION. If you don't have enough "in you" to graduate high school chances are you don't have enough to do anything else in life.

I know a bunch of high school drop outs. They're all (without exception) fucking inbred moron losers

Response to: College burnout Posted December 31st, 2009 in Programming

At 12/31/09 08:23 PM, citricsquid wrote: We all know that programming is about doing shit, it's not about knowing shit, but you don't need an education to do shit.

HAHAHA alright great argument this is where I stopped reading.

Like, we all know about shit, but shit when you do shit, shit happens.

hahaha

Response to: College burnout Posted December 31st, 2009 in Programming

At 12/31/09 07:00 AM, GustTheASGuy wrote: Anyway I don't think dropping out is the kind of discussion the OP wanted. :p

"College burnout"....

LOL @ whoever said programming wasn't about education. Yea, maybe you can throw together a nifty flash app or a battleship game without any formal education. Programming is about logic and math. I'd like to see a high school drop out write a collision detection engine for a curved surface (integrals). Big O = discrete mathematics. The list goes on and on

I'm really not trying to offend anyone here. My point is that there is a lot more to programming then memorizing functions and learning about classes. Yea, I learned how to code java when I was 15 too. Great! Unfortunately there aren't many employers looking to pay people to write simple calculator and notepad type applications.

Case point: Cryptography

Response to: College burnout Posted December 30th, 2009 in Programming

If you think you're going to cut it as a programmer without a high school diploma (at the absolute least) you are extremely mistaken. I'm really not trying to put you down. But fuck kid, EVERYONE graduates high school these days. You're destined to make $10.00/hr the rest of your life.

Think about it. Go back. Get your diploma. NOT A GED. Get your fucking high school diploma. Stop hiding behind this whole "productive" facade.

Response to: College burnout Posted December 30th, 2009 in Programming

Ahahaha excuse me for laughing in your face. You dropped out of high school to become more productive? It's like fucking for virginity. You aren't going to have any chance in this world if you cannot finish high school. High school is a damn cake walk kid. At the very least it's a place to make lifelong friends

Response to: Html Help. Posted December 29th, 2009 in Programming

At 12/29/09 10:13 AM, TropicalPenquin wrote: I'll have a double whopper with cheese, and yes I would like fries with that.

An extra $0.50 get u supersized and a bevig of yo choice

Response to: Simple question. Posted December 29th, 2009 in Game Development

At 12/29/09 09:22 AM, Jameslat wrote:
At 12/29/09 08:41 AM, Archon68 wrote: You don't need to make eight fucking threads about the same problem.
Well when i still have a question i still need an answer (btw try to control ur temper over the public forum if u want to send hate mail just pm me ;)

for the res of u guys thnx for the help!

Did you get it to work?

Response to: College burnout Posted December 29th, 2009 in Programming

Also, for all you high school students out there, remember that college isn't always a good investment. Don't go into debt unless you're going to MIT, Cal-Tech, CMU, Harvard, Yale, etc. Go to a community college, save money, and transfer after two years. If you want to live the college life then go to a state school. A $250,000 private school education is no better then a $30,000 education (except for the aforementioned schools). The people who are going to look down are you are the same people who are going to have gray hair in 4 years. $250,000 debt and a degree from Northeastern completely fucked compared to someone with $0 debt and a degree from SUNY Buffalo

Response to: College burnout Posted December 29th, 2009 in Programming

You're not alone brother. I'm a computer science major (BS not BA), and my last semester really took a toll on me. I have a serious passion for coding. Learned html/javascript at 13, moved on to php, mysql, actionscript, java, c++, assembly, ect, etc. The math is what kills me. I barely scraped by with a C in calc II. Electromagnetism was the hardest class I've ever taken. Sometimes I feel like I would be better suited for a CIS degree... you know... something a little less challenging.

If you've already payed for 2 years you might as well finish up. If you haven't gone that far I suggest you take a serious look at your life. By now I'm sure you've realized that this industry won't turn you rich. If you're lucky, you may land a nice job that affords you a decent living. Give it 10 years and you might land a job in management. Fuck, I know high school gym teachers that make $110,000 a year (public school, NYS) at 30 years of service. What else are you going to do?

For me, it's just a matter of living. I'm going to really concentrate the next two years. I'm going to graduate and take all I can from this degree. I've realized that life isn't all about making the big bucks, and college isn't all about landing a job. Ideally, I would like to find a wife, get salaried and have a baby or two. CS is just a facilitator

I hope my ramble has helped in some way

~ Chris

Response to: File saving Posted December 28th, 2009 in Programming

At 12/28/09 10:26 PM, darkmpulse1 wrote: and if i say that then save the name as blah.bat it will be a batch file?

Yessir

Response to: Online Multiplayer Game? Posted December 28th, 2009 in Programming

Yea I forgot to mention you're going to need a dedicated server cause your game is going to be as popular as farmville

Response to: Simple question. Posted December 28th, 2009 in Game Development

I don't have flash installed on my server so I cannot check that line. If it doesn't work (it should...) please try and typecaste them to doubles, not integers.

Response to: Simple question. Posted December 28th, 2009 in Game Development

Next time please phrase your question is a more comprehensive manner. The person above me is totally off. He's looking to find the remainder (using the mod operator). You cannot typecaste the values to INT because INT values don't have a remainder

_root.cashbox.text += (_root.expensivebox.text + _root.interestbox.text - _root.incomebox.text) % 1;

I don't even think typecasting is necessary (it may depend on what version of flash you are using). If the following code doesn't work you may want to typecaste and work with variables.

Response to: Online Multiplayer Game? Posted December 28th, 2009 in Programming

Things you'll need

1. $2000

or

1. Four years (or a degree)
2. Money for books and coffee
3. An artist
4. $300 for flash
5. Change #1 to six years if you want to do it the free way (java)

Good luck and god speed

Response to: Can't get my turning to work Posted December 28th, 2009 in Game Development

At 12/28/09 07:57 PM, BillysProgrammer wrote: Flipping an object, say if you went to EDIT > W/e -> Flip Horizontally, it would have the same effect. In platformers, thats how they "turn around"

o0o0o I understand. Wouldn't work for my problem though

Response to: Can't get my turning to work Posted December 28th, 2009 in Game Development

At 12/28/09 03:42 PM, SantoNinoDeCebu wrote: it's pretty much right except it should be converted into radians! So multiply your angles by Math.PI/180 and then it should work.

Ahh radians! Of course I'm so stupid....

Wtf does xscale and yscale have to do with anything I asked?

Response to: universal variables? Posted December 28th, 2009 in Game Development

They're called global variables. I'm not positive, but I believe you can have a variable with a "global scope" (can be used anywhere), if you declare it in the main timeline