ActionScript 3.0 :: Duplicating AddEventListener Functionality With A Loop?
Jun 19, 2009
I have 14 movie clips on the stage, each of which has it's own on and off mode and each goes to a separate URL.I would like to use loops to consolidate the code however I am having trouble with the handler.So far I am using the code below but the question is how do you give each button it's own functionality since the handler is the same?
Code:
for (var i:uint = 1; i < 3; i++) {
this["lexus"+i].addEventListener(MouseEvent.MOUSE_OVER, manageMouseOver);
[code].....
View 3 Replies
Similar Posts:
Feb 20, 2005
Inside the iframes are two images from a Flash presentation for Arm & Hammer. I am doing something similar for them and need to duplicate, if possible, the menuing seen here. All I have is the SWF file, which I don't want to put up on the web. For one thing it's pretty big and I don't want to make people sit through it just to get to the menu.
The menu appears as a row of circles. When you mouse over the circles, they expand, and a submenu structure appears. In the example shown here, in Pic 2, I have put my cursor on the PRICING / SPEC SHEETS link. You can see that two sub menu choices appear PRICING and SPECS. These are simply links to downloadable PDFs, no big deal.
[Code]...
View 1 Replies
Dec 15, 2010
The follow code produces a strawberry image that falls from the top of the screen to the bottom. I tried using a for loop to create 10 different instances of this but it doesn't seem to work for me.(Note: ranx is a number produced randomly earlier in the program)
Code:
var nstrawberry:strawberry = new strawberry();
stage.addChild(nstrawberry);
nstrawberry.x = ranx;
[Code].....
View 2 Replies
Aug 2, 2007
I'm trying to duplicate comboboxes in a for loop. The comboboxes are populated with data using the additem function from an array of information. The first combobox is in place at runtime and populated with the data and then, after a user selects how many comboboxes he wants, I run a function to duplicate it. this is the easy part. Everything is duplicated as expected, but as for the data in the duplicated comboboxes, there is no data inside of them!
Code:
var carFieldsArray:Array = new Array (allCars.carMC);
for (var q=0; q<_root.howManyCars;q++) {
if (q>0) {
temp = carFieldsArray[q-1].duplicateMovieClip("carMC"+q, allCars.getNextHighestDepth());
temp._y += 55;
[Code] .....
The carArray is the array with the data. The carfields array is an array that i created for easy access to the comboboxes carMan is the combobox.
View 1 Replies
Nov 11, 2009
I have this map I'm creating in Flash. You click on a state, then you can click on an icon to view a tooltip/popup of some information. What I was trying to do was instead of creating new functions and event listeners for every different icon is to use a for loop...but it's not going so well.[code]...
View 2 Replies
Sep 10, 2009
I want to add a series of event listeners. they work fine in individual lines of code:
ActionScript Code:
home.addEventListener(MouseEvent.CLICK, route);
resume.addEventListener(MouseEvent.CLICK, route);
portfolio.addEventListener(MouseEvent.CLICK, route);
contact.addEventListener(MouseEvent.CLICK, route);
but when i use this loop, i get a 1006 error, "value is not a function":
ActionScript Code:
var buttonNumber:Number;
var buttonName:Array=new Array("home","resume","portfolio","contact");
for (buttonNumber=0;buttonNumber<4;buttonNumber++) {
buttonName[buttonNumber].addEventListener(MouseEvent.CLICK,route); }
is there something obvious that's wrong with my last line in that loop? i've narrowed it down to the part where I call the array value. but after that - I'm at a loss!
View 2 Replies
Dec 5, 2010
I am trying to add event listeners to a series of buttons using a for loop but can't get the event listeners to trace the name of which button was rolled over. Here's a simplified version of the code.
ActionScript Code:
var bgArray:Array = new Array();//array to hold my sprites
for (var i:Number = 0; i<8; i++)
{
[Code].....
View 5 Replies
Mar 4, 2009
I am creating an app with Papervision, and I'm trying to create an interactive grid.I have created a for loop to lay out each tile of the grid, but I want each tile to be individually interactive. I have tried a few things but no luck so far. This is basically how far I am:
Code:
for (var i:uint = 0; i < 10; i++) {
for (var j:uint = 0; j < 10; j++) {
[code].....
View 9 Replies
Jan 14, 2009
Everything works fine except MouseEvent.CLICK addEventListener.menuInfo variable contains part of defined instace name.cURL contains full URL to link.If I trace menuInfo variable, it outputs correctly in order as I exptected.But last event overwrites everything to last element of xList (contains XML list).How do I make this work correctly
Code:
function createMenuEventListener(xList:XMLList):void
{
[code].....
View 1 Replies
Feb 3, 2010
Code:
for (var i:int = 0; i < 3; i++)
{
teacherOptions.btnAction[i].addEventListener(MouseEvent.CLICK, onBtnAction);
}
I have 3 buttons inside the teacherOptions movie clip and they are called
btnAction0
btnAction1
btnAction2
The code I am using doesn't seem to work...I don't want to create an event listener for each of the buttons beacuse they are going to be a lot more than 3, how can I do what I want to do but without errors ??
PD: I know that if the buttons weren't a suboject the correct code would be:
Code:
for (var i:int = 0; i < 3; i++)
{
this["btnAction" + i].addEventListener(MouseEvent.CLICK, onBtnAction);
}
But when it's a subobject you are dealing...things change.
View 4 Replies
Feb 4, 2010
I'm having a problem with the CLICK and navigateToURL part of my scripting. The roll states work fine. I'm getting this error message and am not sure why.
instance37 : null
TypeError: Error #2007: Parameter url must be non-null.
at global/flash.net::navigateToURL()
[code].....
View 2 Replies
Aug 24, 2011
I have a script that contains: an array of movieclips -> MaxBallArr
another array of movieclips -> MaxBallLrg
an array of textfields -> MaxToolTipArr
a library movie clip -> max_box
I'm trying to gather them some how in an addEventListener which worked fine in that way:
ActionScript Code:
[Code]...
View 2 Replies
Nov 17, 2010
I have four buttons with eventListeners that call four different functions. Each function name starts with the button name. like this:
Code:
btn1.addEventListener(MouseEvent.MOUSE_OVER, btn1function);
btn2.addEventListener(MouseEvent.MOUSE_OVER, btn2function);
btn3.addEventListener(MouseEvent.MOUSE_OVER, btn3function);
[Code]....
View 2 Replies
Aug 24, 2011
I have a script that contains:an array of movieclips -> MaxBallArranother array of movieclips -> MaxBallLrgan array of textfields -> MaxToolTipArra library movie clip -> max_boxI'm trying to gather them some how in an addEventListener which worked fine in that way:
Code:
MaxBallArr[0].addEventListener(MouseEvent.MOUSE_MOVE, MaxshowNav)
MaxBallLrg[0].addEventListener(MouseEvent.MOUSE_OUT, MaxhideNav)
[code].....
View 6 Replies
Apr 4, 2007
Flash 8 duplicating movie clips and setting 3 nodes from XML. I am trying to read in an xml with 3 parameters; 2 links and one text field for a caption. What am I doing wrong this time?
[Code]...
I am trying to have "bMC" load into and repeater for however many XML props there are. within "bMC" are two MC's that on click would open window or grab file and One Text field which would load in caption. For some reason the "bMC" isnt even loading at all. Attached is the .Fla
View 2 Replies
May 31, 2011
This code keeps coming back with the same value for i when the button is clicked. It is looping through but only the last value gets passed.
[Code]...
View 1 Replies
Jan 20, 2012
I want to use RTMP based HTTP DVR functionality and HLS based IOS functionality, So I need to know how to MPP from my existing DVR app to the livepkgr app so that the stream being recorded at the DVR app can be used by the Flash and Stream MPP over to livepkgr app and can be used by the IOS HLS.
View 1 Replies
May 19, 2009
I am tring to create a movie clip in which different coloured birds are flying..I am tring to duplicate two or more MovieClips at the same time..but only either of them WorksHow should I modify the code so that I can achieve that ?
PHP Code:
function birds() for(m=1; m<=10; m++)
{firstEnem y= "bird"+1;
[code].....
View 2 Replies
Jul 31, 2009
im having a problem duplicating more than 1 mc in my flash movie here's my code which is meant to duplicate it 1 time.
Code:
function createEnemy ()
{
i = i + 1;
[Code]....
View 2 Replies
Nov 26, 2009
As the tittle suggests i have some trouble with Duplicating movieclips in a masklayer. The mask works but it wont duplicate. Also when i turn of the masklayer and use it as a normal layer the duplicate works perfectly. cant find any reason why it wont work.
View 0 Replies
Jan 27, 2010
I am working on an Augmented Reality project .. This is the code that is called when the marker makes contact with the webcam.
[Code]...
Every time I remove the marker and put it back in view .. this script is called and is causing the action to duplicate itself over and over each time the marker is present. How can I do some sort of check to see if this is already added so that it wont duplicate ?
View 9 Replies
Feb 10, 2011
Here's the deal... I built a dynamic image gallery that runs hoizontally, and the idea is tu duplicate it and, when it reaches a certain point, use it's duplicate, so that there's the illussion of a "never ending" gallery.The problem is that, when duplicating the movieclip, it appears empty, even though I duplicate it after having loaded every picture.
View 8 Replies
Aug 12, 2004
i have a battlehsip that launches torpedoes. i want the gun of the battleship to aim (not perfectly but not way off so the gn can have 8 directions instead of every direction. [ignore this if u dont know what i mean]) the gun aims near the shark and launches a torpedo.i need the battlehsip turret to aim at the shark and duplicate torpedos and have the torpedos launched near the shark. and i need it to move toward the shark.
View 2 Replies
Apr 13, 2003
I have two small dots (stars) that I want to duplicate. I have created a function-[ [code]I placed the function on a blankMC in the onClipevent (load) section. In the onClipEvent (enterFrame) I have placed a setinterval command [code]Now this waits 8 seconds and then creates a massive amount of duplicated stars - more than I want. I had just put the duplicate movie bit in a movie every couple of frames and that did what I wanted but I am trying to challenge myself and use functions and code.
View 2 Replies
Apr 9, 2006
Whenever I make a code to duplicate anything in a reaction to an action, i get the problem of having my initial duplicated mc destroyed upon re-duplicating (you fire bullets and the one shot before the last always disappears and so).The thing is, if you take kirupa's "How to Fire"-tutorial, download the source and run it, the thing works like a charm. However, even if i copy every last single bit of code and content to a new document, the duplication process acts as described above.In addition, here's a quote from the tutorial "How to Fire" [url]
explain how on earth one would get "_level0.bullet" from something the likes of "trace(this._name)", which, of course, returns the instance name. Which would, in the aforementioned tutorial's case, be, in fact, "bullet". Not "_level0.bullet". He states "It's not the instance name"... Well, what the heck is it then? The result of the trace in question varies relying COMPLETELY upon the given instance name. If you write "Bratwurst" as the instance name, you get "Bratwurst" from the trace, as god is my wittness.
Even if i remove EVERYTHING from the code that even COULD, by the user's will, remove the duped mc, the initial problem remains. You can only fire one bullet at any given time, other(s) disappear.It's most propable that there's just something i've missed completely, and end up making myself looking like an ***, but still.For those who want a code, just take a look at the tutorial (the URL above). Everything's basically the same. I would also appreciate if someone were to try what i've described, which is to copy everything from the tutorial .fla and placing the stuff on a fresh document.
View 1 Replies
May 2, 2006
I�m tring this AS to duplicate a MC on the main movie. This AS is on a loaded SWF. It�s not working but can�t find the reason.
Code:
duplicateMovieClip(_root.container, "container1", _root.getNextHighestDepth());
_root.container1.loadMovie("grupo01.swf");
View 2 Replies
Jun 18, 2007
but in a more complex way. I have an existing 2d array that I want to copy to a new 2d array (but the NEW array can vary in size!).
For example, my current 2d array with the data:
var old_array =
[[0,1,2,3,4],
[5,6,7,8,9],
[10,11,12,13]];
And I want the new array to contain the same data as the old_array, yet if the new array is larger, it will put a zero instead of 'undefined'...like this:
var new_array =
[[0,1,2,3,4,0,0],
[5,6,7,8,9,0,0],
[10,11,12,13,0,0],
[0,0,0,0,0,0,0]];
View 3 Replies
Jul 4, 2007
was going well but then i decided to make it so they appear at certain intervals using the amount of seconds elapsed.
Code:
var PreElapsedS=0;
dupCir = function(mc:MovieClip, interval:Number){
[code].....
View 2 Replies
Mar 22, 2009
[URL] if you go into my movie section. i want to add movies to my section if i copy for exemple Audi commercial. i'll have 2 that's great when it'S time to change the name like Audi to Marli it will affect the first one, the original section that i copy too. that's my problem. how can i copy a section to be indivudual. without affecting the first one. cause after that i can go and change everything.
View 1 Replies
Nov 11, 2009
i've read some other threads about this but i can't seem to get them to work with my script..i'm trying to fill my stage with squares to make a visual grid, using setInterval so it shows them animating across row by row. so far i have this:
[Code]....
however i've tried adding in code to make it break onto the next row after duplicating 50 but can't seem to get it to work no matter what i do..
View 2 Replies