Actionscript 3.0 :: Getting A Variable Inside A Funtion?
Jun 22, 2009
loader_ary[i].contentLoaderInfo.addEventListener(Event.COMPLETE, loadyLoaded);I would like to have access to the variable "i" inside the function loadyLoaded.what code would i need to useto return i or atleast the name of loader_ary[i] and slice it or something.
how a function can be called at regular interval for limited times in AS3.0 and one more thing the timer should not be started automatically. I have to trigger that method.
I have a scolling menu, that works wraps around and everything, all nice and pretty.When I place a get url on the button state the url opens,When I place a goto on the button state nothing happens, the supposed scene is a no show.(I have also tried this on the mouse down in the MC state with the same results)I started the scrolling images as buttons then f8'd again and converted to MC's...the MC's have a zoom funtion on them, btu i removed it to see if that was a possible cause to no avail.
I've got a simple program that consist of a document class and a buttonTemplate constructor class. I need to call a function called updateText that should be in the document class, when someone clicks on a button. My event listeners for the buttons are in the buttonTemplate class. My question is, how do you call a function in the document class from a constructor class? Here is my simplified code below
I'm working on a simple catching game where you have monsters coming out from the corner of the screen and you need to get them with the mouse.What I want to do is change the rate at which the monsters come out depending on the score. The higher the score, the more monsters should come out.The code for creating new monsters is a simple timer event:[code]it works when I declare the variable locally within the function. But then I can't access it outside of it, so it's no good!
I am creating a quiz and I set one quiz block with questions into a movieclip. When the person answers the correct answer I want it to add to a counter and pass that value onto the next movieclip. So movieclip one is added to the stage it does something then adds a counter. Then moves to the next frame and movieclip2 is added to the stage. It does something and add to the same counter variable from movieclip1. And so on and so on until no more movieclips.
I have a movie clip called curtain_mc with this actionscript inside:
[Code]...
I would like to change the variable 'f' from true and false by clicking a button but the actionscript on my keyframe doesn't recognize the actionscript in my movieclip? I know its a targeting issue, but not sure how to alter it in order for the two to talk to each other??
Code: var doorType:String = "DT0"; var openType:String = "OT0"; var imagePositioner:Sprite = new Sprite(); //Places a Sprite that will "contain"
[Code]....
openType is defined on a previous screen, it will be equal to OT1 or OT2. I have two sets of images (movie clips) that each have a prefix of "ot1_" or "ot2_" (in their class name). Other than those prefixes the two sets of image names are the same. I think I could cut the amount of code in half if I could use a variable when I use addChild.
I am not very knowledgeable of AS3 and everything I've tried has failed. My theory is that addChild() needs to contain a movieclip, so putting a variable name in addChild() doesn't work.
I need to set a variable that displays quotation marks on the screen. I don't want to say 30 inches when I mean to say 30".
This is what I'm doing....
inches = "30""
obviously flash thinks I typed two "'s and is giving me a "String literal was not properly terminated" error... did a search with no luck and I can't find anything in flash
I recently started learning Flash and Actionscript and now I'm trying to write an actionscript for the first time. Im doing this in Actionscript 2.0.I have a movieclip that consists of two images and one dynamic text field with a variable. The name of the images are "VS1_P1_RUN" and "VS1_P1_OFF" and the name of the dynamic text field is "pumptext". In the dynamic text field I have the variable "VS1_P1_Ind". VS1_P1_Ind is probably a boolean variable as it shows 1 or 0 in another program but in Flash it shows True or False (not sure if Flash thinks it's a text/word or a boolean).My script is supposed to display the image named VS1_P1_RUN if the variable of the dynamic text field pumptext shows the text True and it goes like this:[code]
So I'm completely stuck in what to do. The bottom code works as it should but I want the images to show depending on the value of the variable VS1_P1_Ind. I thought just changing the text field to dynamic and typing the variable name in the variable field would do it but no.If it could be a clue to the solution I'll also share that the value of the variable is not seen/shown in textfield while inside the movieclip. Creating a dynamic textfield outside of the movieclip shows the value of the variable just fine, True/False.
I have some buttons in the scene (inside the .fla) that change a variable "counter" after being clicked. In a separate class there is a function "showPage" that loads a xml-file according to the value of the variable "counter". My problem is, that I dont get the variable "counter" from the fla-file into the function of the .as-class.
Here is my code:
Inside mcMain.as
Code: class mcMain extends MovieClip { //public var counter:Number = 1; //Das hier soll durch den Button getan werden :(
I need to create a variable inside a MoveClip. The easiest way to do this is to click on a movieclip in the editor and just enter the actionscript on a frame, but because i'm doing this with dynamically created movieclips i need to do it with actionscript.
PS: I'm doing it for sorting purposes in a slideshow.
how Im going to put the i variable inside the [[[[ ]]]]] because I cant make it work for(var i:Number=0;i<products;i++){ _root.menu["product"+i]._x += (product[[[[[+i]]]]]x-_root.menu.product["product"+i]._x)/speed; }
How to get variable value from inside event function. Variable was declared outside event function. var StringVar="sample"; myButton.addEventListener(MouseEvent.CLICK, myClickReaction); function myClickReaction (e:MouseEvent):void{ StringVar="other sample"; } trace(StringVar); /*
It gives me "sample" value and I would get "other sample" value */. That strange because if that would be normal function trace would give me good result. var StringVar="sample"; function myClickReaction():void{ StringVar="other sample"; } myClickReaction(); trace(StringVar); /* it gives me result as I wanted to have - "other sample" value */
I know also method of passing arguments into event fuction but it not works for me as I would like to var StringVar="sample"; myButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent){ myClickReaction(e, StringVar) },false, 0, true); function myClickReaction (e:MouseEvent, StrVar:String):void{ StrVar="other sample"; } trace(StringVar); /* it also gives me "sample" value and I would get "other sample" value */ How to do that correctly?
I'm trying to pass a variable through a function, but I'm getting it's value 0. Here's my code:
thumbLoader.addEventListener(MouseEvent.CLICK, goToCategory); function goToCategory(e:MouseEvent) { trace(c);[code]....
this trace gives me value of 0. Normally I would do goToCategory(c) and inside that category I would get it's value, but in this case I'm calling this function with an event, how can that be done?
var c is declared globally, so I'm using it above this code in different place... is there smth like global $c like in PHP.. or there's some other way to do it?!
I have three randomly moving movie clips and one keyboard controlled movie clip which is meant to avoid the tree random flying clips.
I want to do a hit test that basically will do something if anyone of the 3 random clips hit the keyboard controlled clip.
in the hit test i want to be able to have this work for any of the three random clips (flying pumpkins with different instance names, pumpkin1 pumpkin2 pumpkin3). This is all done on an external document class.
I thought about an array but I have no idea really
I have a code, it is below. And i have two vars: coordx and coordy they both are 0 but when up button is pressed, coordx should change into 1 x remain 0 just like map scrolling and if pressed down it should return to default position, but instead of that variables keeps reseting and it starts from beggining. Here is the code:
ActionScript Code: var coordx:Number = 0; var coordy:Number = 0;[code].......
ActionScript Code: function setUpButtons() { var btnCnt = numeri_array.length; for (i=0; i<btnCnt; i++) {
[code]...
i'm having a problem with this script... the onRollOver and onRollOut are working properly but the onRelease it's always the same i mean (my_mc.loadClip(foto[27], "container") for all the 27 buttons..
ActionScript Code: for (i=0; i<btnCnt; i++) { var temp = this["a"+i];
[code]....
and everytime i have to make a modify i have to write for every case..
How can you change a variabele in as3 that you have declared OUTSIDE a function and change it inside the function.My function seems not be able to change the variabele?
ActionScript Code: function Filter2switch(event:MouseEvent) { if(filter2 == false){
I have a movie clip that needs to load an outside Variable and I know how to do it if the Variable is in the main time line.
Main TimeLine: timedelay = 5; MovieClip timedelay = _root.timedelay
What I can not figure out is how to load a variable in a movie clip that is on the Instance of itself (not in the movie clip).
I am fine if I only use one instance of the movie clip at a time on the stage since I can set the Variable on the Main TimeLine into the movieclip (using .root), but this would not work correctly if I want two instances of a movieclip with differenct variables.
Right now I am having to make duplicate copies of a movie clip with different Variable names. I was hoping there would be some way where I could only use one movie clip and give it different variables.
How do I get the for-loop's i variable to be available inside the onLoadInit function????
Code: for (var i = 0; i<nTotalPics; i++) { main.createEmptyMovieClip("container"+i,i); var container:MovieClip = main["container"+i];[code]....
This has been bugging me for about 2 months now. Maybe I'm looking at it the wrong way, but I need to create more things in the onLoadInit function using a for-loop.