Jump to content


Cancelling out a function


  • You cannot reply to this topic
11 replies to this topic

#1 adzicents

    Young Padawan

  • Members
  • Pip
  • 21 posts
  • Location:Melbourne, Australia

Posted 20 January 2006 - 07:39 AM

Ok.
What I have is about 14 different actionscript games/stuff and a few graphic and animations, and i have a problem with one of the actionscript things. What happens is this is completely made with actionscript:
It draws 2 boxes of different colours and also draws a line between them.
The two boxes are dragable, and the line always connects the two. Got it so far?

Ok my problem is the line is drawn by where the mouse is when you are holding the mouse button down on the buttons, and this is made in a function. The code for this is:
function drawline() {
	line.clear();
	line.lineStyle(1, 0x000000);
	line.moveTo(box1._x+10, box1._y+10);
	line.lineTo(box2._x+10, box2._y+10);
	updateAfterEvent();
}
Ok?
Now this function is called while the mouse button is being held down in this code:
if (_root._currentframe=15) {
	_root.onMouseMove = drawline;
} else {
	_root.onMouseMove<>drawline;
	box1.clear;
	box2._visible = false;
}

The main part in the problem is that everything appears in another frame because i have got buttons on the bottom of the screen linking to the other actionscripts and stuff. You might need the full code and the .swf file of this, so i have included them in the attachment as a .zip file. But if you need the .fla file too just say so.

Oh and to get to the frame with this game on it, in the .swf click on the arrow down in the bottom right corner and click AS Game. (Have a look at the other games too and if you want to know how to make them just ask :) )

Thanks for any help you can give me. All is appreciated :P

Oh by the way, flash player 8 resuired if anyone need player 7 version just ask.
And you must tell me which version of flash you are using if you need the .fla because I use Flash Professional 8

#2 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 20 January 2006 - 09:51 AM

There is no attachment..
upload it to your own server and paste the link or pm the link to me.

#3 adzicents

    Young Padawan

  • Members
  • Pip
  • 21 posts
  • Location:Melbourne, Australia

Posted 20 January 2006 - 02:59 PM

ok how about, this is the code:
//The Function that Draws the Line.
function drawline() {
	line.clear();
	line.lineStyle(1, 0x000000);
	line.moveTo(box1._x+10, box1._y+10);
	line.lineTo(box2._x+10, box2._y+10);
	updateAfterEvent();
}

//Creates the Movie Clips
this.createEmptyMovieClip("line", 1);
this.createEmptyMovieClip("box1", 2);
this.createEmptyMovieClip("box2", 3);
//Draws the First Box
box1.lineStyle(1, 0x000000);
box1.beginFill(0xFF0000);
box1.moveTo(0, 0);
box1.lineTo(0, 20);
box1.lineTo(20, 20);
box1.lineTo(20, 0);
box1.lineTo(0, 0);
//Placing the First Box
box1._x = 100;
box1._y = 200;
//Makes the First Box Draggable
box1.onPress = function() {
	this.startDrag();
};
box1.onRelease = box1.onReleaseOutside=function () {
	this.stopDrag();
};
//Draws the Second Box
box2.lineStyle(1, 0x000000);
box2.beginFill(0x0099FF);
box2.moveTo(0, 0);
box2.lineTo(0, 20);
box2.lineTo(20, 20);
box2.lineTo(20, 0);
box2.lineTo(0, 0);
//Places the Second Box
box2._x = 400;
box2._y = 200;
//Makes the Second Box Draggable
box2.onPress = function() {
	this.startDrag();
};
box2.onRelease = box2.onReleaseOutside=function () {
	this.stopDrag();
};
//Makes the Line Between the Boxes
if (_root._currentframe=15) {
	_root.onMouseMove = drawline;
} else {
	_root.onMouseMove<>drawline;
	box1.clear;
	box2._visible = false;
}

and HERE is the .swf

#4 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 20 January 2006 - 04:22 PM

Just my first thought, what about this?
function removeASGame(){
	removeMovieClip(box1);
	removeMovieClip(box2);
	removeMovieClip(line);
}

worked out for me..

Cheers
funkysoul

Edited by funkysoul, 20 January 2006 - 04:23 PM.


#5 adzicents

    Young Padawan

  • Members
  • Pip
  • 21 posts
  • Location:Melbourne, Australia

Posted 20 January 2006 - 06:13 PM

Where do I put that code? Frames? Under the else command?

#6 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 20 January 2006 - 07:13 PM

you put that right after the code you write for the ASGame, and then you call the function on all the other buttons.

#7 adzicents

    Young Padawan

  • Members
  • Pip
  • 21 posts
  • Location:Melbourne, Australia

Posted 23 January 2006 - 10:34 PM

sorry i've been away for a few days but umm... sorry if this sounds noobish but whats the code for calling a function?

#8 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 24 January 2006 - 04:16 AM

yourfunctionname();


#9 adzicents

    Young Padawan

  • Members
  • Pip
  • 21 posts
  • Location:Melbourne, Australia

Posted 24 January 2006 - 05:26 AM

Nope sorry that didn't work.

#10 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 24 January 2006 - 06:59 AM

//The Function that Draws the Line.
function drawline() {
	line.clear();
	line.lineStyle(1, 0x000000);
	line.moveTo(box1._x+10, box1._y+10);
	line.lineTo(box2._x+10, box2._y+10);
	updateAfterEvent();
}

//Creates the Movie Clips
this.createEmptyMovieClip("line", 1);
this.createEmptyMovieClip("box1", 2);
this.createEmptyMovieClip("box2", 3);
//Draws the First Box
box1.lineStyle(1, 0x000000);
box1.beginFill(0xFF0000);
box1.moveTo(0, 0);
box1.lineTo(0, 20);
box1.lineTo(20, 20);
box1.lineTo(20, 0);
box1.lineTo(0, 0);
//Placing the First Box
box1._x = 100;
box1._y = 200;
//Makes the First Box Draggable
box1.onPress = function() {
	this.startDrag();
};
box1.onRelease = box1.onReleaseOutside=function () {
	this.stopDrag();
};
//Draws the Second Box
box2.lineStyle(1, 0x000000);
box2.beginFill(0x0099FF);
box2.moveTo(0, 0);
box2.lineTo(0, 20);
box2.lineTo(20, 20);
box2.lineTo(20, 0);
box2.lineTo(0, 0);
//Places the Second Box
box2._x = 400;
box2._y = 200;
//Makes the Second Box Draggable
box2.onPress = function() {
	this.startDrag();
};
box2.onRelease = box2.onReleaseOutside=function () {
	this.stopDrag();
};
//Makes the Line Between the Boxes
if (_root._currentframe=15) {
	_root.onMouseMove = drawline;
} else {
	_root.onMouseMove<>drawline;
	box1.clear;
	box2._visible = false;
}
function removeASGame(){
	removeMovieClip(box1);
	removeMovieClip(box2);
	removeMovieClip(line);
}

on the other buttons you just put this:

removeASGame();


#11 adzicents

    Young Padawan

  • Members
  • Pip
  • 21 posts
  • Location:Melbourne, Australia

Posted 25 January 2006 - 01:49 AM

Oh My God YES FINALLY!!!! THANK-YOU SOOO MUCH!!!!

Oh and it didn't work because i needed to put this on the buttons:
_root.removeASGame();
Not just:
removeASGame();


#12 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 25 January 2006 - 03:54 AM

oops.. forgot to mention that.. :P
But anyway good that it works for you now ^_^





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users