How To Use MouseEvent On My Movieclip
Hi
I having one package which is called main, And in that i added one child called carMc, now i want that carMc movie clip as a clickable one.i hope the onRelease is not working in AS3, so i used the following code
carMc["car_"+raceParticipantId].mc.addEventListener(MouseEvent.CLICK, myfunction);
But its through 1120: Access of undefined property MouseEvent.this error pl tell me solution.
thanks,
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 09-18-2008, 09:49 AM
View Complete Forum Thread with Replies
Sponsored Links:
AS 3.0 MouseEvent Play Movieclip
Im currently using AS 3.0 I have a number of buttons on my MAIN STAGE each one "on CLICK" plays a movieclip and on "ROLL_OUT" stopes the movieclip. The code I used to do this and it works fine.
------------------------------------------------------------------------
thepass_button.addEventListener(MouseEvent.CLICK, thepassinfoFunction);
function thepassinfoFunction(event:MouseEvent):void
{
thepass_movie.gotoAndPlay(2)
}
thepass_button.addEventListener(MouseEvent.ROLL_OU T, thepassinfoFunction2);
function thepassinfoFunction2(event:MouseEvent):void
{
thepass_movie.gotoAndPlay(86);
}
------------------------------------------------------------------------
I have also got a movieclip with a number of buttons in side it. I want these buttons to do the samething as above however the code will not work because its a child or something like that. Please Help Me!!!
View Replies !
View Related
MouseEvent Not Calling On A Movieclip.
I have an enemy whom when he is clicked should take damage.
The problem I'm having is when I assign the listener:
addEventListener(MouseEvent.CLICK, check_for_click);
it refuses to work.
If I make it:
stage.addEventListener(MouseEvent.CLICK, check_for_click);
It works. The problem although the event handler is on the enemy but the stage. I just don't know why my enemy MovieClip refuses to work.
Code:
I can upload my code if someone could take a peek at it for me.
There is something I don't know about event handlers I think.
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
public class Enemy extends MovieClip
{
public var engine:MovieClip;
public var aka_name;
public var jail_cell; // which cell I'm in
public var life;
public function Enemy(parent, enemy_name, jail_cell)
{
life = 3;
engine = parent;
this.jail_cell = jail_cell;
aka_name = enemy_name;
aka.text = enemy_name;
engine.addChild(this);
addEventListener(Event.ENTER_FRAME,on_every_frame);
stage.addEventListener(MouseEvent.CLICK, check_for_click);
}// class contructor
function on_every_frame(e:Event):void
{
this.x ++;
// check to see if cursor is over enemy
engine.reticle.check_for_enemy(this)
}
function check_for_click(e:MouseEvent):void
{
//check to see if enemy was hit
if(engine.reticle.check_for_enemy(this))
take_damage();
}
function take_damage()
{
if ( life != 0)
life --;
else
death();
}
function death()
{
this.visible = false;
}
public function move(x,y)
{
this.x = x
this.y = y
}// move
}//class
}//package
View Replies !
View Related
Dynamic MovieClip MouseEvent
I am creating a series of MovieClips with a MouseEvent.CLICK added to them. The CLICK it only controls the last MovieClip. I have tried creating a unique name for each MovieClip. How can I get the CLICK to control only the MovieClip I CLICK on.
Below is the code. The first function listens for cue points in an FLV if the cuePts meet the substring requirements it places a MovieClip on the stage.
on MouseEvent.CLICK it fires off the second Function.
Code:
function cp_listener(eventObject:MetadataEvent):void {
//trace("Elapsed time in seconds: " + flvPlayer.playheadTime);
//trace("Elapsed time in seconds: " + eventObject.info.name);
nameVar= eventObject.info.name;
subSt = nameVar.substring(3,nameVar.length);
if(isNaN(subSt)){
trace("this is not a number");
}else{
loadComments = new addComments(getCaption(subSt),getTITLE(subSt));
loadComments.name = "loadComments" + subSt;
loadComments.x = 152 * subSt;
loadComments.addEventListener(MouseEvent.CLICK,CommentClick);
addChild(loadComments);
var myTween:Tween = new Tween(loadComments, "alpha", Strong.easeOut, 0, 100, 300, true);
}
}
This function will only control the last MovieClip placed to the stage.
Code:
public function CommentClick(event:MouseEvent):void{
var myRootMovieClip:MovieClip = loadComments.getChildByName("commentBox_mc");
var controlCircle = myRootMovieClip.getChildByName("squarBox_shp");
//trace(loadComments( event.target ).name);
//trace(event.target.name);
var myTween:Tween = new Tween(controlCircle, "width", Strong.easeOut, 151, 200, 3, false);
var myTween2:Tween = new Tween(controlCircle, "height", Strong.easeOut, 151, 200, 3, false);
}
View Replies !
View Related
Pass MouseEvent Through MovieClip
Hello
I have had a quick look around for the answer to this one with no luck of yet.
I have 2 movieClips overlapping each other and want them both to receive RollOver MouseEvents. I'm sure this was possible in AS2, so I should be possible in AS3
Can anyone Help?
View Replies !
View Related
Event Prioritsation --- MouseEvent.CLICK & MouseEvent.DOUBLE_CLICK
Hi Guys
Been wracking my brains over this and still can't get it to work.
How do I get my app to tell the difference between a click and a
double click event:-
I've seen some similar issues on this group but I couldn't find the
definitive answer:
Here's the code I've been using:-
import flash.events.MouseEvent;
import mx.controls.Alert;
private function initApp():void{
this.addEventListener(MouseEvent.MOUSE_WHEEL,mw,fa lse,2);
this.addEventListener(MouseEvent.DOUBLE_CLICK,dc,f alse,3);
this.addEventListener(MouseEvent.CLICK,lc,false,1)
}
private function lc(evt:MouseEvent):void{
var x:Number = Number(evt.localX);
var y:Number = Number(evt.localY);
Alert.show("Center @ " + " " + x.toString() + " " +
y.toString());
}
private function dc(evt:MouseEvent):void{
var x:Number = Number(evt.localX);
var y:Number = Number(evt.localY);
Alert.show("Zoom In & Center @ " + " " + x.toString
() + " " + y.toString());
}
private function mw(evt:MouseEvent):void{
var i:Number = Number(evt.delta);
var x:Number = Number(evt.localX);
var y:Number = Number(evt.localY);
if(i>0){
Alert.show("FWD" + " " + x.toString() + " " +
y.toString());
}
if(i<0){
Alert.show("BWD" + " " + x.toString() + " " +
y.toString());
}
}
Kind Regards
Jonathan
View Replies !
View Related
Is There A MouseEvent Like This?
I have two MovieClips, MC1 and MC2, is there a mouse function or a listener which could tell me which MC was clicked? Like,
(this is just what I wanted to happen, I know there is no such code but I dont know what to put inside the condition.)
Quote:
if (MC1.isPressed == true)
{
//Duplicate MC1 or do something
}
else if (MC2.isPressed == true)
{
//Duplicate MC2 or do something
}
Is there a MouseEvent like that in AS3?
View Replies !
View Related
MouseEvent
Hi,
This script does not work for me, how can that be?
Quote:
bttn_marc.addEventListener(MouseEvent.CLICK, site);
function site(event:MouseEvent):void {
navigateToURL(new URLRequest("http://www.******.com"));
trace("K L I K");
}
Errors where:
The class or event MouseEvent could not be loaded &
Statement must appear within on handler
Help this men!
View Replies !
View Related
MouseEvent?
Problem Code:
box.addEventListener(MouseEvent.MOUSE_OVER, onBoxOver);
box.addEventListener(MouseEvent.MOUSE_OUT, onBoxOut);
function onBoxOver(evt:MouseEvent):void{
evt.target.play(boxUP);
}
function onBoxOut(evt:MouseEvent):void{
evt.target.play(boxDOWN);
}
______________________________________________________________________________________________
OUTPUT:
ArgumentError: Error #1063: Argument count mismatch on flash.display::MovieClip/play(). Expected 0, got 1.
at mikeumus_fla::MainTimeline/onBoxOver()
ArgumentError: Error #1063: Argument count mismatch on flash.display::MovieClip/play(). Expected 0, got 1.
at mikeumus_fla::MainTimeline/onBoxOut()
_______________________________________________________________________________________________
Hey Everybody,
I'm using actionscript 3.
I have boxUP, and boxDOWN MCs ready and exported to actionscript. I named the instance of box on the stage to and instance name of box.
The site that I'm reffering to is Mikeumus.com. If you go there you'll notice a subtle black rectangle with no fill at the bottom of the .swf. That is the box that is referred to in the code. I just want it to pop slide up and down when moused, in and out of. The .swf is huge as hell too and for a reason i cannot explain. It plays a song coming from youtube's servers, and all the video files on it have been compressed multiple times on AE and Adobe's CS4 Media encoder. The background .flv that I'm sure you'd like to point out as being the source of the huge file size is actually only 418.1 kb! And the others are all within the 200 kb range, so wtf!?!?!
Thank you for your time and consideration.
Peace and Love,
Mikeumus
View Replies !
View Related
Rotate A MC By MouseEvent
Hey board,
how would you code the following action:
there is a ball-MC on the stage and when i would press the MC and move the mouse clockwise oder counterCW the ball-MC should be following my move CW or CCW.
Would be like a volume button to move left- or rightwards.
can anybody give me a hint how to code that?
thanks!
Zacky
View Replies !
View Related
What's Up With MouseEvent.DOUBLE_CLICK?
Do you have to perform some kind of VooDoo magic to get MouseEvent.DOUBLE_CLICK to work? here's my code:
Code:
import flash.events.*;
box_mc.addEventListener(MouseEvent.DOUBLE_CLICK, openFolder);
function openFolder(e:MouseEvent):void {
trace("open");
}
super simple code, just have "box_mc" on the main timeline, first frame.
thx for the feedback!
View Replies !
View Related
[F8] AS Tweening On MouseEvent
Ok, I have 2 questions that may seem dumb to most of you but I'll do my best to try and explain.
1. I have a MC that appears as a small rectangle at the bottom of the screen (although the entire MC is a larger rectangle off-stage) with a button on it. When the button is clicked, I want the MC to slide up and into the screen, revealing the entire large rectangle MC. So I made the MC with 3 components, the rectangle object, the button text and an invisible button over the text. I then added this AS:
PHP Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
news_btn.onPress = function() {
var yMove:Tween = new Tween(news_mc,"_y",Strong.easeOut,0,-260,1,true);
}
This works fine, however, only the rectangular object (news_mc) tweens when the event occurs. I want the tweening rectangle to include the button text and the invisible button to tween with the object. Because I am new to Flash, I don't know how/where to place the different button/MC to make this work.
2. Once the tween has completed, I want the next click of the button to reverse the tween. No idea...
Any help would be greatly appreciated! If you need me to explain my question better, please let me know.
Thanks!
View Replies !
View Related
MouseEvent Question
I have a movieclip (ddTab) that I have stored in the Library that is comprised of two elements (a background and a dynamic text field). Additionally, I have exported this movie clip for ActionScript so that I can access it dynamically via script
I add an occurence of this movie clip to the stage and add an Event Listener to it to detect a Mouse Over event. (See code below)
Code:
var tab1:ddTab = new ddTab();
tab1.x = 5;
tab1.y = 5;
addChild(tab1);
tab1.addEventListener(MouseEvent.MOUSE_OVER, grabIt);
function grabIt(e:Event):void {
trace(e.target);
}
My problem is that within the function the two elements that make up the movie clip (the rectangle and the textfield) are treated separately as targets even though the event listener is added to the movie clip as a whole.
Can anyone tell me what I'm doing wrong or explain why this happens?
View Replies !
View Related
Looping After An On(MouseEvent)?
okay how do I loop after an OnMouseEvent (i'm using "press")
The problem is, my code only executes once per click and doesn't loop.
I hope that's enough info for you guys. I tried to keep it short and simple.
edit: I want it to loop for as long as the button is held down.
View Replies !
View Related
Extending The MouseEvent?
Hey,
I've run into some trouble since I need to send additional parameters to an Event Listener Function. The solution might be extending the MouseEvent Class, but I'm not sure. Quick Brief:
I have an Episode-object, acting as a wrapper of other objects. The important one is the object AssetList, which extends Array with some extra functionality. The idea is that via the AssetList in Episode, I can fetch whatever Asset I might need, regardless of the actual type of object it is. Each Asset implements an interface called IAsset, so that the document class and the rest of the code doesn't need to know what kind of asset it's dealing with. This way, I can create new Assets and maintain functionality. I figure it's good OOP. Other objects can also have AssetLists, if they contain any type of metadata surrounding them.
However, the problem occurs in this code snippet, which gets the relevant Episode-object. In this case, I need the assets of a Clip-object, so I use the Clip-object's Assetlist, but the idea is the same as explained above. When the asset is found, I set a few listeners to it:
Code:
for (var i:Number = 0; i < _episodes.length; i++) {
var tags:Array = _episodes[i].tags;
for (var j:Number = 0; j < tags.length; j++) {
if(_episodes[i].tags[j] == selTag) {
// Tags match
var ep:Episode = _episodes[i];
var thumbs:AssetList = ep.mainClip.assets.findByProperty("type","thumbnail");
var thumb:Image = thumbs[0];
var w:Number = Image.THUMB_WIDTH;
var h:Number = Image.THUMB_HEIGHT;
thumb.displayImage(w,h,true,thumb.name);
thumb.x = thumbCount * w;
thumb.y = 0;
thumb.alpha = .8;
_thumbHolder.addChild(thumb);
thumb.buttonMode = true;
thumb.addEventListener(MouseEvent.MOUSE_DOWN,thumbMOUSEDOWN);
thumb.addEventListener(MouseEvent.ROLL_OVER, thumbROLLOVER);
thumb.addEventListener(MouseEvent.ROLL_OUT, thumbROLLOUT);
thumbCount += 1;
}
}
If I could send an extra parameter to the MouseEvent.MOUSE_DOWN, containing data about which Clip this Asset belongs to, everything would be all set. I realize I could set an extra property inside the Image-object, containing info about the Clip, but it would essentially look something like this, and wouldn't really make any (OOP) sense:
someClip.asset = someAsset;
someAsset.clip = someClip;
(It might be a bit confusing; a clip can be an asset and have assets at the same time, but in different scopes).
If I need to extend the MouseEvent Class, how would I do that? Or is there another recommended way?
Thanks alot!
//Hamrin
View Replies !
View Related
MouseEvent Not Working
im new to actionscript so i might be doing something wrong but im trying to make a tictactoe game and i made the grid so far. I made a class named boxes where i drew a rectangle and then i made a class named grid where i made 9 boxes and aligned them in shape.
BOXES CLASS:
package {
import flash.display.Shape;
public class boxes extends Shape{
var side:Number = 100;
public function boxes(){
graphics.lineStyle(1);
graphics.beginFill(0xFFFF00);
graphics.drawRect(0,0,side,side);
}}}
GRID CLASS:
package {
import flash.display.Sprite;
import flash.events.*;
public class grid extends Sprite {
var topleft = new boxes();
var topcenter = new boxes();
var topright = new boxes();
var middleleft = new boxes();
var middlecenter = new boxes();
var middleright = new boxes();
var bottomleft = new boxes();
var bottomcenter = new boxes();
var bottomright = new boxes();
var thex = new X();
var theo = new O();
public function grid() {
addChild(topleft);
topleft.addEventListener(MouseEvent.MOUSE_DOWN, drawan);
addChild(topcenter);
addChild(topright);
addChild(middleleft);
addChild(middlecenter);
addChild(middleright);
addChild(bottomleft);
addChild(bottomcenter);
addChild(bottomright);
topcenter.x = topleft.width;
topright.x = topleft.width + topcenter.width;
middleleft.y = topleft.width;
middlecenter.y = topleft.width;
middlecenter.x = topleft.width;
middleright.y = topleft.width;
middleright.x = topright.x;
bottomleft.y = topleft.width * 2;
bottomcenter.y = topleft.width * 2;
bottomcenter.x = topleft.width;
bottomright.y = bottomright.x = topleft.width * 2;}
public function drawan(e:MouseEvent):void {
trace("click");
addChild(thex);
}}}
Also i have the main class for the game in which i only add the grid to the screen
MAIN CLASS:
package {
import flash.display.Sprite;
public class tictactoe extends Sprite {
var thegrid = new grid();
public function tictactoe():void {
addChild(thegrid);
}}}
So the problem is:
in the grid class i put
topleft.addEventListener(MouseEvent.MOUSE_DOWN, drawan);
and when im supposed to press the topleft box i will draw an X or an O but for some reason nothing is happening. it works if i put
grid.addEventListener(MouseEvent.MOUSE_DOWN, drawan);
but i need to be able to click each box.
please help!!
View Replies !
View Related
Questions About MouseEvent
Getting back into this after my long hiatus from using Flex2.
In Flash CS3, I'm handling a MouseEvent.CLICK.
1) Looking at the root of the event in the debugger, I see e.shiftKey, e.altKey, etc...but if I refer to them - i.e. if (e.shiftKey == true) { - I get the error:
"1119: Access of possibly undefined property shiftKey through a reference with static type flash.events:Event."
Why?
2) I'm also seeing the same properties with "m_" in front of them - i.e. m_altKey, m_shiftKey, etc - what's the difference?
View Replies !
View Related
MouseEvent.ctrlKey
Anybody know how to use this?
Code:
clip.addEventListener(MouseEvent.ctrlKey, handler);
My thought was that it would check if the ctrlKey was down and if so, run the handler except the only thing I get is this error:
1119: Access of possibly undefined property ctrlKey through a reference with static type Class.
View Replies !
View Related
MouseEvent For Every Frame
Hi, this may be a stupid question since I'm still new to AS3.
I was trying to make a particle emitter that shoots out particles when the mouse button is clicked and stops when it's not. The problem I'm having is that it only shoots out one particle at a time when I click rather than a continuous fountain. I used MOUSE_DOWN for this one which didn't give me errors, but when I tried buttonDown, I got the error: "1119: Access of possibly undefined property buttonDown through a reference with static type Class."
Also I tried combining MOUSE_DOWN with ENTER_FRAME but that didn't even come close to working. There's got to be an easy way to do this that I'm just not seeing.
View Replies !
View Related
MouseEvent Questions
I have my navigational menu. It is set so that the word "home" is italicized and pink. When it is mouse rolled over it changes to a different font that is not italicized and is white.
I need it so that if the user clicks on that "home" button then it STAY's white and un-italicized exactly how the roll over worked.
I have tried all the different mouse events but none seem to work because as soon as I move the mouse away from the "home" button it goes back to its original state whether I clicked on it or not. The entire navigational menu is one movie clip so that takes out some options I believe.
Thanks!
View Replies !
View Related
PerspectiveProjection + MouseEvent = Bug?
Hello All,
i noticied that there is a problem when using the PerspectiveProjection in flash on a container that contains childs where they also have 3D manipulation here's a sample code and i ll explain the problem
ActionScript Code:
var sp:Sprite=new Sprite();
sp.graphics.beginFill(0x00FF00,1);
sp.graphics.drawRect(-50,-50,100,100);
sp.graphics.endFill();
sp.rotationY=45;
var container:Sprite=new Sprite();
container.transform.perspectiveProjection = new PerspectiveProjection();
container.transform.perspectiveProjection.projectionCenter = new Point(0, 0);
container.addChild(sp);
addChild(container);
container.x=stage.stageWidth/2;
container.y=stage.stageHeight/2;
sp.addEventListener(MouseEvent.CLICK,handleClick);
sp.useHandCursor=true;
sp.buttonMode=true;
function handleClick(e:MouseEvent):void{
trace(e);
}
container.addEventListener(MouseEvent.CLICK,handleClick);
container.useHandCursor=true;
container.buttonMode=true;
container.rotationY= 0;
try to run the code you ll notice that the mouse event isnt occuring
now try to comment the last line
ActionScript Code:
container.rotationY= 0;
which mean that the container isnt in 3D space.
so the mouse event occurs,
however if you dont set a new PerspectivePoint which is commenting this 2 lines it will work!
ActionScript Code:
container.transform.perspectiveProjection = new PerspectiveProjection();
container.transform.perspectiveProjection.projectionCenter = new Point(0, 0);
and keep the last line uncommented
ActionScript Code:
container.rotationY= 0;
any idea why this is happening?
cheers
View Replies !
View Related
'MouseEvent' Could Not Be Loaded.
I'm trying to get a flash movie to redirect on a click. I used the sample code below:
inv_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest("
View Replies !
View Related
MouseEvent And External SWF
I'm loading an external SWF to use as a "skin" (no components are involved, only MovieClips). The external SWF contains a number of MovieClips, each exported for Actionscript and with an associated class. One of these classes is, for example, called "Thing1".
I'm successfully loading the SWF using Loader, etc. - I'm also setting its ApplicationDomain to that same one as the loading SWF. I can then successfully create an instance of Thing1 and add it to a child MovieClip of the loading SWF. All is good.. the problem occurs when I try to add an event listener to the instance of Thing1 - the event doesn't trigger.
Here are some curious facts: IF Thing1 consists only of graphics, ie. no child MovieClips, then the event DOES trigger. Also, if I add an event listener, not to a child of Thing1, but to a child of a child of Thing1, then it works. BUT, a mouse event added to the stage of that MovieClip doesn't trigger.
There seems to be some problem with mouse events bubbling across the "boundary" between Thing1 and the loading SWF. Anyone??
View Replies !
View Related
MouseEvent.MOUSE_OVER HELP
Hey this is my first post in a forum ever, and I don't know if I will post this question right, but I am working on a simple menu system in AS3 that consists of some movie clips to move when moused over.
But when I run my code I get an error that I don't understand
1061: Call to a possibly undefined method addEventListener through a reference with static type Class.
This is my code that I am using, could anyone enlighten me as to what this error means?
ActionScript Code:
package { import flash.display.*; import flash.events.*; public class blueBox extends MovieClip{ public function blueBox () { blueBox.addEventListener(MouseEvent.MOUSE_OVER, menuMove); } public function menuMove (event:MouseEvent):void { this.x++; } }}
- Confused????
- boomStick
View Replies !
View Related
MouseEvent Problem
Hi guys,
I have a child Sprite called Table that's smaller than the main window, and the Table has a child called Bat, like this:
Main
-Table
--Bat
Here is the problem: when I handle MOUSE_MOVE in Table it will trigger when the mouse is over Bat, even though I have Bat.mouseEnabled=false. Also, if the Bat is outside of the Table it triggers it with mouse coordinates that are greater/less than the table itself, which makes no sense.
I'd like for the Bat to not trigger anything, but if it has to I need to know that it came from Bat when handling it.
What should I do ?
View Replies !
View Related
Remove MouseEvent ?
hi,
I have a AS3 problem and i'm pretty lost on that probably easy stuff.
I have a mc that serves as a button:
PHP Code:
myButton.addEventListener(MouseEvent.CLICK,click);
Then i just want to "kill" that mouseEvent...i have no clue. I tried removeEventListener but it seems not to work. Any idea ?
Thank's in advance.
View Replies !
View Related
[AS3] - .png + MouseEvent.CLICK
Hey everyone, I have a pretty difficult question (for me at least) and I'm hoping that someone can provide an answer, even if that answer is "can't be done". I have searched quite a few places and haven't found anything on this.
Lets say I have a .png, and its a complicated shape like an "S" or something. When you save the .png it gets wrapped in bounding boxes and comes out as a "square"ish shape.
Is there any way that I can have just the actual image portion of the .png interact with MouseEvents, and not the image itself (not the "dead" space)?
i.e. were I to click on the image to interact with it, the click event would only trigger if I clicked somewhere on the "S" portion of the graphic not any of the transparent portions of the image.
View Replies !
View Related
MouseEvent Listener
I'm using Flash9, AS 3
Trying to get the DOUBLE_CLICK event to work in my test movie, but its not registering the doubleclick of the mouse.
here's my code:
ActionScript Code:
import flash.events.MouseEvent;
mc_powerBTN.addEventListener(MouseEvent.CLICK, powerClick);
mc_powerBTN.addEventListener(MouseEvent.DOUBLE_CLICK, powerClick);
function powerClick(event:MouseEvent):void{
trace(event);
if(event.type=="click"){
trace("singleClick");
}
if(event.type=="doubleClick"){
trace("doubleClick");
}
}
View Replies !
View Related
[AS3] - .png + MouseEvent.CLICK
Hey everyone, I have a pretty difficult question (for me at least) and I'm hoping that someone can provide an answer, even if that answer is "can't be done". I have searched quite a few places and haven't found anything on this.
Lets say I have a .png, and its a complicated shape like an "S" or something. When you save the .png it gets wrapped in bounding boxes and comes out as a "square"ish shape.
Is there any way that I can have just the actual image portion of the .png interact with MouseEvents, and not the image itself (not the "dead" space)?
i.e. were I to click on the image to interact with it, the click event would only trigger if I clicked somewhere on the "S" portion of the graphic not any of the transparent portions of the image.
View Replies !
View Related
MouseEvent Do Interfer
how come other is getting triggerd while there isnt any reason for! ?
Code:
// main button
var spriteButton:Sprite = new Sprite();
spriteButton.name = "spriteButton";
var other:Sprite = new Sprite();
other.name = "Other";
// graphics
var spriteGraphics1:Sprite = createGraphics("spriteGraphics1", 0xFF, 150, 200, 100);
var spriteGraphics2:Sprite = createGraphics("spriteGraphics2", 0x80, 125, 200, 25);
var spriteGraphics3:Sprite = createGraphics("spriteGraphics3", 0x80, 200, 200, 25);
// add to display list
other.addChild(spriteGraphics1);
spriteButton.addChild(spriteGraphics2);
spriteButton.addChild(spriteGraphics3);
addChild(other);
addChild(spriteButton);
// events
spriteButton.addEventListener(MouseEvent.ROLL_OVER , over);
spriteButton.addEventListener(MouseEvent.ROLL_OUT, out);
other.addEventListener(MouseEvent.ROLL_OVER, over);
other.addEventListener(MouseEvent.ROLL_OUT, out);
function over(evt:MouseEvent):void {
trace("over: " + evt.target.name);
}
function out(evt:MouseEvent):void {
trace("out: " + evt.target.name);
}
// create circles
function createGraphics(name:String, color:uint, x:Number, y:Number, radius:Number):Sprite {
var circle:Sprite = new Sprite();
circle.name = name;
circle.graphics.beginFill(color);
circle.graphics.drawCircle(x, y, radius);
return circle;
}
View Replies !
View Related
Having Problems With MouseEvent
I am working with the code used in the Advanced after effect button tutorial, but i receive an error saying "The class or interface 'MouseEvent' could not be loaded.".
Now i have looked around and what i have found is that MouseEvent is a basic and standard program of Flash CS3! but i have looked everywhere on my computer and i can not find it.
Can someone help me PLEASE!!!!!!
View Replies !
View Related
Delayed Function On MouseEvent?
I am using the on (rollover) attribute of a button to call a function, but what is the SIMPLEST way to introduce a delay of say, 1 second, either in the function or the on(rollover) so that the function is not executed immediately? Is there a Flash equivalent of the JS timeout?
View Replies !
View Related
Ignore MouseEvent.CLICK
Hey Guys,
I have a hard time catching the mouse click on the movieclips that I want to act on. I have 2 layers on the main timeline: 1) text label (wrapped in a MC) and 2) 2 movieclips that I want to catch the click event from.
In actionscript 2.0, it is really easy. I only need to set the onRelease function for the 2 movieclips. I can just ignore the text. This way, I can catch the click action on the movieclips that i set onRelease for with my mouse over text. But, now, I can't. Because if I click with my mouse over the text, the returned target is the text.
My question is how can I do to ignore the mouse click event for my labels?
I have attached the fla
Thanks,
Justin
View Replies !
View Related
Can You Call A MouseEvent Without Actually Using The Mouse
hi...i have a mouseEvent that sort of runs the core of a menu i am making. User clicks a button, things happen, page loads. The menu has a method that checks to see the page we are on...thus, when the html page loads, the familiar menu will open to display where we are. i need to utilize the mouseEvent to have the menu appear correctly, however at times, a user could arrive to a page without clicking there. IE- user types www.website.com/tellMemore.php into the browser...the menu will need to open and highlight the tellmemoreButton. User invoked with a mouse is fine, but can you call a mouseEvent without actually using the mouse?
PHP Code:
private function showSub(me:MouseEvent):void
{
var bx:TG_Button=TG_Button(me.currentTarget);
if(this.selectedCatagory!=null && this.selectedCatagory!=bx){
hideSub(this.selectedCatagory);
}
if(this.selectedCatagory==bx){
return;
}
this.selectedCatagory=bx
bx.upDown="down";
.....blah, blah
View Replies !
View Related
Can I Invoke MouseEvent With ContextMenuEvent?
I’m new to both Flash and AS3 so hopefully I can explain my problem correctly. And if anyone has ideas on how to better approach what I’m trying to accomplish, please offer up some suggestions.
I’m producing some training and have the students click through various ‘hot spots’ on several screen captures to simulate the actual steps. At one point they are required to right click and select an option which just takes them to the subsequent step. I’ve customized my context menu.
I have a showStep function call by MouseEvent.CLICK that advances through an image array and advances the array index. When the image is loaded a function then creates the hot spots. I’ve successfully added the custom menu to the correct hot spot and have an event listener using ContextMenuEvent.MENU_ITEM_SELECT that passes to a function I want to then invoke showStep again.
Here’s where I’m stuck. When I select the right menu item, it activates the contextMenuOwner hot spot that I can then click to advance the image. I want to advance the image by selecting the right menu item which calls the MouseEvent obj via showSteps.
Hopefully all of that made sense. Here are the snippets I think are appropriate.
Code:
//set hit areas
var newHitArea:Sprite;
//from customizingContextMenu
var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltInItems();
var mainTimeline:MovieClip = this;
mainTimeline.contextMenu = myMenu;
//rc menu to be used with hit area
var newRCMenu:ContextMenu = new ContextMenu();
newRCMenu.hideBuiltInItems();
var createNode:ContextMenuItem = new ContextMenuItem("Create Node");
createNode.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doMenuEvent);
function doMenuEvent(evtObj:ContextMenuEvent):void{
var tgtObj:DisplayObject = evtObj.contextMenuOwner as DisplayObject;
var tgtMenuObj:ContextMenu = evtObj.currentTarget as ContextMenu;
tgtObj.addEventListener(MouseEvent.CLICK, showSteps);
tgtObj.dispatchEvent(new MouseEvent("CLICK"));
}
function showSteps(evtObj:MouseEvent):void{
stepImg.visible = true;
stepImg.load(new URLRequest("../images/"+imgArr[thisStep][0]));
stepImg.x = layerX;
stepImg.y = layerY;
addChild(stepImg);
makeHitArea(thisStep);
thisStep++;
}
function makeHitArea(currStep){
if (newHitArea){
removeChild(newHitArea);
}
newHitArea = new Sprite();
// ... make hit area
hitAreaType = imgArr[currStep][1];
if (hitAreaType == "rc"){
newHitArea.contextMenu = newRCMenu;
newRCMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);
}else{
newHitArea.addEventListener(MouseEvent.CLICK, showSteps);
}
addChild(newHitArea);
}
// borrowed from Adobe examples: Custom Context Menus
function menuSelectHandler(evtObj:ContextMenuEvent):void {
var obj:DisplayObject = evtObj.contextMenuOwner as DisplayObject;
var menuObj:ContextMenu = evtObj.currentTarget as ContextMenu;
menuObj.customItems = [];
menuObj.customItems.push(createNode);
}
View Replies !
View Related
MouseEvent Best Practice For Argument Name
I notice some people use the argument name (and reserved keyword?) "event" and some people use their own name for the MouseEvent.
Which is the best practice and why?
-- EXAMPLE 1 --
myButton_btn.addEventListener(MouseEvent.CLICK, fcall);
function fcall(event:MouseEvent):void {
// do this
}
-- EXAMPLE 2 --
myButton_btn.addEventListener(MouseEvent.CLICK, fcall);
function fcall(myUniqueName:MouseEvent):void {
// do this
}
View Replies !
View Related
MouseEvent.CLICK Question?
Hey everyone
I have an object called diarypost. Inside diarypost I have a textfield. Now in my mainclass I have an eventListener that listens to the MouseEvent.CLICK like this:
Code:
diarypost.addEventListener(MouseEvent.CLICK, sendPostEvent);
It works fine, and when I click it it executes the sendPostEvent function. the problem is, that if I click in the textfield it sends the textfield inside the diarypost as the event target, and not the diarypost object itself. I want it only to send the diarypost object as the event target, not an specific objects inside the diarypost object. How do I do this?
Thanks
View Replies !
View Related
Object Not Recognizing A MouseEvent
Alright, I made a scrollbar class. It creates a background rectangle, and a bar rectangle. If I add MOUSE_DOWN event to the whole MC it recognizes it, but if I add it to the rectangle, it doesn't. here's my code (I deleted some code so you can see easier):
Code:
package com.bizzark{
//import stuff here...
public class Scroller extends MovieClip {
private var rect:Rectangle;
private var slider:Shape = new Shape();
private var bg:Shape = new Shape();
public var sliderObject:Object;
private var slider_tween:Tween = new Tween(slider, "y", Elastic.easeInOut, slider.y, bg.height, 3, true);
function Scroller(){
slider.graphics.beginFill(0xFFC133, 1);
slider.graphics.drawRect(0, 0, 10, 60); // x, y, width, height
slider.graphics.endFill();
bg.graphics.beginFill(0xCCCCCC, 1);
bg.graphics.drawRect(0, 0, 10, 241); // x, y, width, height
bg.graphics.endFill();
addChild(bg);
addChild(slider);
}
private function positionMessage(e:Event) {
//taken out...
}
function moveIn(obj:Object, t) {
slider.addEventListener(MouseEvent.MOUSE_DOWN, sliderDown); // THIS DOESN'T WORK
addEventListener(MouseEvent.MOUSE_DOWN, sliderDown); // THIS WORKS
slider.addEventListener("enterFrame", positionMessage);
addEventListener(MouseEvent.MOUSE_UP, sliderUp);
addEventListener(Event.RESIZE, resizeEvent);
addEventListener("enterFrame", watchPos);
checkNeed();
}
function sliderDown(e:Event) {
trace("DOWN");
}
///etc etc...
}
}
View Replies !
View Related
MouseEvent Listeners And Depth
Hey guys, I have a question about Mouse Events. If there are two movieclips on the stage and one is partly on top of the other, and let's say the bottom-most one has an eventListener for MOUSE_DOWN, how do I prevent the top movieclip from blocking clicks?
In other words, I'd like the bottom, partially obscured movieclip to have its MOUSE_DOWN event triggered even when the top most movie clip is clicked (so long as it is clicked within where the boundaries of the lower one would be).
Thanks for any help,
Supra
View Replies !
View Related
Public Methods Value From MouseEvent
I have a class with public get and set functions. I am trying to get the values of those methods from a mouse over event, but get the following error:
Error #1069: Property linkName not found on flash.display.Sprite and there is no default value.
Here is my code
Main Timeline:
Code:
var menuItem_btn:BaseMenuItem= new BaseMenuItem(link.attribute("linkName"),link.attribute("xmlFile"),link.attribute("type"))
menuItem_btn.addEventListener(MouseEvent.CLICK, navClicked);
addChild(menuItem_btn)
function navClicked(e:MouseEvent):void
{
e.target.linkName
}
BaseMenuItem.as
Code:
package com.dpp
{
import flash.display.MovieClip
import flash.display.Sprite
import flash.text.TextField
public class BaseMenuItem extends Sprite
{
import flash.filters.DropShadowFilter;
import flash.events.MouseEvent;
private var _linkName:String;
private var _fileLoc:String;
private var _navType:String;
private var btn_txt:TextField = new TextField()
public function set linkName(testName:String):void
{
if(testName.length >= 3)
{
_linkName = testName;
btn_txt.text = _linkName;
}else{
trace("Invalid Name");
}
}
public function get linkName():String
{
if(_linkName != null)
{
return _linkName;
}else{
trace("Name not set");
return _linkName;
}
}
public function set fileLoc(file:String):void
{
_fileLoc = file;
}
public function get fileLoc():String
{
if(_fileLoc != null)
{
return _fileLoc;
}else{
trace("File location not set");
return _fileLoc;
}
}
private function makeBG():Sprite
{
var rect:Sprite = new Sprite()
rect.graphics.beginFill(0x324d00,.75);
rect.graphics.lineStyle(1,0x4a6994);
rect.graphics.drawRect(0,0,250,30);
rect.graphics.endFill();
var rectShadow:DropShadowFilter = new DropShadowFilter(5,90,0x000000,.5,5,5);
rect.filters = [rectShadow];
return rect;
}
public function SVIBaseMenuItem (inputName:String, inputLoc:String, inputType:String):void
{
import caurina.transitions.Tweener;
import flash.text.TextFormat;
import flash.text.TextField;
import flash.text.AntiAliasType;
import flash.text.TextFieldAutoSize;
trace("New Base Menu Item");
linkName = inputName;
fileLoc = inputLoc;
navType = inputType;
var bg_mc:Sprite = makeBG();
bg_mc.buttonMode = true;
var btn_frmt:TextFormat = new TextFormat();
btn_frmt.align = "center";
btn_frmt.color = 0xFFFFFF;
btn_frmt.font = "copperplate32bc"
btn_frmt.size = 18;
btn_txt.width = bg_mc.width;
btn_txt.height = bg_mc.height;
btn_txt.y = 3;
btn_txt.antiAliasType = AntiAliasType.NORMAL;
btn_txt.autoSize = TextFieldAutoSize.CENTER;
btn_txt.defaultTextFormat = btn_frmt;
btn_txt.selectable = false;
btn_txt.text = linkName;
bg_mc.addChild(btn_txt);
bg_mc.mouseChildren = false;
addChild(bg_mc);
bg_mc.addEventListener(MouseEvent.ROLL_OVER,navOver);
bg_mc.addEventListener(MouseEvent.ROLL_OUT,navOut);
function navOver(e:MouseEvent):void
{
Tweener.addTween(btn_txt, {y:0, time:.25, transition:"easeOutSine"});
}
function navOut(e:MouseEvent):void
{
Tweener.addTween(btn_txt, {y:3, time:.25, transition:"easeInSine"});
}
}
}
}
View Replies !
View Related
Ignore MouseEvent.CLICK
Hey Guys,
I have a hard time catching the mouse click on the movieclips that I want to act on. I have 2 layers on the main timeline: 1) text label (wrapped in a MC) and 2) 2 movieclips that I want to catch the click event from.
In actionscript 2.0, it is really easy. I only need to set the onRelease function for the 2 movieclips. I can just ignore the text. This way, I can catch the click action on the movieclips that i set onRelease for with my mouse over text. But, now, I can't. Because if I click with my mouse over the text, the returned target is the text.
My question is how can I do to ignore the mouse click event for my labels?
I have attached the fla
Thanks,
Justin
View Replies !
View Related
Simple MouseEvent Not Working
I've got this on my FLA timeline:
ActionScript Code:
var blackButton:Black = new Black();
blackButton.x = stage.stageWidth / 2;
blackButton.y = stage.stageHeight / 2;
addChild(blackButton);
trace(blackButton.toString());
blackButton.addEventListener(MouseEvent.CLICK, traceIt);
function traceIt():void {}
I get this in the output panel:
ArgumentError: Error #1063: Argument count mismatch on xmlLoader_fla::MainTimeline/traceIt(). Expected 0, got 1.
What am I missing?
View Replies !
View Related
MouseEvent AddEventListener In Constructor
I am trying to create a class that has a listener for a MouseEvent
but when I create a Listener I get errors.
1180: Call to a possibly undefined method addEventListener.
Code:
package as3.util{
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.utils.clearInterval;
import flash.utils.setInterval;
//import mx.core.Application;
public class IdleUserWatcher {
// is the user active?
private var __isActive : Boolean = false;
// the id for the interval
private var intervalID : Number;
// how long to wait before calling is idle... default is 10 seconds
private var idleTime : Number = 1000;
// a list of all objects listening
private var listeners : Array;
// readonly property for isActive
public function get isActive():Boolean {
return this.__isActive;
}
public function IdleUserWatcher(idleTime:Number = 1000) {
//this.addEventListener(MouseEvent.MOUSE_MOVE, this.onMouseMove);
addEventListener(MouseEvent.MOUSE_MOVE, this.testFunction);
//this.addEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
listeners = new Array();
}
public function testFunction():void{
trace("HERE");
}
}
}
View Replies !
View Related
Extending MouseEvent Class
Hey guys,
I'm trying to see if I can add a parameter to pass a Number Variable through AddEventListener. I'm trying to create a custom class. Here's what I have thus far.
Code:
package
{
import flash.events.MouseEvent;
public class MapMouse extends MouseEvent
{
public var _mapNum:Number;
public function MapMouse(MapNumber:_mapNum):void
{
this.addEventListener(MouseEvent.CLICK, _mapNum, mapChange);
}
}
}
This would be called using an EventListener, with an additional parameter, looking something like this.
Code:
this.mapMC.TAMUmap.mapGraphic.academic_btn.addEventListener(MouseEvent.CLICK, mapChange, _mapNum);
But I'm getting errors thrown at me when I try to run this:
1046: Type was not found or was not a compile-time constant: _mapNum.
and
5000: The class 'mapMouse' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.
Any suggestions would be greatly appreciated. THANKS!!!
View Replies !
View Related
How Can Mc_instance Listen For MouseEvent?
hello;
my_mc_instance.addEventListener( MouseEvent.MOUSE_DOWN , a_function ) ;
I do not understand why my_mc_instance even knows what a mouseevent is; I mean I have to know what a "knock on the door" is before I can listen for it;
movieclips DO NOT inherit from: Mouse or MouseEvent or even Event;
movieclips inherit from:
MovieClip --> Sprite --> DisplayObjectContainer --> InteractiveObject --> DisplayObject --> EventDispatcher --> Object
it would seem to me that trying to add a mouseevent listener to my_mc_instance would never fire since movieclips do not inherit any mouse-related stuff;
furthermore, according to MovieClip.as, MovieClip class already has methods that are apparently firing for the mouseevents:
ActionScript Code:
...
function onMouseDown():Void;
function onMouseMove():Void;
function onMouseUp():Void;
function onPress():Void;
function onRelease():Void;
function onReleaseOutside():Void;
function onRollOut():Void;
function onRollOver():Void;
...
which makes me wonder why it is even necessary to add mouse-related listeners to a mc;
any thoughts?
View Replies !
View Related
|