Actionscript 3.0 :: Loop Of Buttons And Loading Swf/img/txt From Xml
Sep 17, 2011
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);
[Code].....
View 2 Replies
Similar Posts:
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();
[code]...
View 0 Replies
Sep 17, 2011
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.
[Code]...
View 1 Replies
Feb 19, 2009
I want to create a loop for 20 buttons:
[code]....
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]
View 6 Replies
Jul 6, 2009
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]
View 1 Replies
Jul 23, 2009
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.
Rather than do
ActionScript Code:
hide = function () {
account_btn.enabled=false;
account_btn._alpha = 0;
[code]...
View 0 Replies
Nov 11, 2009
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
[code]......
View 6 Replies
Nov 12, 2009
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++)
{
[code]....
View 2 Replies
Jan 27, 2011
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:
PHP Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
[code].......
View 1 Replies
Feb 21, 2006
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.
View 3 Replies
Aug 5, 2007
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,
Code:
numOfBtn = 5;
stop();
[code]......
View 1 Replies
May 31, 2009
i tried to use for to control all the buttons i have but i get this error:1083: Syntax error: dot is unexpected.
Code:
var btnNum:Number = 6;
for (var i:Number = 1; i <= btnNum; i++) {
["L" + i + "_mc"].buttonMode = true;
["L" + i + "_mc"].addEventListener(MouseEvent.MOUSE_OVER, onOver, false, 0, true);
[code]....
View 3 Replies
Jul 30, 2009
i have this from as2, where i can create many buttons on stage and loop. then create a function that applys to all the buttons
Code:
for (var i = 1; i <= 3; i++)
{
bt = this["button" + i];
[Code].....
View 3 Replies
Jul 28, 2011
If I have 16 buttons inside a for loop, how would I trace back the number that was pressed.
NumPageButtons = 16
for(i=1; i<=NumPageButtons; i++){
tempMC = eval("page"+i+"_mc")
[Code]......
when I do a trace it gives me 16 not the number (current button ) that was pressed
View 1 Replies
Feb 19, 2009
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);
[code].....
View 5 Replies
May 15, 2009
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]});
[code].....
View 2 Replies
Oct 9, 2009
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]
View 2 Replies
Sep 8, 2009
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.
View 1 Replies
Mar 28, 2011
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] .....
View 1 Replies
Jun 14, 2010
I was trying to loop through the buttons(movieclips) on the stage so I can just write one functions for all of them.
[Code]...
View 3 Replies
Jun 22, 2010
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] .....
View 1 Replies
Sep 17, 2004
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:
Code:
for (i = 1; i < 6; i++)
{
[code].....
View 2 Replies
Mar 14, 2007
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?
View 2 Replies
Jan 13, 2009
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)});
[Code]....
View 2 Replies
Sep 23, 2009
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?
[Code].....
View 8 Replies
Sep 17, 2004
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:
[Code]...
View 2 Replies
Sep 20, 2010
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.
View 3 Replies
Jan 8, 2011
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.
View 3 Replies
Sep 8, 2009
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:
Code:
var myXML:XML;
var buttonURL1:String;
[code].....
View 3 Replies
Apr 15, 2010
ActionScript Code:
for(i = 1; i <= 27; i++){
this["build" + i].onPress = function(){
buildMenu._x += 380;
}
}
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;"
ActionScript Code:
buildMenu.build1.onPress = function(){
buildMenu._x += 380;
[Code].....
I'm stuck on combing the this["build" + i]" with the menu movieclip instance "buildMenu"
View 2 Replies