Dynamic Array Creation?
Hi all!
is it possible to dynamically creat arrays? If so could you please post a sample?
Code: // loop for (var n = 0; n<5; n++) { // create array? fakearr[n] = new Array(); fakearr[n].push("val 1", "val 2"); trace(fakearr[n]); trace(n); }
KirupaForum > Flash > Flash 8 (and earlier) > Flash MX
Posted on: 02-10-2005, 06:43 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Dynamic Multidimensional Array Creation
var Array1:Array = new Array(5); // where 5 is length of array
for(i=0;i<Array1.length;i++)
{
Array1[i] = new Array();
}
Above code will generate dynamic array of multidimensoal array.
Thanks
Parag
Creation Of Array & Randomness
I'm trying to create an array of questions:
myArray = New Array (Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10);
and what I'd like to do is have an swf that corresponds to the questions randomly play. This 'sequence' should continue until 7 questions have been asked.
At the end of the question.swf movie, a continue.swf movie opens that asks the user to continue with this line of questions or move-on. OnRelease of the continueBTN should increase a Question count so that the above mentioned randomly playing questions array doesn't surpass 7 questions.
I'm trying to "hack" code together and am thinking it might look like this:
Code:
// FUNCTION -- Shuffle array
fncShuffle = function () {
return Math.floor(Math.random()*3)-1;
}
fncNewOrder = function () {
// Create new non-referential copy of integer array.
myQs = rraIntegers.slice();
// Shuffle array.
myQs.sort(fncShuffle);
};
fncLoadQ = function () {
if (QCount < 6) {
loadMovieNum("pda_"+myQs[_root.myQ.pop()]+".swf", 2);
trace(CntryQ)
};
};
myQs = new Array (Cntry+Q1, CntryQ2, CntryQ3, CntryQ, CntryQ5, CntryQ6, CntryQ7, CntryQ8, CntryQ9, CntryQ10, CntryQ11, CntryQ12, CntryQ13, CntryQ14, CntryQ15);
for (i = 0; i < myQs.length; i++) {
fncLoadQ();
};
Varying Array Name Creation Problem
Hi...
I want to create an array with instantly changing name when called.
So I made like this.
var now = new Date();
var userInput = "data"+now.getDate();
userInput.array=new Array();
* userInput is used for a movieClip's name.
I'm pretty sure that is not right expression.
Can anybody help me what I should do for that?
thanks
[Flash8]MC Creation In Array Problem
Hi, I have some buttons that create draggable movie clips in arrays. But when I click on one button, and then another, for some reason the previous movie clip dissapears.
Attatched is an fla file that demonstrates this error.
Try clicking on one button a few times, then clicking on another, then another...
Removing Randomization From Array Creation
The code below randomizes the order of some quiz answers, but I've decided that I need a version where the quiz answers are in a particular order.
I thought it would be easy to turn off the randomization by using the value from
Code:
answers.child("*").length()
to feed the array counter. Instead, the script runs slow and kills. If I trace the value of
answers.child("*").length() I get a countdown: 4 3 2 1. Seems simple enough, but the compiler hates using those number as is.
So I'm scratching my head - how should I simplify this array creation so that the answers are taken in order?
Code:
public function shuffleAnswers(answers:XMLList) {
var shuffledAnswers:Array = new Array;
while (answers.child("*").length() > 0) {
trace(answers.child("*").length()); // 4 3 2 1
var r:int = Math.floor(Math.random() * answers.child("*").length());
shuffledAnswers.push(answers.answer[r]);
delete answers.answer[r];
}
return shuffledAnswers;
}
Array Check And Creation Method---Mabey A Bit Complicated
I am creating a spawning code that will also work with the modifier function to control all the objects. here is the code(so far, not near completed, buti cant get this part to work) and idea
Code:
function spawn(howMany , generation , species, refrenceObject){
trace("spawn");
//Check to make sure there isnt an array already for the species
speciesArray = (eval(species) + "GodArray");
if(speciesArray != null) {
speciesArray = new Array();
AgodArray[0]= "A God Array Created, this should only display once";
trace(species);
trace(speciesArray);
trace("made a new array");
}
}
basically you see that there is a function variable species, this plays a big part in this function as it will attach movie clips to the stage with it later. It also is used to create an array to keep track of all animals of one species.
what this part of the function is supposed to do is check to see if an array withthe name of the species has been created(species = bobamaphone--so we check for bobamaphonegodArray) If an array doesnt exist yet, create one, and display the contents of the array( in the test we are hard coding it in so that we have content in the array(just to test if it's workin)
i am callling the array in the second frame as this
Code:
spawn(1,1,"A")
so the output should look like:
Code:
spawn
God Array Created, this should only display once
A
AgodArray
spawn
spawn
spawn
//etc.
but it doesnt.
WHY!?!?!??!
Random Size Array Creation And File Load To Memory (Buffer) From It
I want to create 4 arrays with random files (a main file and several lesser files) (first one array and 3 other array which come after it). I want to choose one from the 3 one which will play. How can i do it? Because i only can play the first one but don' play the other files after it.
Dynamic Bar Creation
I am trying to create a movie clip (mc_A) that will build a horizontal bar (also a movie clip 1 pixel wide we will call mc_A.mc_B) beginning from where I dropped mc_A (mc_A._x) on the stage to the right end of the stage.
I drop the movie clip mc_A_i (instance) on the stage and use the following code on mc_B.
mc_B._x = _parent.mc_A_i._x;
mc_B._width = Math.abs(1024 - _parent.mc_A_i._x);
A trace shows mc_B._x as being set to it's parent movie clip mc_A._x, but it doesn't place the starting point of the horizontal bar where I would expect it to go when I test the movie.
I also have a problem when I set the _width of a movie clip to a number (1024). I run a trace on the next line of code for the width and it isn't the same.
Any ideas?
Don
Dynamic Creation Of MC's
Alright, as my other post was getting no replies to this issue (as it was buried under my other questions) I have decided to seperate it out for clarity.
This portion of my code is supposed to generate a new movieclip, draw in it, and then repeat.
PHP Code:
_root.createEmptyMovieClip ("line", 1);
["line"+d] = line;
["line"+d].lineStyle (3, 0x000000, 100);
_root["line"+d].onEnterFrame = function ()
{
if (_root.i > 0)
{
if (_root.incrementx <= _root.targetx)
{
["line"+d].moveTo (_root.tempx, _root.tempy);
trace (_root.incrementx);
["line"+d].lineTo (_root.incrementx, _root.incrementy);
_root.incrementx++;
_root.incrementy++;
_root.i--;
}
}
else
{
_root.d++;
_root.tempx = _root.incrementx;
_root.tempy = _root.incrementy;
_root.incrementx = 0;
pickTarget ();
}
};
The issue I'm having is with using the ["line"+d]. Generally this works, but in this instance it is giving me an error. Can anyone help with this? Thank you.
Dynamic Creation
Hi all;
Stupid question I guess:
I'm trying to create dynamic text objects in a loop. Is it possible to add an expression into the creation process?(AS3)
PHP Code:
for(var i:Number = 0; i<3; i++){
var myText:TextField = new TextField(); //<< I want to create 3 text fields like : myText[i]
}
Thanks for you help
Dynamic Creation
Hi,
I am newly learning the flex builder 3.0. I have an issue while dynamic creation and reading of data from the components (textinput, combobox etc.).
The logic which I implemented for dynamic creation of the components is as below:
public function dynamic2():void{
var i:int;
for(i=1;i<=n;i++){
var vBox:VBox=new VBox();
var hBox:HBox = new HBox();
var tip1:TextInput=new TextInput();
tip1.text=”hai”;
var combobox:ComboBox=new ComboBox();
combobox.dataProvider=datatypes1;
//Add components to hbox
hBox.addChild(tip1);
hBox.addChild(combobox);
//Add hbox to vbox
vBox.addChild(hBox);
//Add vbox to tile
//Here maintile is Static tile and we are adding dynamic components to it
maintile.addChild(vBox);
}
i=0;
}
In the for loop ‘n’ value is entered by the user based on that value we need to load the dynamic components. I am able generate the components, but the problem is we are not able to read the data from components(textinput and combobox) because we are not able to differentiate the components if multiple times the for loop is repeated.
Is there any concept where we can generate array of components
For example:
This syntax is existing in flex for array variable creation
Var arr:Array=new Array(5);
Do we have any concept like the above to create array of components?
Like wise var tip:TextInput=new TextInput(5);
Or suggest any solution for reading of dynamic values and identify those components separately?
Thanks in advance
Nagaraju
Dynamic Fla Creation
Hi all i have a question for you is it posible to create a layer for your fla file using actionscript or any other type of language? currently i have be given a project that requires the developemt of a fla file and provides a complete template for users to work with.
I have been to such sties as actionscript.org and www.tutorialized.com which have giving me much of the infromation required for developing both php,javascript,html,css and actionscript but none of these sites contain any information on creating layers via a scripted method. So i was wondering if it is posible or weather i am trying to do something that is not.
any sugestions on how to go about developing this functinality would be greatly apressiated.
cheers scott
Dynamic MC Creation
Hello.
I have a movie clip that gets scrolled across the screen. Within this mc are multiple images, all the same size, one right after another, that are basically getting scrolled across the screen. I'm trying to figure out a way to load images from a specified folder into this scolling mc rather than embedding the files so that I can change them dynamically. Also, the number of files in the folder may change, so this would effect the length of the mc. I would need a way for the flash file to either recognize how many images there were in the folder, or if there was an external document (like XML) that I could simply change out the number to corespond with the number of images in the folder.
Hope this makes sense. As always, any help is much appreciated.
regards
Dynamic Creation Of A Button
Hello!
I have a movieclip on the stage and a button in the library. How can I insert the button into the library?
Is the only way to make a movie, put the button in, put all together in the library and the use attachMovieClip?
Martin
Dynamic Screen Creation?
Trying to figure out the best way to do this. I am creating a GUI in Flash to control my Home Automation stuff through a wireless network and a PDA(s). I have all my backend/server side stuff finished and can pass Home Automation stuff successfully to Flash.
The user interface is simple. First screen “Rooms” in the house, next user touches a “Room” and all the controlable devices in the room are displayed (new screen). So, my question is what is the best way to do this with action script (need to keep it in Flash 5 as the Casio PDA’s support 5)?
Rooms can contain anywhere from 1 to several devices (lamps and stuff).
I am sending over to Flash strings like : (dev_0=Door Light&dev_1=Address Light). So, I need to do the following.
Text var “dev_0 = Door Light” (but I can’t use “TextField.xxxx” commands cause they are Flash 6. And I also want to do the layout dynamically. ie, 3 images across the screen, 10 pixels apart and so on.
So, what is the best way to do this?
Thanks,
-Glenn
Using Flash For Dynamic .pdf Creation
Does anyone know whether it's possible to "save" a flash movie as a .pdf?
In other words, capture a snapshot of a flash movie, and save it as a .pdf?
I know its possible to have a flash movie pass a bunch of variables to a .php page which uses them to dynamically generate a .pdf, but i'd like to capture an exact "screenshot" of a graphical flash movie.
I'd even be glad if I could save a flash movie as a bitmap or .jpeg.
Any insight or advice would be greatly appreciated!
Cheers!
Dynamic Button Creation
I try to create dynamicaly some buttos, and I want them to have a on press() action.
To multiply my buttons (they are thumbnails), I can use
_root.createEmptyMovieClip(mcNewName, i);
or
duplicateMovieClip(_root.Base_Thumb2, mcNewName, i);
both works.
But i don't manage to give them an action.
Is some one knows any solution.
Bobwatts
Dynamic Creation Of TextField
I want to make the following gadget
1. When the user drag over a rectangular MC, the gadget records its init. X, Y and final X, Y (I can do that)
2. Then create an input-type textbox with the background color in contrast with a variable in the form 0xRRGGBB, text color same as the variable and located at (initX, initY), width=largerX-smallX, height=largerY-smallerY
3. The user press SHIFT + ENTER, the gadget will change the text field into a static-type text field, with the background color of the text field eliminated
Please help!
Dynamic Object Creation
Does anyone know how I would get the folowing code to work: Say I have my own object and its class name is stored in var myClass. How would I get this to evaluate?
var newObj = new myClass(this);
remember myClass is a variable containing the name of a class. I am trying to call this and pass a reference to the object that is making the call.
Any help is appreciated. If this was javascript then eval would work fine Im sure.
Dynamic Creation Of Instances
Hi, flashkit forums! This is my first post.
I'm a relatively new user to flash, although not completely; I've done a few sites and things in flash, but they have all been ugly and useless up until recently, so I still consider myself new to flash. Plus, this question is pretty basic, I think, so I decided to ask in the Newbies forum.
The question is about the dynamic creation of instances from premade symbols. Let me give you some background: the content system on a site I'm currently developing has two windows, one which is a menu window and another which is the main content window. The content window's contents changes depending on which item you select from the menu window. Let's just take the News section as an example; the user clicks "News" and I want the menu section to load, from a text file, however many entries there are (the format is irrelevant right now, I'll develop a system to create and interpret the text file). Each entry has two parts: A date, and the body of the news. For each entry, I'd like to create a new button that goes on the bottom of the list in the menu window; the menu will have a simple roll-over scroll system, which I think I will be able to handle. Each of these buttons should be identical, except each bears the date which they represent. When one clicks one of the buttons, the body of the news that pairs with the date appears in the main content window.
I am planning to do this by making a template symbol for the buttons, with maybe a blank or " " text box in the middle as a place-holder, linked to a variable. My problem is, how might I create new instances of this symbol during run-time (probably using actionscript), and how might I control the individual properties of each of the separate instances (as in, date, and what content it links to), even when there could be any number of them? My thoughts are that it would be useful for there to be a way to put these instances in an indefinite array, for easy indexing, and a way for them to have object-like characteristics (as in, object-oriented programming) in that they would be common to a class but each individual instance would have their own values for each of their properties. I'm almost certain that I've heard that these are part of the main advantages of symbols and instances, but I'm not sure.
Perhaps it would be simple, perhaps it would be overly complicated, and perhaps there is a better way to do it than I am thinking of. But right now I am at a loss as for what to do; I lack even the proper syntax for this task. Any help that anyone could give me, whether to suggest an alternative method, help me understand my options, explain to me in detail how I can go about following my plan, or to tell me that this would be way over my head, would be appreciated to a nearly absurd degree.
Movieclips Dynamic Creation
Hi all,
I need an algorithm to create a number of empty MovieClips in "_root" acording to a variable value. Later, I will use the LoadMovie method to fill those empty MovieClips.
I´ve tried with "createEmptyMovieClip" and "AttachMovie"...
i.e.
_root.createEmptyMovieClip("EmptyMovie","MyMovie_1 ",0);
...and a few lines later...
_root.createEmptyMovieClip("EmptyMovie","MyMovie_2 ",0);
but only the last Movie, "MyMovie_2" remains on "_root".
What I'd like to do is to use that Method inside a "for" loop, for creating an array of clips with a variable legth.
THANKS!!
[FMX] Dynamic Button Creation Help
Hey all.
I am building an image viewing application in Flash which loads a list of thumbnail images, and generates a button for each. When the user clicks on the thumbnail button, the full size images shows up.
I'm having some difficulty with making the buttons show up. I know they are created because they do show up in the objects list. I've included my code below. If you see what I'm doing wrong, or if there's a better way to do this please tell me. Thanks in advance.
If it helps, I've also tried using attachMovie instead of createEmptyMovieClip to no avail.
Here we go.
In my main timeline, on frame 1:
_______________________________
var imagesPath = "http://domain/images/";
// create a global class ThumbButton
_global.ThumbButton = function (thumbUrl, imgUrl){
this.thumbUrl = thumbUrl; // url to thumbnail image
this.imgUrl = imgUrl; // url to actual image
};
ThumbButton.prototype.test = function(){ //testing
trace("thumbBtn : <" + this.thumbUrl + "> / <" + this.imgUrl);
}
var glamArray = new Array();
var numGlam = 28; // # of pictures
var glamFilename = "glam";
// populate array with ThumbButton objects
for (var i = 1; i < numGlam; i++){
var thumb = new ThumbButton(
imagesPath + glamFilename + i + "_t.jpg",
imagesPath + glamFilename + i + ".jpg");
glamArray.push(thumb);
}
______________________________________
In the first frame of the movie clip that I want to load the buttons on I have:
_______________________________________
var xPos = 0;
// loop throught the array of thumbButtons
for (var i=0; i < _root.glamArray.length; i++){
thumb = glamArray[i];
// create a empty movie clip to hold the button
tButton = this.createEmptyMovieClip("tButton"+i,i);
// position and resize
tButton._x = xPos;
tButton._y=-90;
tButton._width = 20
tButton._height = 20;
//load the thumbnail image into the movie clip
tButton.loadMovie(thumb.thumbUrl);
tButton._visible = true;
xPos+= 22; // incr the position
// I'm not worried about the actual fetching of the
// image at this point
tButton.onRelease = function(){
trace("fetch " + thumb.imgUrl);
_root.fetchImage(thumb.imgUrl);
};
}
stop();
________________________________
Dynamic Creation Of An Object's Name?
I've tried a few things to dynamincally create the name but have had no luck so far.
Basically, I'm trying to do this:
name = "object" + "number";
_root["frame"].name.goToAndStop(3);
How do I make the above work so I can have a dynamic name for where the above variable of 'name' is?
Dynamic Line Creation
I'm working on a code to generate a dynamic ray effect on stage like this:
Code:
import flash.filters.GlowFilter;
var glow:GlowFilter = new GlowFilter(0x66FFFF, 0.5, 10, 10, 2, 3);
createEmptyMovieClip("ray", 1);
ray.lineStyle(5, 0x666FFF, 100);
ray.filters = [glow];
ray.moveTo(265, 190);
ray.lineTo(550, 0);
ray.moveTo(265, 190);
ray.lineTo(550, 25);
ray.moveTo(265, 190);
ray.lineTo(550, 50);
ray.moveTo(265, 190);
ray.lineTo(550, 75);
Can someone help me to create an array to fill the whole stage(550X400) without repeating the code over and over.
Thanks,
ali
Dynamic Gallery Creation
I'm having a little trouble duplicating movie clips in Flash 8. My buttons check themselves to see if the image which is loading into them exists and has loaded. This works fine, but what I need now is for the button to make a copy of itself and align neatly in a line running left, until the images run out. I'm sure this is a simple math and path problem, but this has been stewing in my brain to the point where I can't think straight! Please help, i'm approaching a deadline. Actionscript from first frame below
////FIRST FRAME ACTIONSCRIPT
itemserial = _name;
this.btxtImageURLpre1 = "img/prem_"+_root.itemname;
this.btxtImageURLpre2 = this.btxtImageURLpre1+"_b";
this.btxtImageURLpre3 = this.btxtImageURLpre2 + itemserial;
this.btxtImageURL = this.btxtImageURLpre3+".jpg";
loadMovie(this.btxtImageURL, "loadinto");
////END
fileExists = new LoadVars();
fileExists._parent = this;
fileExists.onLoad = function(success)
{
if (success) {
DUPLICATE MOVIE STUFF TO GO HERE
} else {
//unload self
myself = "_parent." + _name
unloadMovie(myself);
}
};
fileExists.load(btxtImageURL);
///// END OF FIRST FRAME ACTIONSCRIPT
Thanks again.
Jack
Dynamic Textfield Creation
hello
I'm trying to create several texte field an position them .
then assign a knew text to them.
But it does not work
Code:
for (i=0;i<=6;i++) {
for (j=0;j<=7;j++) {
var champs:String = "champs"+i+j
trace(champs)
this.createTextField(champs, i+j, 50+i+j, i+j, 400, 300);
this.champs.html = true;
var text_intextfield:String = "this is text in texfield"+i+j
this.champs.htmlText = text_intextfield;
trace(this.champs)
}
}
Thanks for help
T.
Dynamic TextField Creation...
hey all, thanks for the help in advance.
When my text box overflows, I can't it expands horizontally but i want it to wrap at the edge.
How do i get a textbox to remain 200 pixels wide and expand only downwards?
Anyone see where i'm going wrong or what I've forgotten:
<code>
this.createTextField("newsy_txt",this.getNextHighe stDepth(),0,30,200,200);
newsy_txt.html = true;
newsy_txt.condenseWhite = false;
newsy_txt.autoSize = "left";
newsy_txt._width = newsy_txt.textWidth + 5;
newsy_txt._height = newsy_txt.textHeight + 5;
newsy_txt.multiline = true;
newsy_txt.embedFonts = true;
newsy_txt.size = 16;
newsy_txt.text = bigLongParagraph;
</code>
Dynamic Button Creation
Ok I'm going to be starting a project where I think I'd like the flash navigation to create its buttons dynamically. I haven't gotten down to the nitty gritty of the coding yet, but I thought I'd post my thought process on how this would be accomplished, because I'm only intermediate at best when it comes to actionscript.
So, I'm thinking that Flash will create an array based on an external document, (XML, or TXT), that will contain information such as [button1, button2, button3]. This is where we'll add or remove buttons.
After that new Array is created, we'll loop through a function. This is where I'm a little uneasy, because I'm trying to work out in my head how flash will create multiple instances of buttons. The button, in my mind, would have its own animation, etc., and would have a text box variable, that would be defined by the button name. This way, as flash creates the button instance, it would change the text of the button? I'm not sure how to code this part.
After that, the buttons should fade in on stage, and each button should have its own actionscript powered animation, for say, onMouseover.
Does that make sense? I realise I'm not giving any code to start with, but I'm starting this thread to follow this project, so I'm just throwing my initial thoughts out there. Any help is most certainly appreciated.
I guess I haven't considered how the buttons will pull the relevent url they should link to yet.
Oh man, I may have bitten off more than I can chew.
Dynamic Creation Of Components
Hi everyone,
this might be an obvious question, but I have spent quite some time already on setting up and programming some Flash Remoting with OpenAMF and now I have a pure Flash issue.
I retrieved all the information from the server so everything is stored in an Array (I'll post the Actionscript code here) on the client side in the Flash Movie. The goal is to dynamically modify the labels of some text fields. Unfortunately, I will only now which text fields at runtime.
The way I figured it was setting all these text fields into dynamic text and assigning them a variable. To complicate the matters, the movie has several different nested clips which holds these texts fields and at runtime only one of these clips is show, thus the added difficulty.
Here is a tree representation of the animation structure:
Sequence
MovieClip1
Text1
MovieClip2
Text21
Text22
Not knowing until runtime whether it is MovieClip1 or MovieClip2 to be shown, how do I dynamically access them , and the Text components inside?
Any help is GREATLY appreciated!!
Thanks in advance,
Paul
PS: the actionscript file
"#include "NetServices.as"
#include "NetDebug.as"
if (connected == null){
connected = true;
var gatewayPath = "http://127.0.0.1:8080/console.aventuremaths.college/gateway";
//var serviceName = "babel/tools/BabelUser";
var serviceName = "com.credm.babel.common.service.ActivityAccessServ ice";
// Declaration de la connexion
NetServices.setDefaultGatewayURL(gatewayPath);
var service = NetServices.createGatewayConnection();
var serviceBabelUser = this.service.getService(serviceName, this);
serviceBabelUser.getActivityAccess();
}
// result doit être la liste des éléments à afficher!! Tout se joue dans la classe java
function getActivityAccess_Result(result){
allActions = new Array();
allActions = result;
gotoAndStop (10*allActions[0]);
//for (i=0; i<allActions.length; i++){}
}
function getActivityAccess_Status(myError){
trace("ERROR : "+ myError);
}"
my
Creation Of An Dynamic Iteration
Lo,
i've looked for a tutorial on this but didn't found it...
I'd like to create an animation where the visiter could insert the number of balls he'd like to see. it's a bit easy but I've got a lot of problem to execute it...
for info :
play_btn is the instance name of the button which serve to execute the script.
numberBall_txt is the instance name of the input text where the visiter can insert the number of balls.
Ball is the name of the movieClip (either in the linkage).
I think the problem is :
trace(typeof(occurence)); ==> string !
I give you the little code I whrought :
ActionScript Code:
stop();
play_btn.onRelease = function(){
// trace(numberBall_txt.text);
if (numberBall_txt.text == "" || numberBall_txt.text <= 1){
id=1;
// trace("check1 "+id);
_root.attachMovie("Ball","ball_1_mc",1);
ball_1_mc._x = 100;
ball_1_mc._y = 100;
}else{
id= Number(numberBall_txt.text);
// trace("check2 "+id);
}
var i;
for (i=2;i<id+1;i++){
_root.attachMovie("Ball",occurence = "ball_"+i+"_mc",i);
trace(typeof(occurence));
occurence._x = 100 + 10*i;
occurence._y = 100 - 10*i;
}
};
Thank You very much for your help,
I begin to be mad with this little problem...
Dynamic Button Creation
hi,
i am using this site script to make dynamic buttons.
but i am unable to change the rollover or release effect of the buttons for the purticular one button.
i want to change the text color in rollover and the text in the button title is come from any server side pages like asp or jsp so that anyone change the title of the button.
and i want the particular button release event.
i am using following code
ActionScript Code:
onClipEvent(load)
{
makebuttons();
function makebuttons(){
// if we have buttons created at first time we remove them to recreate others ones
if(_global.createdClips.length>0){
clearbuttons();
}
addbuttons(10);
}
function addbuttons(howmany)
{
// we create an array to save the buttons references
_global.createdClips = new Array();
for(i=1;i<=howmany;i++)
{
_root.count++;
myButton = this.createEmptyMovieClip("but"+i,i)
myButton.lineStyle(1)
myButton.beginFill(0x336699)
myButton.lineTo(100,0)
myButton.lineTo(100,20)
myButton.lineTo(0,20)
myButton.lineTo(0,0)
this["but"+i]._y = i*myButton._height*1
myButton.createTextField("txt"+i,i+10);
myButton["but"+i].text=i;
// when the movieclip is created we save the reference in the array using this syntax
_global.createdClips.push(myButton);
//=====================we create another movie to make a 3Doutline to the buttonD========================
myButton = this.createEmptyMovieClip("contour"+i,i+20)
myButton.lineStyle(1.75,0x999999)
myButton.lineTo(100,0)
myButton.lineTo(100,20)
myButton.lineStyle(1.75,0xffffff)
myButton.lineTo(0,20)
myButton.lineTo(0,0)
this["contour"+i]._y = i*myButton._height*1
_global.createdClips.push(myButton);
//=============we create a textfield to store the caption ====================================
myButton.createTextField("text"+i, 0, 3, 1, 100, 20);
myButton["text"+i].multiline = false;
myButton["text"+i].wordWrap = false;
myButton["text"+i].border = false;
myButton["text"+i].background = false;
myButton["text"+i].variable = "";
myformat = new TextFormat();
myformat.font="verdana";
myformat.size="12";
myformat.color = 0x000000;
myformat.bullet = false;
myformat.underline = true;
myformat.bold=true;
myformat.align="left";
myButton["text"+i].text = "Button"+i;
myButton["text"+i].setTextFormat(myformat);
_global.createdClips.push(myButton);
// we attach event to the button
myButton.onPress = function(){
//you place the code you want
}
myButton.onRelease = function(){
// you place the code you want
}
myButton.onRollOver = function(){
}
myButton.onRollOut = function(){
// you place the code you want
}
}
}
function clearbuttons() {
for(var myButton in _global.createdClips){
_global.createdClips[myButton].removeMovieClip();
// we delete the reference of the movieclip removed from the array
_global.createdClips.pop();
}
}
}
please help me to achieve the desired task
thanks
Dynamic Instance Creation
Hi,
I'm having trouble when trying to dynamically create new instances.
Somehow flash doesn't compile the required classes unless I directly refer to them at least somewhere in the code.
Here's an example of what i'm trying to do:
Code:
private function explode():Void{
for(var j:Number = 1; j <= 3; j++){
for(var i:Number = 0; i < this["amount_"+j]; i++){
var idp:String = parent.obj_count+"_p";
vars = {id:idp,cx:cx,cy:cy,sx:sx,sy:sy,tm:50,ef:ef,hexcol:this["color_"+j],alt:altitude,ctype:"spark_1"};
var tp:String = this["type_"+j];
/*this is where it goes wrong*/parent.objects[idp] = new [tp](parent, vars);
parent.obj_count++;
}
}
}
The class containing this method has 3 type_x properties(type_1, type_2 and type_3). A new instance of type 'this["type_"+j]' is being created. The problem is that flash doesn't see this because the string is variable, so it doesn't include the required class unless I first create a dummy instance at least somewhere.
So, if this["type_"+j] == "FlashP", then I have to make a direct call to the FlashP class at least somewhere in the code.
Code:
var dummy:Object = new FlashP(null,null);//create a new dummy instance
Placing this line anywhere in the code will make it work, but also eats memory - pointless. So, my question, is there any more elegant way to let the compiler know those classes are needed?
- Thanks!
Dynamic Menu Creation...
...help me brainstorm here. I'm runnin' into quite the headache even trying to work this problem out:
GOAL: To provide a "dynamic" menu based on the permissions level of a registered user. (i.e....a user with "admin" permissions would see a menu tab for "Admin Options", whereas a "member" would not even know this option exists...)
ACHIEVED SO FAR:
--Flash is speaking to a Database through Remoting. Login/User Creation/Permission Creation/etc. is no problem. Information is passed between Flash and the server through amfphp (essentially through php).
PROBLEM:
--Essentially, I need to be able to create buttons that point to .swf files "on the fly"...as this site also needs to be dynamically updateable (I'm lookin' to be able to simply FTP a new flash file and the shell to pick it up automatically in the future).
So we need to:
1) Take a .swf file name from the database (done)
2) With this .swf file name...create a labeled "button" (labeled by the name of the .swf file...so...if the file name was "admin.swf", the "button" would have the text "admin" showing on it) that will point to and load it's target .swf on mouse-click.
I'm hopin' someone out there is laughing at the headaches this problem is causing me and has a great and easy solution
Movieclip Dynamic Creation
Hi there,
Is it possible to create a movieclip (i.e. various frames with graphics in each frame) during runtime?
When I draw in a movieclip (via .lineTo etc.) it seems to sit in another layer in the background of the mc. If I change the frame it doesn't make any difference to where I draw.
Is there a way around this besides creating several movieclips inside a movieclip and then showing and hiding the relevant 'frame' as required?
Thanks,
Rob
Dynamic Flash Creation
Newbie Question...
I have video that I would like clients to tag with their own text at the end (personalize) and then download and play as a SWF without having to load an XML or CGI from the web. Basically, they fill out a form, preview and then download a self-contained SWF for their use on their computers. Possible?
Thanks,
-Matt
Dynamic Keyframe Creation?
I want to use XML and Actionscript to create, name, and assign objects, and navigate to frames on a timeline. So, for example, if the XML contains 10 "page" nodes the Actionscript will create 10 frames named "page1", "page2"......"page10". Then a button on a named frame can jump to another named frame...etc. exactly as if I had manually created a timeline with 10 frames.
I know how to work with the XML but am not sure If I can open up new movie frames with Actionscript as described.
Is this possible or should I be thinking about it in a different way..maybe creating an array from the nodes and attaching clips containing the elements of each "page" then using a "goto" button action that just hides or shows the "page" clip?
IF I wanted to load contents into the page elements (from outside - such as text and images), what are considerations for keeping them in cache so that they don't have to reload from outside everytime the "page" is visited?
Dynamic MovieClip Creation: How To Use These MC's In OOP?
Hello,
Ok here is what I need to know, to use a movieclip in OOP you go into its advanced settings and set AS 2.0 class to the external class you wish it to use. Simple enough.
However, I'm using a script to make my movieclips for me :
for(i=0;i<10;i++){
_root.createEmptyMovieClip("turret"+i, _root.getNextHighestDepth());
_root["turret"+i].attachMovie("guns", "guns2", _root.getNextHighestDepth());
}
The problem Im having is, how can you link these dynamic MC's to an external class since you cant go into its advanced settings to set its AS 2.0 Class? I tried a line I doubted would work and it didnt:
_root["turret"+i] = new OutsideClass();
THanks
Aaron
Edited: 12/09/2007 at 07:57:01 PM by AnotherRandomFlasher
Dynamic Grid Creation
ok, I'm building an application and stuck in a Mathematical situation.
I create a grid with the following actionscript :
gridx = 65;
gridy = 65;
num = 0;
for (var i = 0; i<5; i++) {
for (var j = 0; j<this.count; j++) {
rec.duplicateMovieClip("rec"+num, num);
mc = this["rec"+num];
mc._x = gridx*i;
mc._y = gridy*j;
num++;
}
}
rec._visible = 0;
...where "count" is a record count I fetch from an SQL query
Now, what i want, is to duplicate the "rec" movieclip at x axis (5 times)
and then continue at y axis (65 pixels below) duplicating till i reach the record count number.
Thank you in advance.
John
[FMX] Dynamic Button Creation Help
Hey all.
I am building an image viewing application in Flash which loads a list of thumbnail images, and generates a button for each. When the user clicks on the thumbnail button, the full size images shows up.
I'm having some difficulty with making the buttons show up. I know they are created because they do show up in the objects list. I've included my code below. If you see what I'm doing wrong, or if there's a better way to do this please tell me. Thanks in advance.
If it helps, I've also tried using attachMovie instead of createEmptyMovieClip to no avail.
Here we go.
In my main timeline, on frame 1:
__________________________________________________ ________
var imagesPath = "http://domain/images/";
// create a global class ThumbButton
_global.ThumbButton = function (thumbUrl, imgUrl){
this.thumbUrl = thumbUrl; // url to thumbnail image
this.imgUrl = imgUrl; // url to actual image
};
ThumbButton.prototype.test = function(){ //testing
trace("thumbBtn : <" + this.thumbUrl + "> / <" + this.imgUrl);
}
var glamArray = new Array();
var numGlam = 28; // # of pictures
var glamFilename = "glam";
for (var i = 1; i < numGlam; i++){
var thumb = new ThumbButton(
imagesPath + glamFilename + i + "_t.jpg",
imagesPath + glamFilename + i + ".jpg");
glamArray.push(thumb);
}
__________________________________________________ ________
In the first frame of the movie clip that I want to load the buttons on I have:
__________________________________________________ ________
var xPos = 0;
// loop throught the array of thumbButtons
for (var i=0; i < _root.glamArray.length; i++){
thumb = glamArray[i];
// create a empty movie clip to hold the button
tButton = this.createEmptyMovieClip("tButton"+i,i);
// position and resize
tButton._x = xPos;
tButton._y=-90;
tButton._width = 20
tButton._height = 20;
//load the thumbnail image into the movie clip
tButton.loadMovie(thumb.thumbUrl);
tButton._visible = true;
xPos+= 22; // incr the position
// I'm not worried about the actual fetching of the
// image at this point
tButton.onRelease = function(){
trace("fetch " + thumb.imgUrl);
_root.fetchImage(thumb.imgUrl);
};
}
stop();
__________________________________________________ ________
Dynamic Grid Creation
ok, I'm building an application and stuck in a Mathematical situation.
I create a grid with the following actionscript :
gridx = 65;
gridy = 65;
num = 0;
for (var i = 0; i<5; i++) {
for (var j = 0; j<this.count; j++) {
rec.duplicateMovieClip("rec"+num, num);
mc = this["rec"+num];
mc._x = gridx*i;
mc._y = gridy*j;
num++;
}
}
rec._visible = 0;
...where "count" is a record count I fetch from an SQL query
Now, what i want, is to duplicate the "rec" movieclip at x axis (5 times)
and then continue at y axis (65 pixels below) duplicating till i reach the record count number.
Thank you in advance.
John
[FMX] Dynamic Button Creation Help
Hey all.
I am building an image viewing application in Flash which loads a list of thumbnail images, and generates a button for each. When the user clicks on the thumbnail button, the full size images shows up.
I'm having some difficulty with making the buttons show up. I know they are created because they do show up in the objects list. I've included my code below. If you see what I'm doing wrong, or if there's a better way to do this please tell me. Thanks in advance.
If it helps, I've also tried using attachMovie instead of createEmptyMovieClip to no avail.
Here we go.
In my main timeline, on frame 1:
__________________________________________________ ________
var imagesPath = "http://domain/images/";
// create a global class ThumbButton
_global.ThumbButton = function (thumbUrl, imgUrl){
this.thumbUrl = thumbUrl; // url to thumbnail image
this.imgUrl = imgUrl; // url to actual image
};
ThumbButton.prototype.test = function(){ //testing
trace("thumbBtn : <" + this.thumbUrl + "> / <" + this.imgUrl);
}
var glamArray = new Array();
var numGlam = 28; // # of pictures
var glamFilename = "glam";
for (var i = 1; i < numGlam; i++){
var thumb = new ThumbButton(
imagesPath + glamFilename + i + "_t.jpg",
imagesPath + glamFilename + i + ".jpg");
glamArray.push(thumb);
}
__________________________________________________ ________
In the first frame of the movie clip that I want to load the buttons on I have:
__________________________________________________ ________
var xPos = 0;
// loop throught the array of thumbButtons
for (var i=0; i < _root.glamArray.length; i++){
thumb = glamArray[i];
// create a empty movie clip to hold the button
tButton = this.createEmptyMovieClip("tButton"+i,i);
// position and resize
tButton._x = xPos;
tButton._y=-90;
tButton._width = 20
tButton._height = 20;
//load the thumbnail image into the movie clip
tButton.loadMovie(thumb.thumbUrl);
tButton._visible = true;
xPos+= 22; // incr the position
// I'm not worried about the actual fetching of the
// image at this point
tButton.onRelease = function(){
trace("fetch " + thumb.imgUrl);
_root.fetchImage(thumb.imgUrl);
};
}
stop();
__________________________________________________ ________
Dynamic Creation And Loading
I'm making this question before even going in and trying it myself because I remember trying this some time ago without success. I also know when I get to the part of the project where I will have to tackle this I'll be under pressure to finish quickly so I want to start reading asap.
What I need to do is dynamically load the content of the second, third and fourth step in a wizard-style interface for selecting your mobile device. The process goes like this:
Select Carrier>Select Device Brand>Select Device Model>Confirm Device.
Explanation:
You get to the page to find a list of carriers like T-Mobile, Cingular, etc... and select yours. Then I have to load all applicable brand logos based on the carrier you selected. After that you select a brand to continue to the next step. At that point I have to load all model logos that apply to the selected carrier and brand. On the last step you simply get to see a list of capabilities for the selected device and you are done.
Now, each one of these steps loads its content in the form of images like logos for the carriers, logos for the brands and phone/device pictures for the devices section.
My questions are:
Where can I find a good tutorial on dynamically creating movies based on parameters passed to a flash file as XML?
How do I load and place those movies one besides the other in a continuously expanding row?
How do I load an image inside each movie (for each logo or device basically).
Never mind the way I get the response from the server for each step. I might use XML or might decide to go for a single csv string... don't know yet.
Thanks a lot!!
Dynamic Flash Creation
Hello Friends ,
I am a newbie in the Flash World.
Would like to know more about the online flash banner making.
I like few sites those provide online banner making and then send the banner for free to you via mail.
It is really a nice concept and i would like to know if any one has the idea about how that can be done.
Very much interested in learning flash in that direction.
Thanks
Dynamic Content Creation?
Hi all!
I usually figure things out really quick, but need help on this. I'm creating a dynamic user list, where by clicking on the user, you can do private chatting in the app.
So all code OK, but cant figure out how to get the dynamically created texts text. )
So here is the homework for everybody:
ActionScript Code:
stop();
_root.createEmptyMovieClip("movie", 10);
var height_:Number = 0;
for (i=0; i<10; i++) {
_root.movie.createEmptyMovieClip("holder"+i, i);
_root.movie["holder"+i].createTextField("box"+i, i, 0, _root.height_, 120, 19);
_root.movie["holder"+i]["box"+i].text = "bla"+i;
_root.movie["holder"+i].onPress = function() {
trace(_root.movie["holder"+i]["box"+i].text+" "+i);
};
_root.height_ += 19;
}
obviously the for cicle stops at 10, and the code is trying to get the text of the texbox with an instance name ...+"10".. but there must be a workaround here..
Dynamic Creation Of New Objects
Is there a way to do this:
[pkgIdNameArray[i]+"_addOnDescArray"] = new Array();
in place of:
basic_addOnDescArray = new Array();
enhanced_addOnDescArray = new Array();
premium_addOnDescArray = new Array();
or
[pkgIdNameArray[i]+"_XML"] = new XML();
in place of:
basic_XML = new XML();
enhanced_XML = new XML();
premium_XML = new XML();
The packages themselves will change and I would like to make it as dynamic as possible.
Thanks for any help in advance.
tania
Creation Of Dynamic Table In Flash
Hi,
My requirement is to load the datamic data from server and show it on the flash.
I have to show it in a tabular fashion.
Can anybody help me how to show data in a table format in flash
regards,
Raja.
Dynamic Movie Clip Creation
Hi folks !
I'm creating dinamically movie clips with createEmptyMovieClip. I can't move them. If I do :
trace(_root.nameofMC._x)
it always show me 0
Why do it is ? Thanks for your answers
Dynamic Creation & Postion With Movement
hi,
im designing a menu system that when a button is clicked it loads a
number of instances of one symbol from the library. ive managed to do
this as well as giving them all a position.
what im having trouble with is that i'd really like them all to move
to their positions from a pre-determined point.
here is my code..
Code:
on (press) {
for (i=0;i<5;i++)
attachMovie("star", "star"+i, i)
star0._y = 10;
star0._x = Math.floor(Math.random()*10)+1;
star0.display = "date#1";
star1._y = 20
star1._x = Math.floor(Math.random()*10)+1;
star1.display = "date#2";
star2._y = 30
star2._x = Math.floor(Math.random()*10)+1;
star2.display = "date#3";
star3._y = 40
star3._x = Math.floor(Math.random()*10)+1;
star3.display = "date#4";
star4._y = 50
star4._x = Math.floor(Math.random()*10)+1;
star4.display = "date#5";
}
if anyone could help me on this one or even some help on simplifying
the above they would be a life saver!!
Thanks
Dynamic Sound Object Creation?
hello all,
I'm trying to get around a problem I've been having with the sound object. I'd like to loop through a while statment and in that loop make a new sound object with a unique name. The problem is that it is not possible to use a variable when defining an object. For example, I wanted to do the following:
i = 0;
while (i < 10){
mySound = "_root.movieClip" + i;
eval(mySound) = new Sound("locationHere");
i++;
}
This doesn't work because of the eval() statment while creating the sound object. So, how can I make a list of sound objects without hardcoding them all?
marcus
|