ActionScript 2.0 :: Targeting Dynamic Movieclips For OnPress Actions
Aug 15, 2007I'm generating movieclips based off of an xml file. The images load fine but I can't figure out how to target them for onPress actions.
[Code]...
I'm generating movieclips based off of an xml file. The images load fine but I can't figure out how to target them for onPress actions.
[Code]...
[code]When I run the file the image appears but isn't clickable.The full code is below.[code]
View 3 Replieslets say i have dynamically duplicated movieClips ID's stored in array list. i want to add a onPress event to them. how do i do it?
[Code]...
If I want a button to perform 2 actions such as 1st time onPress the mc visible true and 2nd time onPress the mc visible false and true and false and so on.
View 2 RepliesEverytime I press a movieClip, i -1(on the output window) should be equal to the number of the movieClip (ex: myClip17, when pressed, should produce in the output window a value of 17 for i-1). Please copy paste this code to a flash document and you'll see what I mean (please don't forget that you have to have linkage in the library for a movieClip symbol that you have to create - it's a circle only with stroke that has w=15 h=15). Every time I click on a number it should appear a circle on it. If the circle is already there it should disappear. But that's not the case. Somehow every movieClip has the order to attach one of the instances of movieclip marca_mc to myClip31.
var mcAcoplado = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
var diasDoMes = 31+1;
var distEntreTexto = 10;
for (i=1; i<diasDoMes; i++) {
[Code] .....
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 im 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,
[code].....
The problem is: everytime I press a movieClip, i -1(on the output window) should be equal to the number of the movieClip (ex: myClip17, when pressed, should produce in the output window a value of 17 for i-1).Please copy paste this code to a flash document and you'll see what I mean (please don't forget that you have to have linkage in the library for a movieClip symbol that you have to create - it's a circle only with stroke that has w=15 h=15).Every time I click on a number it shouldappear a circle on him. If the circle is already there it should disappear. But that's not the case. Somehow every movieClip has the order to attach one of the instances of movieclip marca_mc to myClip31.
var mcAcoplado = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
[code]....
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;
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?
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]....
I've created three movieclips to select the next level, and these work fine the first time my game runs, but when I come back to them, after the first game is over and we're restarting, the movieclips appear, but the onRollOver,onRollOut and onPress do not work...
[code]...
I am still sorting out how things translate to AS3 so here it goes:
In the land of AS2:
Say you for looped 5 times and placed movieclips on the stage (attachMovieClip) each one having an mc inside called box_mc. You named them in the loop mc_1, mc_2, mc_3, mc_4, mc_5.Then later you wanted to rotate that box in them you could for loop again and target/rotate the box with a line like this:
this["mc_"+i].box_mc.rotation +=5;
Now in the land of AS3:I place 5 movieclips using addChild and the way I later target the box_mc inside them is to use two lines something like this:
[code]...
I know this method works, but is this the most efficient/correct way of doing this? I tried to get to the box_mc level when assigning the targetMc var, but never found a way that didn't error.Compounding question, how do you make an old line of AS2 work in the AS3 world like this:
this["mc_"+i]["child_mc_"+j].box_mc.rotation +=5;
On my stage, I have a bunch of movieclips with sequential instance names ("toggle1", "toggle2", etc.). I also have another bunch of movieclips, each with their own sequential instance name ("name1", "name2", etc.).How can I set it so that when I click on a "toggle" movieclip, a specified property changes on the "name" movieclip with the same number.Here's what I have so far.
ActionScript Code:
for (var i = 1; i <= 16; i++) {[code]....
What am I missing/doing wrong?
before it was just
somemc._x = someotherMc._x
but as3 doesn't know how to identify someotherMC
[code].....
how to target MovieClips from a class. If I have a MovieClip on the stage named recMc and I want to manipulate it using a class, I know that if I attach my class in the Document Class field in my .fla file and then just do something like this... it works
- class and fla are in the same folder -
Code:
package {
import flash.display.*;
import flash.events.*;
[Code]....
how to target this object without attaching the class to the Document class?
I have a movieclip added to the stage through a function.
ActionScript Code:
function myFunctionOne():void{
var myClipA:clipA = new clipA();
myClipA.name = "myClipA";
addChild(myClipA);
}
To access this item on the stage I have to use:
ActionScript Code:
getChildByName("myClipA");
I have some other movieclips INSIDE this clip that have also been dynamically added. If I want to reference one of those clips I have to reference them by name using getChildByName.
[Code].....
But is there a better way to reference movieclips if they are created inside a function, or is there a way to create them so they are always globally accessible?
Im creating movieclips based on the items in an xml file. It pulls the data in ok, and loads in an image from the given description, and poisitions the clips ok.
Where i'm falling down its assigning button functions to these clips. I can not reference the clips indivually it always refers to the last clip created.
code sample below
files attached also
// Import Classes and Tweening
import gs.*;
import gs.easing.*;
import fl.motion.easing.*;
[Code].....
I have the MovieClip named dessin, which loads another MovieClip named dessin (dessin.dessin). Now, there is a MovieClip named displayPlane, in the new MovieClip (dessin.dessin), in the MovieClip named displayPlane, there is a variable, which goes as follows:
Actionscript Code:
var _loc3 = displayPlane.attachMovie("displayNode", "displayNode_" + projectCount, projectCount);
inside that clip, there are multiple MovieClips in vars, I am trying to specifically target one var, the following:
Actionscript Code:
var _loc8 = this.attachMovie("closeBtn", "closeBtn", 5);
I have tried this code to target that specific MovieClip with no success.
Actionscript Code:
_root.dessin.dessin._loc3._loc8
Right check this:
/////////////////////////////////////
/////////////////////////////////////
///////////////FUSE//////////////////
/////////////////////////////////////
import com.mosesSupposes.fuse.*;
[code]....
But the problem is the thumbMov movies will obviously have a uniquely generated instance name i cant target directly due to the "for" loop..How can i modify what ive done to target any of the thumbMovs with the FUSE functions?
I'm dynamically creating movieclips with dynamically created movieclips inside them and am having trouble with targeting them.
Below is a simplified example of what I'm trying to achieve, in the real file there are a lot more movieclips and I'm creating and naming them with a for loop.
This one is just one Sprite created inside another sprite. I can target the top level sprite named "testname". However when i try target the nested MC it throws an error.
The bottom couple of traces are just test MCs I've made to make sure i got the syntax right, on targeting nested movieclips.
PHP Code:
var holder:Sprite = new test1();
holder.name = "testname";
this.addChild(holder);
[Code]....
So how can i make 2 same movieclips (copy paste) have a working actions, because now only 1 works? The movie clips that have same coding are the walls.[URL]
View 2 RepliesI know that you can do for example onClipEvent(enterFrame) as an action for an exisiting movie clip.How do i dynamically do thisI load the movie:
_root.createEmptyMovieClip("myMovieClip", 101);
myMovieClip._x=50;
myMovieClip._y=50;
[code].....
My movie is five about minutes long with audio and an offscreen timeline move clip containing action script to control other movie clips or play the root directory. After about a minute or so, movie clips get out-of-synch with the audio, apparently its getting bogged down. My swf file doesn't seem that big, about 2.2MB and my move clips aren't that complex, although up to three levels deep.
View 3 RepliesI am having issues trying to get a simple button to make the playhead jump to a certain frame when pressed. I have the main timeline and then have a movieclip which has buttons inside of it and actionscript applied in the movieclips timeline. Is this a no? That is should all actions go on the main timeline? If this is so then does anyone know why I keep getting an error that it can't find the instance named button inside the movieclip?
portfolioButton.addEventListener(MouseEvent.MOUSE_ DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndPlay(100);
}
I've found the solutions for most of my many problems with as 3 but this one is really baffling The frame actions of child-movieclips of dynamically added movieclips are not firing! If I have movieclip, say "mc", which contains a child-movieclip "submc" which has a timeline animation in it with "stop();" on the last frame and I add "mc" on the stage via addChild() the stop action inside the sub movieclip will not work.
All the frame actions inside "mc" itself work. Everything works if I drag the movieclip onto the stage manually. Right now the only way I can see to stop a movieclip on its last frame is by using the ENTER_FRAME event, but that's awfully cumbersome.
I have a small problem with dynamic targeting inside a loop. Shortly, I have some buttons which I add listeners to in a loop. loop works fine. I got everything to work, but the second line in it gives this error : TypeError: Error #1034: Type Coercion failed: cannot convert []@d4abe81 to Function.[code]Can anyone help me with the correct syntax for the second line ?
View 1 RepliesActionScript Code:
for (var i:Number = 1; i<=15; i++) {
_root["window_"+i].onRelease = function() {
_global.myvariable = window[i].name ; //doesnt work
}
}
How can i get name of clicked button? In as3 is evt.target.name action, but in as2?
I can't seem to target the mc's that I have pre-loaded externally. The problem is that mcs like 'screen_roadmap' play at the beginning of the compiled movie, and not when I make them visible by pressing on the button. I currently have a stop(); command on frame one, so I would like the movieclip to gotoAndPlay(2); only when I press the button. I have tried things like : this["screen_roadmap"].gotoAndPlay(2);. I used this code from an actionscript book, but it makes no mention of targeting the mcs.
ActionScript Code:
menu.roadmap.btn.onRelease = function() {
gotoScreen("roadmap");
[code]....
Ive been talking about this in another thread, but I guess its a better idea to start a new thread to ask this question: How can I target a named instance of a dynamic text field that is inside a button, which is inside a movie clip, which is on the root timeline, from a frame in the root timeline?
I tried _root.movieclipname.buttonname.txtfieldname but that doesnt work...and to make issues a little more complicated, its not a static movie clip, but a duplicate that needs to be targeted every iteration of a 'for' loop.
I thought it would be something like -
_root.movieclipname[i].buttonname.txtfieldname
But thats not working...How can I target that textfield?
I want to add a logo to my dynamic menu tabs, the code below adds the logoLdr to the very last tab, but i want to add logoLdr to the first tab generated?How do i target individual tabs in this loop?
PHP Code:
function createMyMenu():void {
//This will be used to represent a menu item
[code].....