16 Forum Posts by "graives"
That doesn’t make the FBI the world’s largest bitcoin holder. This honor is thought to belong to bitcoin’s shadowy inventor Satoshi Nakamoto, who is estimated to have mined 1 million bitcoins in the currency’s early days.
At 1/3/14 03:15 PM, milchreis wrote:At 1/3/14 02:01 PM, EtherNexus wrote: You don't need a loop, because this.onEnterFrame = buttonHandler actually adds the function to the listenerIt does not add it to a listener. The MovieClip class does not allow you to add listeners to it.
It is an event method that you can set (or unset).
and listeners are loops omittedListeners are not loops. That's just wrong.
and handled by the flash engine itself,The behaviour is defined in the class of the object and not some "engine" (whatever that is).
You can define both event methods and event listeners in your classes for arbitrary events.
It's like(if not one) a thread or something like that.No, it's not a thread.
Yeah. everything this guy said. I kind of skimmed over what EtherNexus said (didn't even realize he called it a loop lol). Thanks for clarifying!
At 1/3/14 02:01 PM, EtherNexus wrote:At 1/3/14 01:32 PM, graives wrote: this.attachMovie("yes", "yes", this.getNextHighestDepth(), {_x:100, _y:100});This is actually just an expansion of my code to the no button, made to yes.
this.attachMovie("no", "no", this.getNextHighestDepth(), {_x:200, _y:200});
var yesDown:Boolean = false;
function buttonHandler()
{
yes.onRelease = function()
{
yesDown = true;
yes.gotoAndPlay(2);
}
if(yesDown)
{
removeMovieClip(no);
}
}
this.onEnterFrame = buttonHandler;
I am not the best with AS2, but I tried this and it worked. Do not forget to set your instance names on each of the buttons!
Of course you did add some warppers to it. I'm tlaking here about buttonHandler().
You don't need a loop, because this.onEnterFrame = buttonHandler actually adds the function to the listener and listeners are loops omitted and handled by the flash engine itself, much the way it does on java. It's like(if not one) a thread or something like that.
This gave me an idea which I'll try later on as a tutorial.
In mine, it adds the buttons to the stage using code and it removes the clip with removeMovieClip. Then I used a boolean to determine when the button was pressed and to act accordingly. I am not really sure where you were getting at (accusing me of stealing what you wrote, lol?), but yeah it is not the same at all.
As for saying you do not need a loop, you do. Try it yourself and remove the buttonHandler function. I am guessing it has something to do with adding the buttons to the stage.
Sorry, and you are going to want to put that on the timeline of the frame where this takes place. You can remove the buttons from the stage (it places them for you if you name them 'yes' and 'no') and change the x and y values to your liking.
this.attachMovie("yes", "yes", this.getNextHighestDepth(), {_x:100, _y:100});
this.attachMovie("no", "no", this.getNextHighestDepth(), {_x:200, _y:200});
var yesDown:Boolean = false;
function buttonHandler()
{
yes.onRelease = function()
{
yesDown = true;
yes.gotoAndPlay(2);
}
if(yesDown)
{
removeMovieClip(no);
}
}
this.onEnterFrame = buttonHandler;
I am not the best with AS2, but I tried this and it worked. Do not forget to set your instance names on each of the buttons!
At 12/20/13 05:55 AM, SolidPantsSnake wrote: This looks kinda stupid.
Honestly, it is. Dogecoin is baby-level currency. Everyone should be tipping fedoracoin!
At 12/21/13 08:42 PM, Xenomit wrote:At 12/21/13 08:40 PM, graives wrote:I'll ask again, what does quoting world records have anything to do with my nearly superhuman abilitiesAt 12/21/13 08:26 PM, Xenomit wrote: I can run 3 miles in 8 and a half minutesThe world record for running a single mile is 3:43:13...
Oh, I get it. You are one of those role players who pretends to be someone else to escape their real life. That is cool I guess.
At 12/21/13 08:26 PM, Xenomit wrote: I can run 3 miles in 8 and a half minutes
The world record for running a single mile is 3:43:13...
At 11/29/13 03:44 AM, Innermike wrote:At 11/29/13 12:57 AM, graives wrote: Sorry, just simple rectangles.Depends whether they're rotated or not. If they are it's more complex than if they aren't. If they aren't then you're simply comparing positions and positions+dimensions. If they are then you could go about it a bunch of different ways, for a lot of people using an existing physics engine is the easiest route, but you could probably roll your own SAT collision fairly easily, though if you have problems with colliding unrotated rectangles that might not be a good idea.
Came up with this:
private function hitDetection(aa:Sprite, bb:Sprite):Void
{
if (!(aa.x > bb.x + bb.width / 2
|| aa.x + aa.width< bb.x
|| aa.y > bb.y + bb.height
|| aa.y + aa.height < bb.y))
{
trace("test");
}
}
Any ways to improve it (well, of course there are lol, but things that should definitely be done)?
Sorry, just simple rectangles.
At 11/29/13 12:54 AM, MSGhero wrote: It depends on the shapes of the objects or, more accurately, the shapes of where you want collisions to happen. Circles collide in one way, rectangles in another. When you know what shapes you want to collide, google it to get an idea and probably the pseudocode for how to do it.
I know there are many ways to do collisions in AS3, but I have heard that using math is one of the best ways. I can't seem to grasp the math of it though. Can someone please explain how I would go about making a function that tests the collision between two objects?
Something like:
function collisionTest(object1:Sprite, object2:Sprite):void
{
stuff for collision here?
}
At 11/27/13 03:54 PM, A-Genius wrote:At 11/27/13 03:43 PM, graives wrote: This needs to go outside of the monster1 class (along with the myEnemy array). Also, make sure moveMonster is set to public.public class monster1 extends Sprite
{
public var myEnemy:Array = []; // add my objects inside my array
function MyEnterFrame(e:Event):void
{
for(var i:uint = 0; i<myEnemy.length; i++){
myEnemy[i].moveMonster(e);
}
}
public function moveMonster(e:Event):void
{
if (this.y != 300)
{
this.mapPattern();
}
}
ok
Nah, your loop has to go in a completely different class. Put it in the class that is calling your monster1.
At 11/27/13 03:05 PM, A-Genius wrote:At 11/27/13 09:10 AM, kkots wrote: Re-post your code with changes applied! :Dimport flash.display.Sprite;
import flash.events.*;
public class monster1 extends Sprite
{
public var myEnemy:Array = []; // add my objects inside my array
var oneTurn:Number = 0;
var speed:Number = 1;
public function monster1()
{
this.width = 49;
this.height = 45;
addEventListener(Event.ADDED_TO_STAGE,Launch); //when the object is add to stage
trace(myEnemy.length);
}
function Launch(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE,Launch); //remove listener to work for one object
myEnemy=[this];
addEventListener(Event.ENTER_FRAME,MyEnterFrame); // create listener to add into frame
}
function MyEnterFrame(e:Event):void
{
for(var i:uint = 0; i<myEnemy.length; i++){
myEnemy[i].moveMonster(e);
}
}
function moveMonster(e:Event):void
{
if (this.y != 300)
{
this.mapPattern();
}
}
it still act slow >.> when I add 20 monster
function MyEnterFrame(e:Event):void
{
for(var i:uint = 0; i<myEnemy.length; i++){
myEnemy[i].moveMonster(e);
}
}
This needs to go outside of the monster1 class (along with the myEnemy array). Also, make sure moveMonster is set to public.
At 11/27/13 12:22 AM, A-Genius wrote:At 11/27/13 12:10 AM, HappyWhaleStudios wrote: Can we see the code? Probably the issue is that you're not doing it in the most efficient way or your computer's just slow, but probably the first one, so post your code and I'll see if I have any suggestions on how to make it betterThis is the first code that I think contain the problem:
When you add your objects you are going to want to be adding them to an array. After you do that, you can access the objects by using a for loop. This will prevent you from having a bunch of the same functions running and condense it nicely into one single loop.
To make a for loop you will want to do something like:
for(var i:int = 0; i < arrayName.length; i++)
{
stuff here
}
To tell the monsters what to do you will be using arrayName[i] instead of "this". So this.x would become arrayName[i].x

