Dynamically placing movie clip at the angle and global position of a mouse click (button) which is constantly rotating.
Does anyone know the code for finding the global positioning of X & Y co-ordinates of a click of a button which is constantly rotating,
and then secondly the code for when you click on the button it displays a movie clip on top of it -(position of x & y when clicked) at the angle that you clicked it (so underneath the buttons are still rotating so other people can click them where they are)
to explain the context, I'm trying to design a mock up of a circular interactive table
when someone comes up to it and clicks on one of the buttons that are moving, it reads where the person clicked it and opens up a new box (movie clip) where they clicked it (at the angle) so its not upside down if you are at the top.
I've included my .fla file which shows the four buttons moving and a little diagram
explaining what I'm trying to do.
yourbutton.addEventListener(MouseEvent.CLICK,f);
function f(e:MouseEvent){
var yourmc:MovieClip=new YourMC();
yourmc.x=e.stageX; // if you want the mouse position where the button was clicked. else use e.currentTarget.x and e.currentTarget.y
yourmc.y=e.stageY;
yourmc.rotation=e.currentTarget.rotation;
addChild(yourmc);
Similar Messages
-
Trying to move clips in the timeline and they won't drop?
I'm trying to unlock tracks and that doesn't seem to help, what's going on? When I try to drop them in the place where I want them, instead of the cursor becoming that down arrow with the line below it, it just stays being the regular arrow cursor but with a star to the right of it and a square line appears on the timeline where I'm trying to drop the clip but it won't drop.
You can open your Project file in a text editor and see what links the project expects to find.
To do this,
1. Find your project in the iMovie/iMovie Projects/ folder. Make a copy of it, and put the copy on your desktop so you don't risk harming it in step 2. The project will have the name that you gave it, and will have the file extension RCPROJECT.
2. Open the copy of the RCPROJECT file in a text editor. You can do this by right-clicking (or control-clicking) on the project file and selecting OPEN WITH...some text editor.
You can open it in Text Edit, which comes standard on your Mac, but it may be confusing because of the hexadecimal characters. If you have access to the BBEDIT text editor, it seems to handle the hex characters better, so you can tell what is going on.
3. Now look at the links in the project file, and see where iMovie thinks they should be. If necessary, move them back there.
Hope this helps. -
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." -
i know i can slow down speed in a movie clip but can i and how do i slow down a transition clip? specifically the scrolling credits. it goes so fast i cant read it
never mind i found the answer
-
Center a dynamically generated movie clip
Hello,
I have created an empty movie clip in the root, I load
dynamically some jpg to the empty movie clip, but now I want to
center it and I can't :(
I have this code, it centers the movie clip but on the
registration point of 0,0 not in the middle of the movie clip so
the movie clip will show up nice and centered.use:
imageholder_mc._x = Stage.width - imageholder_mc._width / 2;
EDIT: lmao kg :) -
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? -
How can i fix a clip when the video and audio are not matching up?
How can i fix a clip when the video and audio are not matching up? I imported the video from a junkdrive in a .VOB format and concerted to a .mov the videos were filmed on a miniDVD recorder.
I would try detaching the audio and the dragging the audio to the left or right until it lines up.
-
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? -
Passing a variable from a movie clip to the main timeline
Hi,
I'm having trouble passing a variable from a movie clip in my
flash file to the main timeline.
I have a movieclip with the instance name IntroNav which
contains several buttons. Clicking a button sets the variable
"page" to a specific name, i.e. page = "home"
However, outside of the movie clip, on the main timeline I am
unable to call this variable, and "page" seems to have no value.
Can anyone tell me why this is and how to solve it?
ThanksUmm, yes ... declare your variables correctly.
var page:String = new String(); //proper complete
var page:String; //strict typing
var page:String = "home"; //stirct typing with value
declaration
Do not declare the variable in your buttons, you would have
to do so in every button and be constantly resetting the value.
Declare it on the main timeline at the lowest level. You do not
need to use it as a _global, you just need to resolve your path
issues. You can 'set' the variable value from a button, without any
problem, but you have to call to the variable correctly.
You do not 'name' a variable as "_root.page" , the '_root'
refers to the lowest level of the SWF or the main timeline, as does
a call to ' _level0' (that's a zero). If the variable is declared
on the main timeline, and you're calling from the MC/button or
anywhere you can refer to the variable by calling to it by
the proper path of '_root.page'
To set the variable from any of your button/MC instances
call:
_root.page = "value"; OR _level0.page = "value";
But you must have the varibale declared on the main timeline,
and only once and the playhead should be stopped or it will reset
the value to the default upon looping. -
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 -
Garage Band 10.0.2 - How do I move clips in the editor?
Pretty basic question about Garage Band 10.0.2. I find it difficult to grab and move clips in the editor - the bottom window - as I could in previous versions. Instead, I'm having to go up to the top window to move clips closer together. What am I doing wrong?
Hold down the command key, while you click the region in the track editor and drag it. Don't click the ruler, click the wave shape in the audio region.
-
How do I inactivate all other movie clips except the running one.
Hello guys
I would need help to inactivate all other actions on movie clips while the active movie clip is running. So in my flash scen when the user makes a roll over on a movie clip I would like that movie clip to play all frames in that movie clip before the user can roll over on an other movie clip. So the active movie clip don't gets interupted. What actionscript 2.0 should I look for?
Thanks!
/KlasYou could use a boolean variable in a conditional that wraps whetever functionality the objects have to prevent them from taking those actions. So when you rollover an object it starts to activate its animation or whatever and sets that boolean to prevent any others from doing the same. And when it completes its actions it rets the boolean.
If you show your rollover code it might be easier to show an example, but it might be something like...
var allowPlay = true;
mc1.onRollOver = rolloverFunction;
mc2.onRollOver = rolloverFunction;
mc3.onRollOver = rolloverFunction;
function rolloverFunction(){
if(allowPlay){
allowPlay = false;
this.play(); // or whatever action your rollover executes
and when that animation completes the movieclip resets the allowPlay to true.
_root.allowPlay = true; -
*Class Project - Please help: Why does my movie clip keep playing over and over?
I am desperate for help on this one as its my Final Flash
class project and I just can't get my scenes/movie clips to play in
the order I want them to.
I have Scene 1 (movie clip 1) that plays and then Scene 2
(movie clip 2) plays. The problem is that Scene 2 (or movie clip 2)
repeats itself over and over again. I can't get it to go back to
Scene 1 (movie clip 1) to play that again.
I want it go to to this Scene 1 and actually start at a
certain frame to continue on with the story.
I have named my movie clip instances.
What am I doing wrong? I went into movie clip 2, into
actions, and movie clip control, and I don't really see a way to
tell it to go back and play movie clip 1. Trying to see how to
refer back to the instance name of the movie clip and get it to
play.
Ideas? Please please? I would be forever greatful.
Angiequote:
Originally posted by:
computerkitten
I wonder if I should just take that movie clip out of the
scene completely.... and not have the second scene at all. Maybe I
should just have 1 scene and these 2 movie clips. Wonder if that
would work better?
As Nickels55 said, above, scenes add unnecessary complexity.
So the answer to this is: YES. Scenes are awkward in Flash. Never
use them in any final project. Put everything on a single timeline
in a single scene, and you will have much better control of the
project. -
Problem with accessing dynamically created movie clips, returns null...
Hopefully this is a stupid question with an easy answer, if my code is straight forward enough.
I am using this snippet of code to create menu items, and then use the jCount variable below to give the clips an index number, like so (which seems to be working just fine):
for(var j:Number=0;j<xmlSubMenuLength;j++){
var mcSubMenuItem:mcSubMenu=new mcSubMenu();
addChild(mcSubMenuItem);
jCount++;
mcSubMenuItem.name = "mcSubMenuItem" + jCount;
//traces out names correctly
trace ("---------------------------------jCount NAME = "+ mcSubMenuItem.name);
mcSubMenuItem.x=mcMenuHolder.x+20;
mcSubMenuItem.y =mcMenuHolder.y;
mcSubMenuItem.y+= nextBtnY;
nextBtnY+=subtopicSpace;
global_subi.text = String(jCount); //i see the proper count of 10 in the text field
However, when I try to access the clips using this snippet:
for(var j:Number=0;j<Number(global_subi.text);j++)//
trace("GLOBAL SUBI = "+ String(global_subi.text)); //traces out 10, which it should
var scSubMenuItem:String = "mcSubMenuItem" + j;
var scSubContent:Object = this.getChildByName(scSubMenuItem);
trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scSubContent:Object = "+ scSubContent); //returns null!
My last trace statement returns null. Can anyone see my error, or explain why I can't access my clips after they have been created?
Thank you muchly,
~ChiplehHi kglad,
Thanks for the response.
"it's not clear from the shown code that jCount is initialized." - I've posted the relevant code below, which shows that I'm initializing jCount.
"and it's not clear why you don't use j instead of jCount in that for-loop" - j is used as loop for creating the subtopic movie clips within the i for-loop. So, for each topic in i for-loop, create a group of suptopics using the j for-loop. The j for-loop re-initiates j every time the length of the subtopics is reached(if that makes any sense) - i.e. topic1>subtopic 1,2,3,4 : topic2>subtopic>1,2 : topic3>subtopic1,2,3,4
jCount is used to keep a running count of the total number of subtopcs created - i.e. per the example above, jCount will display 10.
var topicSpace:uint=button_mc.height;
var subtopicSpace:uint = button_mc.height;
var nextBtnY:uint = 0;//whatever;
var jCount:Number = 0;
function createXMLMenu(menuLength:Number,itemName:XMLList):void{
var navItemText:XMLList = itemName;
for(var i:Number=0;i<menuLength;i++)
var mcMenuItem:mcMenu=new mcMenu();
addChild(mcMenuItem);
mcMenuItem.btnTxt.htmlText = i+1 +". " +navItemText[i];
mcMenuItem.ivar = i;
mcMenuItem.name = "mcMenuItem" + i;
mcMenuItem.x=mcMenuHolder.x;
mcMenuItem.y =mcMenuHolder.y;
//kglad's addition
mcMenuItem.y+= nextBtnY;
nextBtnY+=topicSpace;
var subVar:Number = i;//mcMenuItem.ivar
//Submenu content
var xmlSubMenuLength:Number = xml.sim.bodyText.page[i].subpage.length()
var menuItemAttachment:MovieClip = MovieClip(mcMenuItem);
for(var j:Number=0;j<xmlSubMenuLength;j++)
var xmlSubPageNumber:XMLList = xml.sim.bodyText.page[subVar].subpage;
var subNavLinkNumber:Number = xmlSubPageNumber[j];
var subTitleText:String = xml.sim.bodyText.page[subVar].subpage.subNavItem[j];
var mcSubMenuItem:mcSubMenu=new mcSubMenu();
trace("mcSubMenuItem.ivar = "+ j+1);
var mc2Attach2:MovieClip = MovieClip(menuItemAttachment);
mcSubMenuItem.btnTxt.htmlText = j+1 +". " +subTitleText;
mcSubMenuItem.ivar = Number(subVar);
mcSubMenuItem.jvar = Number(j);
addChild(mcSubMenuItem);
jCount++;
mcSubMenuItem.name = "mcSubMenuItem" + jCount;
trace ("---------------------------------jCount NAME = "+ mcSubMenuItem.name);
mcSubMenuItem.x=mcMenuHolder.x+20;
mcSubMenuItem.y =mcMenuHolder.y;
//kglad's addition
mcSubMenuItem.y+= nextBtnY;
nextBtnY+=subtopicSpace;
global_subi.text = String(jCount);
mcSubMenuItem.lExtend.visible = false;
global_i.text = String(i);
Then I try to access the clips like so:
-The first for-loop access the topic movie clips, no problem, and traces out scContent correctly.
-The second for-loop traces out null everytime, when I would expect it to be tracing out the names of the subtopic movie clips.
function accessClips(){
//This will access the topic movie clips
for(var i:Number=0;i<Number(global_i.text);i++)
var scMenuItem:String = "mcMenuItem" + i;
var scContent:Object = this.getChildByName(scMenuItem);
trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scContent:Object = "+ scContent);
//This is supposed to access the subtopic movie clips
for(var j:Number=0;j<Number(global_subi.text);j++)//
var scSubMenuItem:String = "mcSubMenuItem" + j;
var scSubContent:Object = this.getChildByName(scSubMenuItem);
trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scSubContent:Object = "+ scSubContent);
Hope this makes sense, Chipleh confused. If the code is not clear enough, let me know and I'll try to further clarify.
Thanks again,
~Chipleh -
I cannot delete a file from the documents folder. I can move it to the trash and then empty it, but when I go back to the documents folder, the file is still there.
Gay,
I wonder what your computing environment is. Is your account being administrated by another account? Are you working in an account subject to "Parental Controls"?
Jerry
Maybe you are looking for
-
Mail no longer works right through att.my.yahoo on Firefox.
I use ''att.my.yahoo.com'' to access several e-mail accounts. Recently (perhaps about the time I upgraded to Firefox 5 or 5.0.1), I started having trouble after going to mail. I now get a different screen that says "A new look! We've improved the way
-
How do you run alien arena on leopard?
I downloaded the linux version and the mac os x patch but I can't install or run the game at all and the read me is in spanish. Any help would be greatly appreciated. Thanks in advance
-
How can I apply page watermarks to digitally signed documents
When printing a digitally signed PDF I need to apply a watermark across each page that states the hardcopy is an uncontrolled version of the document. I understand how to allow updates to specific form fields after the document has been signed, but c
-
Adding SoapHeader C# Client
I'm trying to create a c# client that consumes a web service via SOAP, the problem is that when the client call the server it sends this XML: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLS
-
HP Pavilion p7-1226s download errors, freezes up and missing graphics
I just purchased my Pavilion p7-1226s w/ Windows 7 Premium 64 bit. Sometimes it freezes up or when you click the mouse on a website, it doesn't do anything. I have to completely shut down IE. Also when pages come up sometimes the graphics and pics ar