ActionScript 3.0 :: Loop Of Buttons And Loading Swf/img/txt From Xml?
Sep 17, 2011
create a multidimensional array which will pull text, swfs, and/or images from an xml file based on which button is clicked.What I don't understand is how to pull the swf or image file from the file like I have with the text. Truth be told, I'm completely lost and could really use some help fixing this. I need to pull text and images or the swf file from the xml depending on which button is clicked and I tried to put this together, but I've given myself a headache trying to understand where I went wrong.
ActionScript Code:
var pageXML:XML;
//Load the XML file.
var pageXMLLoader = new URLLoader();
What I'm trying to do is create a multidimensional array which will pull text, swfs, and/or images from an xml file based on which button is clicked.
What I don't understand is how to pull the swf or image file from the file like I have with the text. I need to pull text and images or the swf file from the xml depending on which button is clicked and I tried to put this together, but I've given myself a headache trying to understand where I went wrong.
Code: Select allvar pageXML:XML; //Load the XML file. var pageXMLLoader = new URLLoader(); pageXMLLoader.load(new URLRequest("scripts/xml/content.xml")); pageXMLLoader.addEventListener(IOErrorEvent.IO_ERROR, xmlIOErrorHandler);
Okay, here goes: What I'm trying to do is create a multidimensional array which will pull text, swfs, and/or images from an xml file based on which button is clicked. What I don't understand is how to pull the swf or image file from the file like I have with the text. Truth be told, I'm completely lost and could really use some help fixing this. I need to pull text and images or the swf file from the xml depending on which button is clicked and I tried to put this together, but I've given myself a headache trying to understand where I went wrong.
the code within the rollover/rollout function doesn't work. It does work when outside of the function or when the code doesnt use "g".Is this because once inside the rollover/out function it always brings back the last value of "g" ... in this case 20?[URL]
I created a menu of invisible movieclips (from a library item with the class name Invis) with buttonmode set to true so that I can have them send the playhead to different labels on the main timeline.I could use some help with determining which button is clicked and then placing code that executes depending on which button is clicked.Here is what I have so far on frame 1 of my timeline:[code]
I don't have an incredible amount of experience with flash, but I feel like I'm missing something really obvious here. I have about 10 buttons here (although I only show two in my code), and rather than listing out long lines of code, I figured it should be relatively straightforward to put it in a for loop...but its not working for whatever reason.
this loop business is giving me a headache, i can't seem to get flash to recognize functions with a variable in itHere is me doing it the long way and i'm trying to figure out how to do it with a loop.I have 4 buttons going across and i'm trying to create another row of buttons under it, a total of 8 buttons.I also created a sprite called squareBtn
ActionScript Code: //displaying buttons //the difference in X is 34
I have been trying to figure out how to distribute buttons with a loop and I did it but now I don't know what the instance name is to target it.i tried using dog and that doesn't work I tried to set the instances names as _1 _2 _3 _4 but its registered as undefined.
ActionScript Code: var dog:squareBtn; for(var i:int = 1; i < 3; i++) {
i call my disable button function that is inside a for loop? it only ever disabled the last button but i want it to disable them all. Below is my code:
I have several buttons on stage (8), and I want to add a slighty different action for everyone of them. How do I do that, All the buttons always get the last past of the "FOR"..
Code: function loadThumbs(eventoUrl:String) { for(i=1; i<=9; i++) { temp = this["thumb_"+i]; with (temp) { image = "fotos/"+eventoUrl+"/thumbs/"+i+".jpg"; loadImages(image, temp); temp.onRollOver = function() { this.play();}; temp.onPress = function() { this.loadImages(image, image_big); };};};}; loadImages() is a LoadMovieClip type function I created.
I had the following script which worked fine for my buttons which were sitting on the stage and are called 'btn1', 'btn2', etc... However I wanted to animate all the buttons so have put them all into a movie clip called buttons, but now my script doesn't work, I have tried changing all the this targets to _root.buttons.this,
In AS2 I used to be able to set up a FOR loop that would program sequential buttons. Now, I'm trying to do it with AS3 and I can't seem to get the function-part right. The last function is the only one that works. Here's some sample code...
PHP Code:
for (var i:Number = 0; i<3; i++) { this["quiz"+i+"_mc"].go_btn.addEventListener(MouseEvent.CLICK, goButtonEvent);
I have this for loop that is basically pulling some info from an xml file and putting it in a list box. And for each item in the xml, it also adds 2 radio buttons.Everything is working properly except all the radio buttons have the same y location, and i want them to be spaced apart, not on top of each other.I have tried messing around with the y location (rb1.y+105, etc) but I'm not having any luck.
for (var i:uint=0; i<il.length(); i++) { lb.addItem({data:il.description.text()[i], label:il.title.text()[i]});
I'm trying to update a series of buttons with a for loop automatically. These buttons will have a somewhat fixed instance names like btn1,btn2,btn3,btn4.My problem is i don't know how to reference the button names with a dynamic variable appended..I have something simple like this, but can someone point me in the correct direction for the syntax please?[code]
It is possible to loop through buttons in a movie clip that do not have sequential names.For instance, they are all named by the date they are for reference to a database.
I'm trying to generate a button with the loop of an array, But I can't make the icon style and the stylename work. for (var x:int = 0; x < smileys.length; x++ ) { var emoticon:Button = new Button(); var label:String = smileys[x][0]; emoticon.width = 24; emoticon.height = 24; emoticon.x = positionX; emoticon.y = 0; [Code] .....
I'm trying to write onPress for 4 buttons inside a for loop. This lines traces undefined: Code: trace(_root.TeachMethodArr1[count]) // undefined. This is because count is no more starting from 0 when I click the buttons.
Code: var TeachMethodArr1:Array=new Array() var TeachMethodArr2:Array=new Array() TeachMethodArr1 = ["a","b","c","b","e"] TeachMethodArr2 = ["a","b","c","b","e"] for(var count:Number=0; [Code] .....
I have is a movie with a button in it called button.i've duplicated the movie (manually) several times on the stage.the movies have been given instance names of movie1, movie2 etc.i've then used actionscript to assign actions to the buttons.i have the following code:
I using a for loop for a redundant action that I want to happen across 5 buttons. OnRollOver the button rotates. OnPress the button moves to a new position. It looks like this:
Code: for(i=0;i<5;i++){ _root.swatch_mc['swatch'+i].onRollOver = function () { this.onEnterFrame = function () {[code]....
My problem is this; onPress I want the button to move up (Ive achieved this already). I also want the other buttons to move down onPress (this is my problem). Is there a way have the other 4 buttons move down onPress using the for loop? Or is there another method of doing this?
I have this little loop that creates buttons. My aim is to change value of variable 'thevalue' on everytime button is pressed, first button should give value 0, second 1, third 2 and so on.
Code: for (jo=0; jo<xmlData.firstChild.childNodes.length; jo++) { value1= xmlData.firstChild.childNodes[jo].attributes.value; _root.attachMovie("button", jo, (1000-jo), {_x:20, _y:20+(jo*20)});
I am trying to basically have a loop that is based on a string length. It adds a movie clip for every letter and a hidden rollover button. All this seems to be working fine but I am having trouble wrapping my head around how to code the event listeners or it might be how I'm telling it which movie to play. As of now all the buttons play the last mc which is block6. What do I need to do differently?
i'm pulling my hair out over this one. I have is a movie with a button in it called button. i've duplicated the movie (manually) several times on the stage. the movies have been given instance names of movie1, movie2 etc. i've then used actionscript to assign actions to the buttons. i have the following code:
I have 29 buttons, named img1, img2 ....till img29...I need to access them all in a loop. I had asked this question earlier, but at that time the buttons had to be accessed via their holding movieclip, but this time the code is within the clip, so I need to directly access the button.
So originally the code I was using to access them was
_root.folioholdermc["img"+i]._alpha //thanks to Ned Murphy
now I need to access them as
this.img2._alpha //due to a path change
I tried using
this.img[i]._alpha but this is not working.
I want to put this in a loop where I moves from 1 to 29.
I got a set of buttons and a text field where they load the content.I'm trying to not make one zillion functions and keep the code neat so i guessed i would try set the buttons' actions within the loop too. I firstly had some problems getting the i counter inside the onRelease function (actually I don't think i ever got how to do it). But I tried this and worked:
stop();var comprarXML = new XML();comprarXML.ignoreWhite = true;comprarXML.load('flash/comprar.xml');comprarXML.onLoad = checkLoading; function checkLoading(success) { rootNode = comprarXML.firstChild; ButtonReleaseAndContent ();} function ButtonReleaseAndContent (){ for (i=0;i<12;i++){ // my buttons are not generated dynamicly, that why the count. btTemp =
[code]....
At the line where I set the text, I had a though " I may have to refer from within the button mc, since the generated code goes inside it!". So i tried the this.temp , guessing that this would be equal to the button level. A few seconds later i noticed my referencing for the text field wasn't coming from within the button, but from the root.
Basically i am loading a series of URLs in from an XML file and i want to assign them to each button on stage (the number of buttons on stage and the number of URLs in the XML doc will match). They will correspond, so myButton1 will go to the first URL in the XML file and so on. I also want to declare button mode true on all the buttons on stage (they are actually movie clips) but i just don't know the syntax of how to do it in a for loop without writing the whole thing out in a really long winded way.Here is my code:
I have 27 buttons on a menu generated by a for loop. When the button is clicked it moves the menu +380 pixels. Now to shorten my code I moved the buttons inside the menu movieclip. Intance name: "buildMenu"
This means I only have to move the menu rather than the menu plus each individual button.
The code below works fine but I don't want to have to write this 27 times as each button will be calling much more than just "buildMenu._x += 380;"