ActionScript 3.0 :: Assign Variables Do Dynamic Created Buttons?
Apr 12, 2011I have a 13 buttons to wich I added Event listeners using a for loop:
Code:
for (var i:Number = 1; i < 13; i++)
{
[code].....
I have a 13 buttons to wich I added Event listeners using a for loop:
Code:
for (var i:Number = 1; i < 13; i++)
{
[code].....
I know this should be do-able, but i am stumped... I created a row of movie clip buttons + eventListeners (CLICK) with a for-loop. i now want to take an array that consists of a list of swfs (i.e., var myArray:Array=new Array(); myArray=["thing.swf","dog.swf",more.swf",etc}--and programmatically assign a loader + URL request to each of the created movie clip buttons that will load the swfs on the button click.
View 1 RepliesWhat I need to do is assign 5 separate dynamic text fields to 5 seperate buttons and at the same time to those same five buttons i would like to add 5 images that i would be able to change merely by swapping out the images in the file theyre in on the server.I would also like to get a nice transition between the images...ALSO i want to dynamically load the images for the buttons that will be used for switching from picture to picture(which im thinking i will be able to do after i know the how to do point the aforementioned things.)
Through tutorials I've found around the net I've been able to get most of the parts together... but i get lost because what they show you for AS2 they don't for AS3 and vice versa, at least that ive seen.so... I guess my question is... would i need to set up 5 seperate dynamic text fields on the stage and then set each one of them to one of the corresponding button. If so what AS code would i need to use to do so. And if not what would i need to do?
The other part of the question would be I know about the UILoader... would i be able to use it as my buttons and images, if so would i need 5 seperate ui loaders for both the Thumbnail buttons and the images or is there a way that would be better to do it? and once i do that would i do the transitions using frames and tweens like with AS2?
I am building a Gallery/Case Study application and I am running everything off of XML, and I need to be able to add images/text to the application whenever, without causing any problems. On the sideshow portion of the application, I am putting dynamically generated textfields under the picture viewer, with the number of the current image, highlighted. Similar to the one here:[URL] the first slide haha this was one of the best examples I could find. Anyway I've created the textfields, that display the correct numbers (that is, from "01" until say "07" depending on the .length(); of the XML tag <image>), but that is all they do so far. I am setting the type in the textfields by doing this
Code:
_tf.text = "0" + myIndex as String
myIndex is a varibale incrementing as long as var i:Number is less than the length property of the XMLList I'm using to store the image URL's. I am adding the _tf var to the stage using addChild(); and multiplying i by like 20 or something to make the x values different for every _tf. My problem is that if i try to reference the myIndex value when the textfield is clicked, it says the value of myIndex is 7, which is what it was set to when the last iteration of the loop executed. Basically I need to be able to store a value somewhere, that is unique to each textfield so I can load the corresponding image from my XMLList. I've tried messing around with the .name property of MovieClips, but I'm not exactly sure how it works. I use it earlier in the code with my Loader instance, but I don't know how to use it with MovieClips.
Write well let me see if i can explain this:I have created a class that will create a movie class colour block:
Code: Select allimport com.si.mc. CreateBlockClip;
import com.si.mc.newClass;
var myBar:CreateBlockClip = new CreateBlockClip("bar",300,5);
[code]....
Assign actions for a mc created dynamically?
View 3 RepliesI want to change the value of a variable which is inside another flash movie .I have loaded the swf file.Inside the 'onLoadInit' function i wrote the code like below.
[Code]...
xml values are stored in 'arr' array collection. depending on the length of the array stored, the below described components are created and assign those values to relevant components dynamically. For Example:
[Code]....
how to control dynamically created clips... What I've got is a series of objects on the stage, that have been created using an external xml file. here's the code for this...
Code: Select allfor each (var MenuItem:XML in myXML..MenuItem) {
code for setting the clips on the stage, positioning them, etc, } But what that doesn't do is give each clip an individual instance name, so I've no way of controlling them on the stage? I presume I need to create a variable and then loop through the MenuItem xml assigning a unique instance as it goes through it?
here's my code
createEmptyMovieClip("myMC",0);
// load a jpg
myMC.loadMovie("myImg.jpg")
[code].....
I am trying to use the duplicateMovieClip event to create a row of custom movie clips dynamically and I would like to be able to set the _alpha properties on each object depending on an event i am firing in a different movie.[code]...
View 4 RepliesIs it possible to assign variables dynamically to URLVariables?
View 6 RepliesHow do you assign an object different variables.I tried setting it up like this but I get an error.[code]How do you do this correctly I get error Label must be simple identifier when I do it like this.
View 2 RepliesI just want to know if there is a way to assign multiple variables, and if there is a way to check multiple variables.
I want to be able to assign variables to false and then check if all the variables are false.
I use following flash actionscript code, got from online, to load the "Loading.txt" file:
var myTextLoader:URLLoader = new URLLoader();
myTextLoader.addEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void {
[code].....
As primitives are copied as 'value' not by Reference, this doesnt work:
ActionScript Code:
var myPrimitive1:int = 10;
var myPrimitive2:int = myPrimitive1;
myPrimitive2 = 20; // i want this to affect myPrimitive1 too
My goal is to pick a random property on a data Object() and alter that. My approach was to put all the Objects properties into an array, and then randomise that array, and pick the first element. The only problem is of course that, that element is no longer a Reference to the original, so If I change that it wont alter the original...
ActionScript Code:
// Create Data Object
var myObject:Object = new Object();
myObject.primitiveVar1 = "string1";
[Code].....
I'm having some trouble with a flash 5 game I'm making. I'm attempting to make a simple choice game, where there are two input text boxes and each has a different meaning. Similar to url.... One for the smart remarks for a reply to their answer. The other for their score. I want the score added after the correct choice is made. [code]The problem is that I don`t know how to assign variables to the text boxes and the answers so that the score carries over from the last scene.
View 1 RepliesThe label variables are null at the end of the loop. This has worked for be in the past. What am I missing?
[code]...
I'm having some trouble with a flash 5 game I'm making. I'm attempting to make a simple choice game, where there are two input text boxes and each has a different meaning. Similar to [URL]. One for the smart remarks for a reply to their answer. The other for their score. I want the score added after the correct choice is made.
on (release) {
field1 = "The Absent of Body = The Absent of Mind";
first1 = 0;
}
The problem is that I don`t know how to assign variables to the text boxes and the answers so that the score carries over from the last scene.
I am making an audio player app that collects variables based on javascript running on the page. By default it loads 2 mp3s, but I need to be able to re-assign the mp3s that it loads based on different javascript clicks.
I think what I want to do is assign the default 2 songs to variables on file load. Then call a function that re-assigns those variables to the javascript variables passed in. My question is - how do I create a function that only runs on initial load? I assume I could then use javascript to call a different AS3 function to stop the player, re-assign the variables, load the file, and then start it again.
I have an AS3 function that runs when a URLRequest fails. I need to be able to use this function to assign global variables that I can then check against using other functions. How do I assign global variables inside of a function?
Edit:This is the variable (soundFile2Exist) I am trying to get outside of my function:
function onIOError(e:IOErrorEvent):void
{
var soundFile2exist = null;[code]...............
But anyway, my problem is that, I have 52 Button instances on Scene 1 as bellow:
B1 , B2 , B3 , ... , B52
and I want to assign seperated actions for each of them.
The way I currently CAN do that is this:
B1.addEventListener(MouseEvent.MOUSE_DOWN, B1F);
B2.addEventListener(MouseEvent.MOUSE_DOWN, B2F);
B3.addEventListener(MouseEvent.MOUSE_DOWN, B3F);
[Code].....
But "test.addEventListener(..." does not work, and Flash searches for a function named "test" instead of working with the VALUE of "test".
I am not an expert in Flash and my problem might looks silly.But anyway, my problem is that, I have 52 Button instances on Scene 1 as bellow:and I want to assign seperated actions for each of them.The way I currently CAN do that is this:
B1.addEventListener(MouseEvent.MOUSE_DOWN, B1F);B2.addEventListener(MouseEvent.MOUSE_DOWN, B2F);B3.addEventListener(MouseEvent.MOUSE_DOWN, B3F);...B52.addEventListener(MouseEvent.MOUSE_DOWN, B4F);
[code].....
One of the things that I love about AS 1/2 is with scrpt assist on, the ability to click a box and assign an action to a button (over, rollout, rollover, click, etc.). With action script 3, at least in CS4 that interaction isn't there and you have to write the code.I'm wondering if in CS5 there is that ability with AS3? Am I the only designer who misses this function.
View 1 Repliesthe current code I have on the timeline now (where the buttons reside) is:
stop();
function playLifeboy(event:MouseEvent):void
{
[code]......
I am new top actionscript that is why I am trying to learn AS3 instead of the AS2 etc.anyway I am trying to create a number pad in flash (like a calculator but wothout the add, subtract etc) so that when I press a number its displays the number in the flash movie. I nearly have it but it only displays one number at any one moment but i need to be able to add upto 5 digits in the display, so that later on in the project I can validate this field to make the input is correct.here is the code that I have made but remember this is my first AS3 flash program so go easy on me
stop();
display.maxChars = 5;
// start of the array
[code].....
how to assign movies to buttons. I don't know how to do this in MX. In five I used to use tell targets to assign actions. Is it the same in MX.
View 5 Repliescould anyone help me modify the code for these checkbox components? right now, the SUBMIT button checks which ones of the checkboxes are checked and gets their label, then writes the appropriate labels in a dynamic text box.[code]For the program I am doing, I need to have a maximum of 6 checkmarks and each one of the checked label must go into its own variable. (see gray part of the swf) I would also like the labels to appear in the right order, right now it's inversed.
View 1 Repliesright now, the SUBMIT button checks which ones of the checkboxes are checked and gets their label, then writes the appropriate labels in a dynamic text box.
// HERE IS THE CODE FOR THE Checkbox Components-----------
// Array of the instance names of the checkboxes
myCheck = [one,two,three,four,five,six,seven,eight,nine]; // Function
[code].....
//AS BEGINS
var productList:Array = Array("diabeoff", "cholestoff", "inulina", "colageno", "power", "castoff", "dieta", "miel", "extrapower");
[code].......