Boundary for movie clips following the mouse
here's my AS...
myInterval = setInterval(KBMOglobal,15);
function KBMOglobal () {
KBMOglobal1._x -= (KBMOglobal1._x - _xmouse)/10;
KBMOglobal1._y -= (KBMOglobal1._y - _ymouse)/10-2;
ok, so my movie clip follows the mouse around, with a small
delay and the y axis is slightly lowered. the stage of my movie is
380 x 640. does anyone have any suggestions on how to create a
boundary, equal to the size of my stage, that does not let the
movie clips that follow the mouse extend past? does that even make
any sense? essentially, i would like the movie clips to follow the
mouse, the entire movie clip stay visible on the stage. because of
the positioning of the items on the stage that initiate this
function, i only have to consider the width of each movie clip,
which luckily is a constant = 200. does that make any sense? let me
try this all again....
how do adjust the above function so that the movie clip,
KBMOglobal1 (which has a width of 200) stay within the horizontal
limits of the stage (which is 380)?
thanks for your time and to everyone in this forum that has
been so very helpful with all my questions in this project so far,
yall rock!
quote:
Originally posted by:
NickTheNameless
this is almost working perfectly, however i need to adjust
the boundary of the x axis. for some reason, the movie clip stops
following the mouse when it reaches half way across stage,
horizontally.
would you please be so kind to explain what your script is
doing? because i'm not a total idiot, i realize i could probably
replace 380 with 760 (double the width of the stage) and it would
work as expected. however, if you could spare the time to explain
what the following two lines are doing, step by step....i'll give
you my first born.....
KBMOglobalGeneralCancelDispatch._x<0?KBMOglobalGeneralCancelDispatch._x=0:KBMOglobalGenera lCancelDispatch._x;
KBMOglobalGeneralCancelDispatch._x>380-KBMOglobalGeneralCancelDispatch._width?KBMOglobalG eneralCancelDispatch._x=380-KBMOglobalGeneralCancelDispatch._width:KBMOglobalGeneralCancel Dispatch._x;
thanks again for your time!
do you know ?: operator? it is like if...else... statements,
when we say:
somethingIsTrue ? do1() : do2();
it is exactly same meaning like:
if (somethingIsTrue) {
do1();
} else {
do2();
Now, we look at this line:
KBMOglobalGeneralCancelDispatch._x<0?
KBMOglobalGeneralCancelDispatch._x=0:
KBMOglobalGeneralCancelDispatch._x;
it is same like
if (KBMOglobalGeneralCancelDispatch._x<0) {
KBMOglobalGeneralCancelDispatch._x=0
} else {
KBMOglobalGeneralCancelDispatch._x
Similar Messages
-
How do you make a movie clip face the mouse
How to you make a movie clip rotate so it's always facing the
mouse?thanks a lot! I got the code to work, I just modified it a
bit. -
How to make a movie clip follow the player
Ok I want to make spawn able enemies and when they get in like 5 pixles in range they start to follow the player they are moving and if they switch directions it will go to another frame that will make it look like they are running in that direction. How can this be acheived?
use Math.atan2() to find the angle between the player and enemy.
-
Premiere Elements 13 issue with the mouse on MAC OSX Yosemite 10.10.1
When I select a clip of video and move to a different place in my time line, Premiere Elements 13, will not release the clip from the mouse.
The clip follows my mouse movements and goes to other places in my time line.
I try to delete these extra insertions, but the mouse will not release the clip.
Action I’ve taken: I’ve re-installed Premiere Elements 13. Problem remains.
This issue has consumed too much of my time and does not go away. It ruins my video.
Help please.
ThanksI tried using the Guest Account on my Mac. In the Guest Account, Illustrator works perfect!
Then I started wondering what processes (tools/tweaks) I run by default on my account. Turned out the problem was called by a little background tool called RightZoom. RightZoom let's the green 'zoom' button always maximize your current window.
So thanks! Problem solved! -
How to keep a Movie Clip on the screen for 5 secs.
I am having trouble with keeping a movie clip on the screen.
I am setting it up to play a movie using the .onPress function. It
is calling the movie but only shows it for a split second. How can
I make the movie stay on the stage for 5 seconds? Here is how I
have it coded:
rc1MC.onPress = function() {
if (rc1MC.hitTest(_xmouse, _ymouse, false)){
_global.correct++;
updateStats();
var c1:MovieClip = this.attachMovie ("correct1_mc",
"correct1",4300);
var ymov = this._y;
var gravity = 20;
c1.onEnterFrame = function() {
ymov += gravity;
xmov *= 0.5;
c1._rotation += 5;
c1._x += xSpeed;
c1._y = ymov;
if (c1._y>stageHeight) {
c1.removeMovieClip();
delete this.onPress;
Thanks BrandonGot my answer...
http://forums.verizon.com/t5/FiOS-TV-Technical-Assistance/For-Those-of-You-Who-Want-to-View-Subscrib... -
HitTest for multiple Movie Clip at the same time
I have a movie it is a triangle.I duplicate it and I want to hitTest on the first triangle movie clip and I added 3 different line movie clips on the 3 side of triangle.I tried to write a code something like that.
if(firstTriangle_mc.hitTestObject(line1_mc,line2_mc,line_3mc){
trace("Ok");
but I've got error.I think it is not allowed hitTestObject for multiple Movie Clips.So is there anyone have an opinion about it?What should I do?Here is another test for multiple movie clips for hitTestPoint but only the first work the others don't
uc_mc.addEventListener(Event.ENTER_FRAME,hitle);
function hitle(e:Event) {
if (uc_mc.hitTestPoint(cub1,cub1Y,true)&&(cub2,cub2Y,true)&&(cub3,cub3Y,true)) {
uc_mc.alpha=0.5;
}else{
uc_mc.alpha=1;
The code above doesn't work.What should I do? -
my cursor moves arbitrarily. The mouse does not control it except minimally or from time to time.
There are several possible causes for this issue. Please take each of the following steps that you haven't already tried until it's resolved. Some may not apply in your case.
1. Follow the instructions in this support article, and also this one, if applicable. A damaged or defective AC adapter could be the cause, even if it's the right kind.
2. Press down all four corners of the trackpad at once and release. If there's any effect, it's likely to be temporary, and in that case the unit must be serviced or replaced.
3. Open the Bluetooth preference pane in System Preferences and delete all pointing devices other than the trackpad, if applicable. Disconnect any USB pointing devices. By a "pointing device," I mean a peripheral that moves the cursor, such as a trackpad, mouse, trackball, or graphics tablet. A plain keyboard is not a pointing device.
4. Start up in safe mode and test, preferably without launching any third-party applications. If you don't have the problem in safe mode, but it comes back when you restart as usual, stop here and post your results. Do the same if you can't start in safe mode. If there was no difference in safe mode, go on to the next step.
5. Reset the System Management Controller.
6. If you're using a Bluetooth trackpad or mouse, investigate potential sources of interference, including USB 3 devices.
7. A swollen battery in a portable computer can impinge on the trackpad from below and cause erratic behavior. If you have trouble clicking the trackpad, this is likely the reason. The battery must be replaced without delay.
8. There's a report that a (possibly defective) Thunderbolt Ethernet adapter can cause the built-in trackpad of a MacBook to behave erratically. If you're using such an adapter, disconnect it and test.
9. There's also a report of erratic cursor movements caused by an external display that was connected but not turned on.
10. If none of the above applies, or if you have another reason to think that your computer is being remotely controlled, remove it from the network by turning off Wi-Fi (or your Wi-Fi access point), disconnecting from a Bluetooth network link, and unplugging the Ethernet cable or USB modem, whichever is applicable. If the cursor movements stop at once, you should suspect an intrusion.
11. Make a "Genius" appointment at an Apple Store to have the machine and/or external trackpad tested. -
How to get the aspect ratio follow the mouse?
Hi! I'm just wondering, is there a way to have the aspect
ratio follow the mouse?
Cause I'm trying to implement Adobe Capture-videos to a
phpbb-based forum and therefore, the videos can't be any bigger
than standard youtube-videos. So I need to have the aspect ratio be
fixed and about 448x337 pixels. And when i want the mouse centered
in the video and have everything around follow the mouse.
Is there a way to do this? Or do I just have to create a link
in the forum to a new browser-window?Hi Kenny Bones and welcome to our community
Unfortunately there is no way to automatically have this
occur. With Captivate, you simply define a recording region of the
screen and grab whatever happens inside that region. I suppose one
way you *might* accomplish it would be by manually recording. In
this case, you press the Print Screen key each time you desire a
screen grab. But for what you are talking about, it would require
toggling on and off the full motion recording. (FMR) Turn on FMR,
move the window, turn off FMR, etc.
This sounds like something you might wish to suggest to the
development team. You may do this by
clicking
here and completing the form.
Cheers... Rick -
How do I recerence Movie Clips on the Main Timeline from inside a class?
Hey everyone, this might be a stupid question but I thought
I'd ask cause it's making me nuts. I'm all of 2 days into AS3
(coming from not using Flash at all in YEARS) so feel free to
consider me ignorant. I do have plenty of application development
experience in other areas though.
I can't seem to create a class that can reference an instance
of a movie clip on my main timeline. I'd post code of what I've
tried but I've gone through so many desperate edits & wild
guesses that it was just garbled junk before I deleted it all.
Basically here's how I figured Flash could work, though maybe
it doesn't work this way at all.
I'm assuming that with AS 3 being so big on being a true
object oriented environment, I wouldn't need to mix my code and
interface together. Preferably I'd be using the Flash authoring
tools just to design my interface. Create a button... place it
somewhere... give it an instance name. Roughly the equivilant of
Apple's InterfaceBuilder for those of you that might be familiar
with Cocoa development. I can see maybe having to put a few lines
of ActionScript onto frame 1 (though really I'm hoping Flash would
have a better method of kicking off the application at this point
that using code tied to frames) to load my classes & such, but
after that I'd like all of my code to be held in external class
files.
So maybe I've got:
Interface.fla - My interface
Button_1
Button_2
TextField_1
Main.as - My main controller class using to handle all of my
applications behavior
SomeClass.as - Some helper Class
SomeOtherClass.as - Some helper Class
Main.as would have instructions in its initialization method
to go ahead & attach events to buttons & initialize
anything else that needs to happen when the application starts.
From there on it would all be objects communicating back &
forth. Button_1 would get clicked with would fire
Main.someMethod(). Main.someMethod() would then do it's thing and
set the value of TextField_1. All very clean & code is very
separated from interface.
Unfortunately I can't for the life of me figure out how AS3
classes reference each other like that. There doesn't seem to be
any kind of a global 'root' or '_root' I can use to locate any
movie clips on the stage. I've searched the help & the web for
any kind of simple tutorial but to no avail. My job has tasked me
with building a flash app for a project but I'd really rather not
have a tone of ActionScript just shoved into frame 1. That just
seems... ugh! (::shudder::)
Can someone maybe point me in the right direction here? I'm
really willing to do my homework but I can't seem to locate the
info I need to get started. Also, is there an ActionScript IRC
channel or something maybe?
Thanks,
CliffI worked with the problem last night and the solution I
started coming to involved creating my own custom document class
based off which extends MovieClip. My thought is that way I have
access to the initialization routine of the timeline itself and
that all of the elements on the main timeline should be
"properties" of my custom class.
Is this correct? Is there a down side to doing this & if
so what is it & why?
Also, just for my reference, the last time I did anything
with ActionScript I think I was using '_root' to target the main
timeline. WHat are the global variable names in AS 3? Is it just
'root' & 'stage' or 'Root' & 'Stage' or what? -
Different zoom levels for different clips in the same project?
Hi
I am making a movie with videos from two different cameras. As a result some of the clips are cut down in size to a small portion of the screen. This can be solved if it is possible to use different zoom levels for different clips in the same project. I have not been able to do this. Is it possible?
kind regards
SorenYou can scale the small clips up to the same size of the larger one... but you will get a quality loss.
Using Motion or Scale to Frame Size commands
Better to scale the large ones down to a Sequence that matches the smaller clip dimensions. -
Steady Stream of "Searching for movie data in the file..." Error Messages
My iMovie has been crippled by error messages that pop up whenever I try to accomplish anything in iMovie. I always see "Searching for movie data in the file 'healyintro.mov'" for a few minutes, then "The movie file 'healyintro.mov' cannot be found. Without this file, the movie cannot play properly." I cannot actually use iMovie because of these errors.
I've tried everything from reinstalling iMovie to removing application support files to removing my iMovie Events and iMovie Projects folders to creating a .mov file, calling it healyintro.mov and seeing if that'll shut iMovie up – nothing works.
Once in a while, iMovie will ask for a different movie file, with the same problem.
Any ideas?I am having the same issue. I don't know what the previous poster means by allowing the system to continue, since I'm prompted with a "Cancel" / "Search" dialog after each missing clip. Slight digression: "Search" is not even the correct term here according to UI guidelines ("Choose" or "Locate" might be better choices given the file picker dialog that results).
I'm actually using Aperture to relocate my video masters on removable media, which is a very nice feature of Aperture, but completely breaks iMovie unless it's connected. Seems like a pretty major oversight.... can we just have it fail more gracefully here and allow us to work with new stuff without getting hung up on missing movie clips from the past? -
Dynamically adding multiple instances of a movie clip to the stage with one button
hello,
I was wondering if there was a way to add several instances
of the same movie clip to the stage dynamically utilizing one
button.
I can do one with the following code placed on the button...
on (release) {
attachMovie ("filledCircle", "filled1", 5);
filled1._x = 370;
filled1._y = 225;
But I want the user to be able to hit the button again and
get yet another instance of "filledCircle" on the stage.
I also want the user to be able to drag these instances
around...
Any help would be appreciated...
Thanks,
MuhlMuhl,
> I was wondering if there was a way to add several
> instances of the same movie clip to the stage
> dynamically utilizing one button.
Sure thing.
> I can do one with the following code placed on the
> button...
>
> on (release) {
> attachMovie ("filledCircle", "filled1", 5);
> filled1._x = 370;
> filled1._y = 225;
> }
Gotcha.
> But I want the user to be able to hit the button again
> and get yet another instance of "filledCircle" on the
> stage.
You're in luck, because this isn't very hard to do. The main
thing to
keep in mind is that each instance must have A) its own
unique instance name
and B) its own unique depth. In your example, the instance
name is filled1
and the depth is 5. The next clip's instance name should be
filled2 at a
depth of 6. Then filled3, depth 7, and so on. You can use a
single
variable to handle the incrementation.
// code in a frame
var counter:Number = 1;
// code on your button
on (release) {
attachMovie ("filledCircle", "filled" + counter, counter +
4);
With me so far? The variable counter contains the numeric
value 1. The
second parameter of attachMovie() is provided with a
concatenation of
"filled" + 1, which makes "filled1". The third parameter is
provided with
the sum of counter plus 4, which makes 5. Obviously, we need
a bit more.
The button must, in addition, increment the value of counter.
The ++
operator handles this perfectly.
on (release) {
attachMovie ("filledCircle", "filled" + counter, counter +
4);
counter++;
Now, it seems you also want to position the attached movie
clip to (370,
225). Are they call supposed to go to the same place? If so,
you may use a
second variable to hold a reference to the newly attached
clip. Look up
MovieClip.attachMovie(), and you'll see that the method
returns the exact
reference you need.
// code in a frame
var counter:Number = 1;
var mc:MovieClip;
// code on your button
on (release) {
mc = attachMovie ("filledCircle", "filled" + counter,
counter + 4);
counter++;
mc._x = 370;
mc._y = 225;
Make sense?
> I also want the user to be able to drag these instances
> around...
Then you need to handle a few events. You're dealing with
movie clips
here, so your best bet is to study up on the MovieClip class,
which defines
all movie clips. (Note, also, that the TextField class
defines all input
and dynamic text fields; the Sound class defines all sounds,
etc. This is a
very handy arrangement of the ActionScript 2.0 Language
Reference.)
// code in a frame
var counter:Number = 1;
var mc:MovieClip;
// code on your button
on (release) {
mc = attachMovie ("filledCircle", "filled" + counter,
counter + 4);
counter++;
mc._x = 370;
mc._y = 225;
mc.onPress = function() {
this.startDrag();
mc.onRelease = function() {
this.stopDrag();
Easy as that. You're simply assigning a function literal to
the event
of each new MovieClip instance as you create it. Take a look
and you'll see
each of these class members available to you -- that is, to
all movie clips.
MovieClip.onPress, MovieClip.startDrag(), MovieClip._x, etc.
Wherever it shows the term MovieClip in the Language
Reference, just
replace that with the instance name of your clip -- or a
reference to that
clip (which even includes the global "this" property).
David
stiller (at) quip (dot) net
Dev essays:
http://www.quip.net/blog/
"Luck is the residue of good design." -
Creating functions for movie-clips(serious problem)
Hello,
This is I think my third thread on these forums and in my
previous threads I had always got some help.Well, now I have
another serious problem, can you help me?
I am unable to create a function that can control movie
clips. Let me explain:-
I have 10 movie clips on the stage and I have assigned them
that whenever they crash to an object, they will go to a random
position. Writing this code ten times for each movie clip would be
very tedious, so, I thought about creating a function, but, it
doesn't work. Here's the function, can you correct it?
var object:movieClip;
function position(object) {
var testnum1:Number;
testnum1 = random(290)+36;
_root.object._y = -77.6;
_root.object._x = testnum1;
position(nameofmovieclip)
PLEASE HELP IS REQUIRED!!!!
Thanking All,
ChinmayaThanks for the reply,
I tried that, it worked!
But, now, I am encountering a really odd problem. This time
I'll give you my full code.The problem is, that now when the object
collides with another one, it changes its position according to the
code but then after a while, it just passes through the object.
Here's my code:-
function position(object) {
var testnum1:Number;
testnum1 = random(290)+36;
object._y = -77.6;
object._x = testnum1;
metal.onEnterFrame = function() {
_root.metal._y += speednum;
if (_root.metal.hitTest(_root.testline)) {
position(_root.metal);
speednum = random(6)+1;
Can you help me out again,
Thanks,
Chinmaya
P.S. I have tried to use the function like this:
position(metal), but it doesn't work. And yes, I have already
defines speednum somewhere before, so that isn't the
problem. -
Check for movie clips with AS?
Is it possible to check if a frame contain a movie clip with
AS, and then if movie clip is found run a function? Like a global
"event handler " for movie clips.I want a function that automaticly can detect and fade in any
movie clip found in any keyframe in the main timeline. So i don't
have to make
In the first keyframe in the main timeline
on (ohh here i found a movie clip)
//let's run a nice fade function on that movie clip
mx.transitions.TransitionManager.start
(eval(TheClip),
{type:mx.transitions.Fade,
direction:0,
duration:1,
easing:mx.transitions.easing.None.easeNone,
param1:empty,
param2:empty
Something like that -
RemoveChild for movie clip that was added in another function?
Hello everyone. I have 3 different functions for my preloader. I have an Event.OPEN, ProgressEvent.PROGRESS, and an Event.COMPLETE. In the event.OPEN function, I create a new variable that is data typed to the class name of my preloader that I set in it's property dialogue box. This is just a simple circle animation. Below is my code for it:
function addPreloader(event:Event):void
var myPreloader:mcPreloader = new mcPreloader();
myPreloader.x = stage.stageWidth / 2;
myPreloader.y = stage.stageHeight / 2;
myPreloader.width = 75;
myPreloader.height = 75;
addChild(myPreloader);
My ProgressEvent.PROGRESS function looks like so:
function preloadImages(event:ProgressEvent):void
var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
percent_txt.text = percent + "%";
and my Event.COMPLETE function looks like so:
function imageLoaded(event:Event):void
var myLoadedImage:Loader = Loader(event.target.loader);
addChild(myLoadedImage);
new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
event.target.loader.removeEventListener(Event.OPEN, addPreloader);
event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
The only problem is that when it's done loading, I'd like to remove the myPreloader from the stage. Since it is declared in the Event.OPEN function, I can't communicate with it via my Event.COMPLETE function. How can I successfully remove it from the stage after it's done loading? Thanks!
JesseDuh, thanks Kglad. It's been a long week ;).
Jesse
Date: Thu, 9 Jun 2011 13:47:57 -0600
From: [email protected]
To: [email protected]
Subject: removeChild for movie clip that was added in another function?
var myPreloader:mcPreloader
function addPreloader(event:Event):void
myPreloader = new mcPreloader();
myPreloader.x = stage.stageWidth / 2;
myPreloader.y = stage.stageHeight / 2;
myPreloader.width = 75;
myPreloader.height = 75;
addChild(myPreloader);
My ProgressEvent.PROGRESS function looks like so:
function preloadImages(event:ProgressEvent):void
var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
percent_txt.text = percent + "%";
and my Event.COMPLETE function looks like so:
function imageLoaded(event:Event):void
removeChild(myPreloader);
myPreloader=null;
var myLoadedImage:Loader = Loader(event.target.loader);
addChild(myLoadedImage);
new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
event.target.loader.removeEventListener(Event.OPEN, addPreloader);
event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
>
Maybe you are looking for
-
Displying wrong data after entering estimated cost while creating travel request.
Hi Team, We are facing an issue while creating travel request from portal. When we are entering estimated cost and after clicking on save and send button we are getting data is saved as correct.But after clicking on display form button the data is sh
-
I updated my iphone 5 to ios 6.0.2. my wifi says its connected but doesn't work now. It doesn't matter what wifi network I connect to. It worked before updating my phone. I can no longer use facetime or use wifi at all. I'm not sure what to do to fix
-
Any Way to Set Default Settings for HDR Toning?
I have developed a nice set of parameters for the HDR Toning feature and have saved them as Noels Defaults, but I don't see a way to make them the default settings for HDR Toning. Frankly I find the default color settings for the tool very garish.
-
[SOLVED] xfce4-powermanager-svn/kdemod-powermanager!
Hello dear Archers! - Sorry for my bad English! I have some problem with Arch x86_64 - 2.6.28-ARCH + xfce4-svn on a Toshiba laptop (dual core/4 gb ram/video intel GMA): 1. Xfce4-powermanager-svn wich don't change display brightness/change cpufreq pol
-
Connect 2013 Macbook Air to 30" Cinema Display
Hi, so I bought a DVI to thunderbolt connector and connected my macbook air to my 30" display, but it wont give the 30" monitor the full 2560x1600. Is it even possible to do this or am I stuck at driving it at a terrible resolution?