ActionScript 3.0 :: Use A Function On 7 Movieclips?
Aug 20, 2010
trying to use a function on 7 movieclips..wrote it all down with 7 individual EventListeners..but it can be much easier.Tried this, but that won't work..trowing me an error:
TypeError: Error #1006: hitTestObject is not a function.
at new_fla::MainTimeline/endDrag()
ActionScript Code:
import caurina.transitions.*;
var cirX:Number = 60;
var cirY:Number = 60;
[code]....
So I've got 7 movieclips named Object1, Object2....Object7, and when I click on one the movieclip has to stick on the mouse and if it is released nearby the target movieclip it has to stick to it. If it is not nearby it has to go to a random place..
All works fine like this:
ActionScript Code:
import caurina.transitions.*;
var cirX:Number = 60;
[code]....
View 3 Replies
Similar Posts:
Sep 13, 2009
I'm doing a basic site with frame labels on the main timeline whose name corresponds to the btn names. A simple otoAndPlay(evt.target.name); I have a basic navigation setup of 7 mcs with mouse eventlisteners for CLICK, ROLL_OVER and ROLL_OUT.
Example:
prepare.addEventListener(MouseEvent.CLICK, navigate);plans.addEventListener(MouseEvent.CLICK, navigate);retire.addEventListener(MouseEvent.CLICK,
[Code]....
Does anyone know a better way to do this so when my mcs are clicked they display the rollover content/art? In essence I'm trying to achieve that when the user clicks a btn it goes to that "page" and the corresponding btn stays highlighted. Pretty standard web navigation technique but I just don't know what the best way to do this in flash is and with how my site is setup.
View 1 Replies
Feb 2, 2011
I ve used next script:
onClipEvent (load) {
if((_root. mc1._visible=true) and (_root.mc2=true)) {
_root.mc3._visible=true;
}else{
_root.mc3._visible=false;
}}
To achieve next: mc3 is visible only when mc1 and mc2 are visible else its hidden, but this dont work, with this script on load all clips are visible on stage mc1, mc2, mc3, inspite there is a script which is hiding mc1, and mc2...(they should appear on stage on mouse event and this was ok before a inserted script from beginning of post, now they are always visible). How should I write this to make mc3 visible only when mc1 and mc2 are both visible on stage.
View 2 Replies
Mar 3, 2004
I have 3 movieclips on my main timeline - 1 MC for each frame. The movie clips are named image1_mc, image2_mc, image3_mc. I want to have all 3 mcs have this code on them:
[Code]...
View 14 Replies
Apr 26, 2010
I'm adding movieclips from an external .as class called GUI. But what I'd like to do is be able to load multiple GUIs - lets say GUI0, GUI1 & GUI2 - through the one class using a dynamic variable. So if I need to load a certain GUI i can just instantiate the GUI class and run newGUI.loadGUI(GUIname); and have it load the correct movieclip based on the variable.So, syntax aside, it would look something like this:
Code:
loadMenu(GUIname) {
GUItoLoad = GUIname;
var mcLoader:GUItoLoad = new GUItoLoad();[code]........
I've tried a few different things syntax wise, and have had a search and browse, but have come up empty handed.
View 1 Replies
Dec 14, 2009
Is there a way how the startDrag function can be used on 2 different movie clips on one stage?
I have my own photo slideshow player (photos + music) and I need 2 dragable movieclips (buttons). First one is on the timeline and second one on the volume slider. How to achieve that I could use the startDrag function on both of them in the same time?
Or is there any trick how to do it? A regular youtube player has 2 dragable buttons (volume, timeline) also...
View 3 Replies
Feb 7, 2010
I am creating an interactive map which is attached, what I want when you hover over any movieclip the alpha decreases and when you mouse off it goes back to 100% aplha. I can certainly do this, but I only know how to do it by referencing each movieclip first! For example:
[Code].....
View 6 Replies
Mar 12, 2011
I'm trying to apply a function to an array of movieclips, rather than have to type out the function for each one. So, if my movieclips were mc1, mc2 and mc3, I would have:
Code:
function Invisible (movieclip){
movieclip._alpha=50;
}
[code]....
This does not work - I still have to put Invisible(mc1) for each object to make it work. Is there a way to use arrays to do this?
View 3 Replies
Jun 7, 2011
I have 30 buttons on the stage each with a different instance name.
ActionScript Code:
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
btnArray = [h1_btn, h2_btn, h3_btn, h4_btn, h5_btn, h6_btn, h7_btn, h8_btn, h9_btn];
for each (var btn:*in btnArray) {
btn.addEventListener(MouseEvent.CLICK, checkClick);
btn.buttonMode = true;
[Code] .....
Not all of them only a snippet. Is there a short way of doing this. The only prob is each function will have a completely different piece of code in it eventually doing different things. I have 20 mc with 30 btns in each.
View 9 Replies
Jul 3, 2006
I have yet another "I die-problem", not so drastic this time, though. I've only tried to solve it for two hours or so,it's killing me Well, as usual, I end up here, at the Kirupa forums.. and of course, l end up emptying the coffe-machine at work.. *runs for more espresso* It's an issue regarding the duplicateMovieClip function. I know how it works, and I know how to duplicate MovieClips using the function, however, I do have an issue figuring this out: Now, explained roughly:I have a MovieClip which contains yet another MovieClip. I want to duplicate both the MovieClip and it's child, but I want it to stay inside the parent MovieClip, just as the original MovieClip contained the original child.
View 13 Replies
Apr 25, 2010
I'm adding movieclips from an external .as class called GUI. But what I'd like to do is be able to load multiple GUIs through the one class using a dynamic variable. So if I need to load a certain GUI i can just instantiate the GUI class and run newGUI.loadGUI(GUIname); and have it load the correct movieclip based on the variable.
[Code]..
View 3 Replies
Mar 28, 2011
i have 4 movieclips on stage and i want to apply a drag function for each separately but i was wondering if there's a way to make this simple. and not to write a function for all 4 movieclips.
View 2 Replies
Dec 6, 2003
I have created 3 movieclip buttons which have a total of 3 states eachUP, OVER and Pressed.What i am wanting to do is create a fuction that will change the state of an already pressed button back to its UP state. For exampleButton one is press and will stay in its state untill button 2 or 3 are presses then it will revert back to its up state.My way of tackling the problem was to target a frame in the movie clip that I wanted to change such as this:
on (rollOut) {
gotoAndPlay("ee");
}
[code].....
View 5 Replies
Nov 5, 2009
I have a simple function on the main timeline which applies to 50 moveiclips, named MovieclipA1 to MovieclipA50. [code]The code is the same for all 50 mc's. All that changes is the 'A1' which become A2,A3,A4,A5 etc.Is there anyway to avoid writing this code 50 times, perhaps using an array which contains A1 to A50?
View 7 Replies
Feb 26, 2010
I have a movieclip "squareA" -- inside of squareA, on frame 2 is a movieclip called "squareB". I tried the following code:
Actionscript Code:
squareA.x = 10squareA.y = 10squareA.gotoAndStop(2)squareA.squareB.x = 10squareA.squareB.y = 10
But I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at problem_fla::MainTimeline/problem_fla::frame1()
If I put SquareB in frame 1 of SquareA -- it works.
View 3 Replies
Nov 13, 2010
What I am trying to achieve is have one movie clip containing a button control the timeline of another movie clip.I know how to get a button to control the timeline of it's current movie clip, however, getting a button to control the timeline of a seperatef there is a tutorial that someone knows of, or if someone could post a snippet of AS3 showing how a button controls another clips timeline -Re: Question: AS3 Button controling timeline of movie clip.here is the coding I am using too:
but_shows.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
function onMouseDown(event:MouseEvent):void{
_root.mainContainer.gotoAndStop(2);
[code].....
View 1 Replies
May 19, 2010
I have this function to find occurences of misstyped varaible names (with wrong lower / upper case). I have a movieclip called "debug" where I define and call this funciton ("getCase(_level0)"). But It never finds my testttt variable - If I put the test varaible in _level0 the variable is found.
var targetsCase_ary:Object = new Object();
var targetsLower_ary:Object = new Object(); testttt = 1 testttT = 1 function getCase(clip:MovieClip, recu:Number){ if (recu==undefined) recu = 1; var n:String; for (n in clip){ var sPath:String = clip._target + "." + n; var sPathLower:String = sPath.toLowerCase (); //trace(sPathLower + " " +
[code]....
View 3 Replies
Feb 6, 2010
I want to create a dynamic thumb scroller. I want to call a function in the thumb . How can it possible?
ActionScript Code:
var btn:CustomButton;
for (var i:Number = 0; i<totalNum; i++) {[code]...
I want to call a function named SetRotate() in CustomButton Class
View 5 Replies
May 18, 2003
I want to use the same movieclips (some are button movieclips) but be able to have a function lay them out at runtime in two (or more) layouts. Just the _x and _y position like in this example:I'd like to layout the mcs with just actionscript. So it can be hardwired into the movie's script with parameters A yielding layout A, et cetera.
something like this:
Code:
boxOne_mc._x = 100;
boxOne_mc._y = 100;
boxTwo_mc._x = 200;
[code]....
but all wrapped up in one function.
View 14 Replies
Jan 20, 2005
I am loading some thumbnails (jpgs) into some movieclips using loadmovie. Easy enough. I want to scale the movieclip to increase the size of the thumbnail on rollover. The problem is when I use loadmovie and load the external JPG it sets the the JPGs default registration point to (0,0) and when I scale the thumbnail it scales from the top left corner. I would like it to scale from the center. This is the code I am using:
onClipEvent (load) {
var thumb = "thumbtest.jpg";
loadMovie(thumb, thumb_loader);
thumb_loader._yscale = 70;
thumb_loader._xscale = 70;
} on (rollOver) {
thumb_loader._yscale = 100;
thumb_loader._xscale = 100;
} on (rollOut) {
thumb_loader._yscale = 70;
thumb_loader._xscale = 70;
}
Is there anyway to change the registration point so it scales from the center and not the top left?
View 1 Replies
Apr 21, 2010
I'm using flash MX, and this was written in the only frame. Before this, I had the function declared and then called, and the output was 1 then 2 then 3.With the function declared at the end there is no output.In both cases the movieclips never played.
Actionscript Code:
_root.McG1.onRelease=Select(1);_root.McG2.onPress=Select(2);_root.McCar.onPress=Select(3)[code].....
View 6 Replies
Jun 15, 2010
Is there a way to make the onMouseDown function also work within the MovieClips area in this code example? It seems like the two functions are conflicting.
attachMovie("nutrition","nutrition",4,{_x:715, _y:370});
nutrition.gotoAndPlay();
nutrition.onPress = function():Void{
[Code].....
View 2 Replies
Jun 17, 2010
I am using the following code to simulate a volume control bar filling on vol+ and unfilling on vol-. The dragger is a mask that causes the fill to appear and disappear when the mouse is pressed and dragged on the volume controller. It works well, but I would like to add a "switch" that moves at the same time and in the same location as the fill, but on top of it... I created the movieClip for the switch and tried all kinds of variations to the following code with its instance in the code, but cant seem to get it working... below is the code which works with just the mask filling / unfilling.
this.ratio = 0;dragger.onPress = function() {this.startDrag(true, 0, 0, line._width, 0);
this.onEnterFrame = function() {
ratio = Math.round(this._x*100/line._width);
_root.volume = ratio; }; };
dragger.onRelease = dragger.onRelease=stopDrag;
View 3 Replies
Feb 4, 2011
I hope the title of my post isn't confusing, I wasn't sure how to phrase it. [code]...
View 1 Replies
Mar 7, 2012
I'm trying to make a point and click game for the fun of it. I'm having troubble with the .onPress function. I've made an array of movieclips, and I want to go through them in a loop, and make an onPress function for each of them. What I am trying to do with the code below is to make the debugText tell me what movieclip I pressed:
var letterArray = new Array();
letterArray = [l1_mc, l2_mc, l3_mc, l4_mc, l5_mc, l6_mc, l7_mc, l8_mc, l9_mc,
l10_mc, l11_mc, l12_mc, l13_mc, l14_mc, l15_mc, l16_mc, l17_mc, l18_mc,
l19_mc, l20_mc, l21_mc, l22_mc, l23_mc, l24_mc, l25_mc, l26_mc, l27_mc,
l28_mc, l29_mc, l30_mc, l31_mc, l32_mc, l33_mc, l34_mc, l35_mc, l36_mc];
[Code] .....
DebugText outputs:
Pressed movieclip nr: 36 36 36 36 36 36
No matter what clip i press, i get the same output: 36. why?
View 5 Replies
May 17, 2005
i have this on my buttons (movieclips):
[Code]...
on rollOver i want to dynamically pass a movieclips name to a function which controls that the movieclip should goto its frame named "over", but i cant get the adressing to work. if i trace the variable "name" in the example it gives me the moviename correctly. so i guess my syntax is wrong. the function doesnt work with the path variable either. i know this might be a stupid question. dont mind me, i'm a noob.
View 6 Replies
Oct 29, 2006
I am trying to use the code in one of the tutorials which loads a movieclip.I need to load about 10 clips using the method below, but I can only get one to load. I will also need to make each of them draggable.
Code:
but.onPress = function ()
{
_root.createEmptyMovieClip("container", 1);
loadMovie("square.swf", "container");
[code]....
View 3 Replies
Apr 28, 2007
[Code]...
NOTE: The following text is my problem and observations, if you afraid to read it all, my problem is easily guessable within the code go ahead and crack at it without my explanation :-p I'm having some trouble with using hitTest(); with movieclips within arrays. I wanted to build a function that checks the hitTest of Movieclips in arrays because the array is dynamic and it would run more efficient and faster this way.
As you may notice it doesn't check just the movieClip in the array, but a movieclip 2 scopes within it. I feel that this is my problem. I noticed in my debugger that that mc doesn't show up, but i put an onLoad event on it to trace its existence when loaded and it shows up fine. I wonder what I'm doing wrong.
View 2 Replies
May 30, 2007
im having some trouble when trying to implement the swap depth function to movieclips that have the setmask function implimented to them. the problem is that i can get the swapdepth to work but when the setmask is implimented at the same time the movie clips will not swap depths.
the code that i am using to set the mask is _root.bgmasked.setMask(_root.dragger); this is on frame one in the action/code layer bgmasked is the imaged being masked by dragger.
[Code]...
View 2 Replies
Sep 4, 2007
I have a problem when few movieclips calls the same function, every movie clip when it is onMouseOver give to the function their properties witch function process.
If i OnMouseOver a few movieclips at the time the function cant calculate every movieclip alone... Maybe i have to put some array.. ??? i dont know..
On OnMouseOver the movieclips move i random direction and when i passes 15 seconds they return to their original place..
View 5 Replies