ActionScript 2.0 :: Function That Works For Every Movieclip Whatever Instancename The Moviecl
Jan 21, 2007
I want a function that makes every movieclip on the scene thats beeing released to do what�s in the actonscript.My function doesnt woork, is there a function that works for every movieclip on the scene whatever instancename the movieclip has ?
createTextField function has the following signature:createTextField(instanceName:String, ...)it's ok if the instance name is passed as a string literal.but it does not recognise it if it is passed as a name of the variable containing this string:
createTextField("name_of_the_textfield", ...) is OK name_of_the_textfield.type="input"; trace(name_of_the_textfield.type) returns "input"
This seems so simple and yet I can't figure out why my MovieClips won't hold their instance names.[code]And I do this for each button (I know I can do this with XML but nothing seems to work right now so I've broken it all down to see what's going wrong).[code]And the trace statement gives me "instance29" or some such. Can't seem to get the name to stick. I've tried creating getter and setter methods in my button class to access a label property and use that instead of the name but it comes out undefined when I trace. I'm having trouble finding anything on the forums though I'm sure it must be there. Could someone point me in the right direction. I don't need a full answer, just an explanation of why this is happening.
When Mouse is down on PlanetEarth_mc, only PlanetEarthOuter_mc starts moving, leaving PlanetEarthInner_mc and PlanetInner_txt in the same existing place. I want to call the parent of the target i.e. I want to move PlanetEarth_mc. also, EventReceived.target.parent.startDrag();//Gives Error. How can I achieve that from received MouseEvent Object I hope u understand this.
Somehow the mainmovie get confused with the instancenames. Is there a way to get around with this so I don't have to rename each name?? It would b such a hassle to rename all instancenames if I got many duplicated/similar swfs.
I have a listener and a function for it on the main timeline, listening for TextEvents from links in a dynamic textbox nested somewhere in the movie. The problem is that everything works only once. I click on a link, it works, click again and it does nothing. I have to reload the objects for it to work again. What am I doing wrong? Do functions work only once when the main timeline is stopped?
I created what I though was a pretty simple function for a mouse event listener. The funtion goes to a frame in the current movie clip as well as the parent movie clip. For some reason however the first time you click the button, it only effects the parent movie clip. When you click on it the second time, both movie clips are effected. Here is the script,
And I don't know how to use the debugger in Actionscript. This is my code. It's in a class called GeoPiece and is being activated when a movieclip of instance GeoPiece is dragged over a movieclip of instance GeoPuzzle. lastObjOver is a place holder and is an instance of GeoPuzzle.
I want the mc from GeoPuzzle to highlight (goto frame "Over") when it is touched over and unhighlight (goto frame lock or out) when untouched. The script works perfectly - unless the GeoPuzzle piece was already locked. For some reason, it then sets itself to null and I can't figure out why.
ETA: The touchevent its responding to is a TOUCH_MOVE attached to the GeoPiece.
I have a function ("advance_slideshow()") that ticks a slide show up by one, then it loops back at the end. It works when called from the key listener I set up for debugging. However it does not work when called from setInterval. I added a trace to the function to confirm that it was being called, which it is; it just doesn't work when called via the interval
Code: ////////////////////////// /* IMPORTS AND INCLUDES */
I have 20 players in a game and cutting and pasting lots of code except for a few numbers. I have future features that would require over 400 lines of mostly repeated code. So I learned how to use "for", and practiced with a trace command. Traced the results exactly as I thought. However when I apply it to the guts of my function, the movie breaks down. I suspect it's because the function is being called on an EnterFrame command and the for loop I wrote is being executed over and over.
This works when I hand code: Actionscript Code: function drill(){GUESS0 = ((guess0min * 60)*1000) + ((guess0seconds * 1000)) GUESS1 = ((guess1min * 60)*1000) + ((guess1seconds * 1000)) GUESS2 = ((guess2min * 60)*1000) + ((guess2seconds * 1000)) GUESS3 = ((guess3min * 60)*1000) + ((guess3seconds * 1000)) GUESS20 = ((guess20min * 60)*1000) + ((guess20seconds * 1000)) //and then 300 more lines of other code}
And then a button later calls this when pressing: Actionscript Code: my_MC.onEnterFrame = function(){_root.drill (); //so _root.drill is continually being called, which is good, because it has all sorts of data that needs to be refreshed, but I think it's screwing with my "for" loop.}
And the following is NOT working. Actionscript Code: function drill(){for (i=0;i<20;i++){ "GUESS"+i+" = ((guess"+i+"min * 60)*1000) + ((guess"+i+"seconds * 1000));";}
But when I trace it in a separate test movie, it outputs exactly what I would hope it placed in the code: Actionscript Code: for (i=0;i<5;i++){trace("GUESS"+i+" = ((guess"+i+"min * 60)*1000) + ((guess"+i+"seconds * 1000));");}
So at the end of the day, I guess I can trace these results in a test movie and use it to generate what I need, and cut and paste it into the project... but I thought 'for' loops were for saving time AND space. Am I using this code right? Maybe my use of "", or +, or i is misguided?
I have a function that draws a rectangle on the screen (see createInfoPanel())While drawing rectangle, I am adding 2 text fields on it.But as you may guess, it is adding those immediately. I want to delay adding these text fields, then I want to remove these panels after a while. The problem is, when I set an interval or timer, they won't work after I using once (I had to stop them by clearing/removing, it didn't set them again).Since my panel is being created each time image changes, I need them to work every time image changes.
So, I have 2 questions:1- How can I re-set interval each time my createInfoPanel() function works? It won't work anymore after setting and claring once. 2- You can see infoPanel.addChild(titleField); line in addInfoPanel() function. How can I work a smooth animation here? I mean, text appears slowly?
I am trying to compare the performance of several different algorithms. So created several functions each of them implementing different approach of solving the same task.What was thinking to do is to create 2 Date objects before and after the function runs, and to compare them afterwords.
The switch case doesn't works with function. This is the AS3 code: ActionScript Code: var med:Number, mdi:String, op:int, tot:String; bt1.addEventListener(MouseEvent.CLICK,yardas); function yardas(MouseEvent:Event):void{ op=1 [Code] .....
I'm making a website to the company that I work and I'm having a problem.The function only works on the first 30 frames of the scene?!?! Strange!Here goes the .fla and if you see the "years bar" doesn't move has the other elements. But if you click on the [M Button] and next on the [P button] it works.Why does not work on the other buttons.
I have a function ("advance_slideshow()") that ticks a slide show up by one, then it loops back at the end. It works when called from the key listener I set up for debugging. However it does not work when called from setInterval. I added a trace to the function to confirm that it was being called, which it is; it just doesn't work when called via the interval.
[This is Flash 8, AS2]
Code: ////////////////////////// /* IMPORTS AND INCLUDES */ ////////////////////////// import mx.transitions.*;
My hitTest function only works on the y-axis This is the code.... onClipEvent (enterFrame) { // _root.speed = speed; if (Key.isDown(Key.UP)) { speed += 3; [Code] .....
I finally finished my game and now whenever my game communicates with my php file/mysql database it fails when the file is being run off the server, but somehow it works fine when played locally.
Here is some sample code:
(This works locally, hence the full url for the load function. But it does not work on the server which I thought was strange.)
Code: startupvars = new LoadVars(); startupvars.load("http://alexville.com/alexvillenetwork/startup.php"); startupvars.onLoad = function(success){ if(success){
I really want to finish this project that I'm working on, but this stupid problem keeps holding me back.
When I try to Load variables from my PHP file on my webserver from my local computer everything goes fine. But when the swf file is actually on the webserver the Load function fails to return any result with no error.
Here is my code:
Code: Stage.scaleMode = "exactFit"; startupvars = new LoadVars(); startupvars.load("startup.php");
[Code]....
What happens after this code runs is that the text boxes dont get filled with ANY text, not even the Logged In As before the variable. So I guess the "startupvars.onLoad = function(success){" code is not being run.
I have a function ("advance_slideshow()") that ticks a slide show up by one, then it loops back at the end. It works when called from the key listener I set up for debugging. However it does not work when called from setInterval. I added a trace to the function to confirm that it was being called, which it is; it just doesn't work when called via the interval.
Code: ////////////////////////// /* IMPORTS AND INCLUDES */ //////////////////////////
I have a function triggered by a button click that searches through an XML file for an e-mail address (entered in a text field) and returns a match or no match. When I run the swf locally it works fine, but once the site is posted it no longer works. Locally it is connecting to the same xml & php files that it uses online.
I have a function that draws a rectangle on the screen (see createInfoPanel()) While drawing rectangle, I am adding 2 text fields on it. But as you may guess, it is adding those immediately. I want to delay adding these text fields, then I want to remove these panels after a while. The problem is, when I set an interval or timer, they won't work after I using once (I had to stop them by clearing/removing, it didn't set them again). Since my panel is being created each time image changes, I need them to work every time image changes. So, I have 2 questions:
1- How can I re-set interval each time my createInfoPanel() function works? It won't work anymore after setting and claring once.
2- You can see infoPanel.addChild(titleField); line in addInfoPanel() function. How can I work a smooth animation here? I mean, text appears slowly?
I found a cool prototype function here in the forums that plays a movieclip backwards:[code]I have the protoype defined on the main timeline of my main file. I call the function on press of a button from an external movieclip after it's loaded into main.When testing it in flash it works beautifully. When I test it online it doesn't work at all. Other code on the button being called at the same time does work (like unloading a movieclip on the main timeline).
I have the protoype defined on the main timeline of my main file. I call the function on press of a button from an external movieclip after it's loaded into main.When testing it in flash it works beautifully. When I test it online it doesn't work at all. Other code on the button being called at the same time does work (like unloading a movieclip on the main timeline).