ActionScript 3.0 :: Create A Single Movieclip That Responds To The Same Input (mouse Click) In Two Different Ways?
Apr 4, 2010
i'd like to create a single movieclip that responds to the same input (mouse click) in two different ways: if playhead is on frame labeled "one" go to frame labeled "two", otherwise if playhead is on frame labeled "two" go to frame labeled "one". i've tried if/else and switch statements with no success - what's a good approach to doing this?
View 1 Replies
Similar Posts:
Jan 20, 2010
I'm pretty new to Flash and seem to be struggling with variable scope, events and where to put code within movieclips/main area etc. What I'm trying to do is produce a Flash movie that will allow the user to click on a tool from a selection, i.e. a circle, then click on another part of the screen to place the centre of the circle, with a second click to set the radius of the circle (an alternative would be a single click and drag to place the circle and drag it out to the desired radius.) Once the mouse if clicked a 2nd time, or the drag operation is completed, the circle will stay at the selected radius.
The code I'm using so far to test out the idea is below:
_root.onEnterFrame=function(){
_root["item1"].onMouseMove=function(){
d = Math.sqrt(Math.abs(_xmouse-this._x)*Math.abs(_xmouse-this._x)+Math.abs(_ymouse-this._y)*Math.abs(_ymouse-this._y));
if(d<370){
this._width = d*2;
this._height = d*2;
}else{
this._width = 87;
this._height = 87;
}}}
This uses a simple circle movieclip, and the above code is placed in Frame 1 of the background as opposed to the movieclip itself. It resizes the circle movieclip ok, but I want to be able to control the resize with the mouse or with a single click/drag.
View 10 Replies
May 12, 2010
Lets say i have a button on frame 1. And if you press it normal, you ll get to frame 2. But then if you click it on another way, you ll get to frame 3. How do i do that easy?! With another way i mean like shift click or ctrl click or is it an easier way?
View 3 Replies
Jan 13, 2010
I'm building a historical timeline app in Flash. The main feature will be an MC containing links to specific event in the history of an organization. The MC will scroll, and there will be a couple ways to scroll it. One type of navigation will be fwd/backward buttons, and I want them to work such that if the button is pressed and held, an MC containing links will scroll w/increasing speed (up to a limit), but if the button is clicked, it will just move the MC a specified amt.
An example of what I want to accomplish can be seen it this HP timeline: [URL]
I think I could do this w/a MOUSE_UP eventListener
View 2 Replies
Jul 21, 2011
I know that datagrid can detect changes of single mouse click with
//add listener
myDataGridList.addEventListener(Event.CHANGE, myDataGridListChange);
public function myDataGridListChange(e:Event):void{
trace(myDataGridList.selectedItem.id);
}
but can they detect double mouse click?My purpose of doing this is that, if the user double click on a datagrid row, I need it to return me value of myDataGridList.selectedItem.id, so that I'm able to continue to proceed to the next stage of my game.
View 4 Replies
Nov 15, 2010
Can I create a single event listener for all mouse events ?
my understanding is no because: what's happening is that each listener is checking for a string in an event and comparing it for a match against a list which is the listener.
View 7 Replies
Aug 13, 2009
What I need to accomplish is advancing (playing) the timeline each time the same movieclip is clicked. It's basically an animation of a clock and each time the user clicks on the the clock face i would like to have the hands animate to a certain time. Everything will be set up with frame labels and stops on certain frames. I'm just not sure how to start this. instance name: clockface_btn
View 1 Replies
Jun 11, 2010
I have one movieclip inside which I created few movieclips...I applied drag drop functionality to main movieclip with which all movieclips inside of it also get dragged along with it..and I want inside movieclips to act as buttons meaning on clicking perticular movieclip it should perform perticular event assigned to it... How to make movieclips into buttons and the main movieclip containing these buttons with drag drop functionality?
View 2 Replies
Jan 3, 2004
I've just finished a simple Flash 5 game in ActionScript. Everything about it works fine except when I try and turn it into a web page. After I create the page, the graphic controlled by the player no longer responds to the keyboard. Can anyone explain why this is and how I can fix it?
View 4 Replies
Oct 19, 2010
If I plan to implement 100 objects on stage to be listen to mouse and keyboard input, is using "function" call responsive enough? How good does eventlistner work?
View 2 Replies
Jan 11, 2009
it might sound weird but what i need is... Create a movieclip, with an instance name, when i click with my mouse left button, anywhere i click! i don't even know if it's possible(Anyway if you wonder why i need this, i'll explain:in a certain level of my game, you play with a m�ssile launcher, and there's enemies in front of you, when you "fire" against them, (so, when you left click) your pointer (or mouse arrow) create's a movieclip that is an explosion, and, if this explosion hit's the enemies, they die
View 2 Replies
Dec 5, 2010
I write some working code that creates a circle on mouse click with a radius of 5 and with a random colour each time...I have the code to create the circle and the code for the random colour here:
var myColour:Number = Math.floor(Math.random()*0xFFFFFF);
this.graphics.beginFill(myColour);
this.graphics.drawCircle(0, 0, 10);
this.graphics.endFill();
Essentially I want to create a Flash application that places random coloured circles with a radius of 5 on the stage with a centre location of the mouse position each time a user clicks.
View 5 Replies
Jan 31, 2007
I'm trying to create flash app where a single jpeg (person headshot) is loaded into the masked movieclip (same size as passport photo) (using loadMovie), then user can edit the image (drag inside mask, zoom, rotate) and then after pressing a button the app duplicates the EDITED image 4 times - to make sort of headshot sheet.
While I know how to load movie, drag single clip or scale it, I have no idea how to duplicate the movieclip once is edited, to make identical copies of it (scaled, rotated...)If I use duplicateMovieClip it won't work since it won't duplicate the loaded image.
View 3 Replies
Jul 5, 2010
I want to create a class where when you mouse click on an instance of it, all other instances are notified about this click.
I want this functionality to be inside the class so there wll be no need to write any code outside the class definition, like assigning listeners to all instances and such.I wrote the following code but the event I dispatch doesn't get catched.
package sample{ import flash.events.EventDispatcher; import flash.events.MouseEvent; import flash.display.MovieClip; import flash.events.Event; public class labels extends MovieClip { var dispatcher:EventDispatcher = new EventDispatcher(); public function labels() { this.buttonMode = true;
[code]...
View 8 Replies
Apr 27, 2011
When someone "click and holds" I want to fire off function over and over, say, once every 100ms while the mouse is clicked. Instead of MouseEvent.CLICK I would look for MouseEvent.MOUSE_DOWN and then start a timer on that event function that calls another function every 100ms. Then, on MouseEvent.MOUSE_UP I would stop the timer. Am I on the right track? Will I be able to get updated X and Y coordinates while the mousedown event is firing?
View 3 Replies
Feb 3, 2011
can i define a flash event as double click or single click
View 3 Replies
Oct 7, 2009
from various books, I know that to add eventlisenter for mouse click to a movieclip:
movieClipName.addEventListener (MouseEvent.CLICK, clickFunction);
then I define the function
function clickFunction(event:MouseEvent)
{ bla bla bla }
My questions are (as silly as they might sound!),
a) why do we need a parameter (i.e. event:MouseEvent) for clickFunction??
b) since we have a parameter for clickFunction, when we feed this function into addEventListener, why didn't we write movieClipName.addEventListener (MouseEvent.CLICK, clickFunction() );
View 3 Replies
Feb 3, 2012
I want to add a Single Clcik event and Double click event both on the same movie clip in as3 , its working but call both the event same time so how to fix it
View 1 Replies
Apr 20, 2004
How do I get a movieclip to move to the mouse when it is clicked and released and have it rotate in the direction that it moves?
View 5 Replies
Jun 6, 2011
It is possible to create a "virtual mouse" which will be click on links on the HTML page loaded into HTMLLoader? I tried to do this using the class senocular .url... but it does not work.[code]
View 0 Replies
Feb 15, 2010
Imagine we have a MovieClip called "box". When I click somewhere on the screen, I want the box MC to move to that position. So I wrote something like this (just for horizontal movement):
PHP Code:
onMouseDown=function(){moveTo(_xmouse);};
function moveTo(newx){box.onEnterFrame=function(){if(box._x<newx){box._x+=5;
}else if(box._x>newx){box._x-=5;}else{delete box.onEnterFrame;}};}
Now this works to a degree, except that when the box MC moves to the right position, it then proceeds to vibrate on the spot. I thought it was probably because it can never move to the exact position of _xmouse because I'm adding 10 to the x property which is why the condition is never met. However even if I just add 1 instead of 10, I still have the same problem..
View 3 Replies
Aug 2, 2009
I wish make a zoom with tweenlite library on a movieclip.But I wish zoom on a focus where the user click.The user step are like this:step1: the user go on a place over the picturesstep2: clickstep3: zoom to the click placeHow I can do it in AS 3.0?
View 1 Replies
May 20, 2009
I'm not proud of my subject line, but it was the best I could do.I'm using this while loop to activate the function buttonpressed from one of five buttons named thumb0, thumb1, etc.:i = -1; while (i++ < 4){this["thumb"+(i)].addEventListener(MouseEvent.MOUSE_UP,buttonpresse d);}I want the main timeline to jump to the labeled frame corresponding with the targeted button's numberfunction buttonpressed(evt:MouseEvent):void{MovieClip(root) .gotoAndStop("clip"+[i]);}
View 2 Replies
Feb 20, 2009
I have a MovieClip of an bicycle, and I've attached and event listener for mouse clicks on that movieclip. The mouse clicks events are raised when I click on the bike, but I really want to be able to click somewhere in the entire region of the movieclip's rect (to make it easier for the audience this is for to be able to click).
View 1 Replies
Oct 20, 2010
I have a square movieclip named squarepad. What I want is when I click on it to do [some stuff] according to where the square is clicked. It should be something like this:
if ([mouseclickedx] > 1) and ([mmouseclickedx] < 10) then
[do this]
end if
View 1 Replies
Sep 2, 2011
I am trying to switch a boolean variable to true after a mouse click on a movieclip.
I want an animation to continue after the user has clicked both btn1 and btn2.
After researching this topic it appears that changing a variable inside a function will only effect code within that function and not the code outside of it - therefore my main Btn1Var and Btn2Var do not update to flase.
ActionScript Code:
stop()
var btn1Var:Boolean = false;
var btn2Var:Boolean = false;
[Code].....
Is there an easy way to change the original variable for each button to true after being clicked?
View 5 Replies
Aug 28, 2008
Not to certain how many people may need this script, but lo and behold I had need of it for my project. So, here's my script on how to add a movie clip to a Datagrid Cell via CellRenderer1) Create an Actionscript file (*.as) and call it IconCellRenderer2) Put the following code inside that file:
Code:
package
{
[code].......
View 4 Replies
Oct 25, 2010
The other is a scrub that manipulates a MovieClip, but tracks a change in mouse position from click to release, instead of tracking the changes in position of a slider playhead. But here is the download for that one:(sorry not a link due to not having over 50 posts yet, you will need to copy and paste)I have found plenty of AS1+2 ways of doing this idea, yet just haven't found any solid AS3 versions.I am currently in a class to learn Actionscript and have tried to figure out this problem yet I am just not yet to that level.
View 0 Replies
May 3, 2011
if got a question, when designing in the fla, you can create objects convert them to movieclips and then double click on that movieclip so your inside your movieclip. Now i wanted to code everything so no more designing any more just code. Now i searched google for a as3 movieclip in movieclip but cant seem to find anything.
So what i basically want is a code for; the design trick movieclip in movieclip.
View 5 Replies
Dec 29, 2009
I have create a simple tooltip movieclip that follows the mouse. the tooltip will popup when I hover over another movieclip, but when the tooltip is visible and I move the mouse onto the tooltip it disappears, because I have a mouse out event on the second movieclip to remove the tooltip. Is there a way to make the tooltip visible but not affect anything, such as mouse over and mouse out?
View 1 Replies