Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsI'm not sure how to make a MOUSE.DOWN event work, could you please help?
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main extends MovieClip {
public function Main() {
addEventListener(MouseEvent.MOUSE_DOWN, mouseClick);
}
public function mouseClick(e:MouseEvent) {
trace("HELLO");
}
}
} You can't know what you don't know if you can only use yourself as a reference point.
You need to add the mouse event on something.
If you do:
myButton.addEventListener(MouseEvent.MOUSE_DOWN,mouseClick);
Then when you click on that button, it will fire the mouse event. If you just want to click anywhere on the stage, add the mouse event to the stage:
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseClick); Hey, thanks! I had no idea stage would do anything, but all of the tutorials made it target a button, so I knew something was missing. AS3 is looking quite new compared to AS2, but I personally like the class system.
You can't know what you don't know if you can only use yourself as a reference point.
At 12/17/12 11:19 AM, Rational-Delirium wrote: Hey, thanks! I had no idea stage would do anything, but all of the tutorials made it target a button, so I knew something was missing. AS3 is looking quite new compared to AS2, but I personally like the class system.
stage is whatever you set it to, but defaults to Sprite(FlashDevelop) or MovieClip(Flash IDE)
set events that require focus to the stage (one of the rare use-cases for it)
AS2 uses the class system, as well. It's just that it doesn't force devs to use it like AS3 does, so 99% of AS2 coders go the AS1 route with it.
Also, compared to AS3, AS2's OOP structure sucks. There's so few classes for anything you can't really do much with it without it becoming bloated because of all the base classes.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
I don't understand what you mean by 'stage is whatever you set it to.' My main class extends to Movieclip, but do you mean that I could make it extend to Movieclip or Sprite?
You can't know what you don't know if you can only use yourself as a reference point.
At 12/17/12 11:42 AM, Rational-Delirium wrote: I don't understand what you mean by 'stage is whatever you set it to.' My main class extends to Movieclip, but do you mean that I could make it extend to Movieclip or Sprite?
I would highly recommend extending Sprite, as we programmers have no use for frames. They just get in our way most of the time.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
At 12/17/12 11:31 AM, egg82 wrote: stage is whatever you set it to, but defaults to Sprite(FlashDevelop) or MovieClip(Flash IDE)
set events that require focus to the stage (one of the rare use-cases for it)
stage is a read only property of type Stage and hence cannot be set.
At 12/17/12 11:48 AM, egg82 wrote:At 12/17/12 11:42 AM, Rational-Delirium wrote: I don't understand what you mean by 'stage is whatever you set it to.' My main class extends to Movieclip, but do you mean that I could make it extend to Movieclip or Sprite?I would highly recommend extending Sprite, as we programmers have no use for frames. They just get in our way most of the time.
I remember the AS3 Bible saying it was more efficient, but I thought it'd be simpler to stick to the tutorial standards of the internet at the beginning :P I just switched everything to extend Sprite, but I don't know what you mean by stage being what you set it too. Do you mean that
stage.randomSprite
references the bounding box of a Sprite, while
stage
references the bounding box of the stage?
You can't know what you don't know if you can only use yourself as a reference point.
At 12/17/12 12:11 PM, milchreis wrote: stage is a read only property of type Stage and hence cannot be set.
fair enough, I suppose I shouldn't have said "stage" - think of Main as the timeline, or root
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P