Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Adding To Listbox Dynamically



Hi, i am trying to add items to a list box dynamically. I am using PHP to post variables to flash. The output is like this :-

total=3&name1=jules&name2=harry&name3=phil&

I am trying make a loop that adds the varibles of name1, name2 ect until it reaches the total. When i try to do this it just enters name1, name2 and name3 into the listbox not the actual names? It works if add it like :

List.addItem(name1); The adds the item 'jules' to the listbox.

But wont work if i add it like :

x = 1;
List.addItem("name" add x);

It just adds 'name1' to the listbox?

Very wierd and frustrating! If anyone can help with the 3 lines of code that is needed to make the loop and add the items i would very grateful as i have tried everything!!!

Many thanks in advance.

Jules
Jules@hungrybear.co.uk



FlashKit > Flash Help > Flash ActionScript
Posted on: 09-15-2003, 04:44 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Adding Item To A ListBox
Hi,
i am tring to add items to a list box and it gets added shows everything in reverse order. what i mean is , if i add image1,image2,....image10, it lists image10,image9,....image1. How do I solve this? Any help appreciated. Thanks in advance.
Nesamani.E

Adding Sound To Listbox On Rollover?
Hello,
Is it possible to have a sound triggered when you rollover listbox menu items? Either with an action or by editing the box itself perhaps? I'm using Flash MX

Thanks!
Jason

[F8] Adding Items To A Listbox Embedded In A Movieclip
Hi all,

The movie clip I'm attaching has a text field (called module) and a listbox (called issuesBox) in it.
On stage I have a button with the following code:


Code:
on(click){
for (i=0;i<=5;i++) {
var newClip:MovieClip = _root.attachMovie("mc", "mc"+i, i,{_x:50,_y:yval});
newClip.module.text="title";
for (j=0;j<=10;j++) {
newClip.issuesBox.addItem("hi");
}
}
}
At runtime I get 5 movie clips with the text field filled with "title," like I hoped for. However, the listbox isn't getting filled 10 times like I thought it would. Any suggestions?

Thanks!

ListBox Populated Dynamically With Cf?
Hello everyone,

I need some help to decide how to implent this little application or wathever you wish to call it. I need a ListBox or something similar to put a scrollable menu, the items of that menu are stored in our database. We use FlashMX and Coldfusion. I'm new to ActionScript so i really need some good tutorial or good advise on how this should be done. The programmers here are pretty good though but we need to know how to start and wich is the best way to do it.

I have been browsing for 2 days now to find what i'm looking for but with not luck. I'm very tired and very depressed by now

Thank you for your help!

Dynamically Expanding ListBox
I am pulling in a list of variables into flash via PHP.

The variables are a list of cities, which depending on the county, might have a couple, or a dozen. I'm having no problem getting the variables into flash, but I do have a problem displaying the output.

Right now I have a listBox component that shows all of my variables in a text box that scrolls. This works perfectly, but in the end I will have this information hovering next to the mouse, so the user will not be able to scroll the list.

I'd much rather have the variables pulled into some kind of textfield that would list each new variable on a new line, and expand dynamically depending on how many entries there are. How do I get started??

Thanks a ton

heres the code I'm currently using to pass the variable to the ListBox:


ActionScript Code:
myListBox.addItemAt(0,myData.counties_property_f);
myListBox.addItemAt(1,myData.counties_property2_f);
myListBox.addItemAt(2,myData.counties_property3_f);

Adding Horizontal Scroll Functionality To ListBox Component
how can i add a horizontall scroll bar to ListBox Component, so that when the item width is greater than the original width of the ListBox, the ListBox show a horizontal scroll at bottom.

I came to know that i can extend the class to provide this functionality but dont know the code to do it.
any body knows this how to do it please.

Dynamically Duplicating Buttons, Dynamically Adding Code To Them... HOW?
I spent many hours on this, but still i can't figure out how to do it.

I want to create (or duplicate) a button,
each button has to be separated from each other by some pixels and the buttons could have many rows.

then, once i got the buttons i wan't to assign each of them an "unique" code

b1.onRelease = function() { // <-- but i don't want to write a
loadMovie(somemovie,someplace) // function like this for each button
)
};

Listbox /combobox Help, Linking Combo And Listbox To Call Url W/ Flash 7
Seeking:
I'm want to be able to select an item from a combobox, that will call a list into a listbox, and then be able to click on that link to navigate to a URL.

Purpose:
I have a list of over 80 blog urls from the past several year, a monthly release. I would like to be able to select the year in a combobox which will trigger the 12 url from that year to appear in a listbox, when an item from the listbox is selected I want that url to open. This has proved to be quite difficult in in Flash 7. Any assistance, link, or tutorials would be greatly appreciated.

Adding Variables Dynamically....
hi,

any help/ideas would be greatly appreciated!

i am trying to create a weekly planner so students can enter in the amount of time they spend on a number of activities (study/work/exercise etc) and see those times dynamically subtracted from 24hours pers day and then finally the day totals subtracted from the weekly total..

this is the code i have so far:


Code:
//variables
hrs1="0";
hrs2="0";
hrs3="0";
hrs4="0";
hrs5="0";
hrs6="0";
hrs7="0";
total_hrs="24";
//end variables

//this function defines the variables
defineVars=function(){
for (i=1; i<8; i++)
{
textEntry=eval('hrs'+i);//the name of the variable
textEntry.id=i; //the number assigned to the variable
}
}

//this function sets the names of the text fields on the stage
nameFields=function(){
for (i=1; i<8; i++)
{
theField=eval('act'+i); //the name of the input box
theField.id=i; //the number assigned to the input box
theField.text=textEntry; //the variable originally assigned to the input box which is 0

theField.onChanged=function(){
if(this.text=="") //this 'if' makes sure the text box always has the value zero to prevent total_hrs from displaying NaN
this.text="0";
doCalculation(this); //this runs the calculation function so that if they change the value back to zero it takes that into account
}
}
}

doCalculation=function(which){
total_hrs= 24 - Number(which.text); //this calculation will check the value of all text boxes, add them & subtract the total from 24
}


so at the moment it only subtracts the value of the active input textbox from 24.. what i need it to do is check the values of the other input textboxes, add them together and then subtract the total from 24 everytime one of the textboxes is changed..

i thought about creating an array and pushing the values entered into the textboxes into the array and then getting the calculation function to add the values in the array and then subtract that total from 24 but i soon realised that if the student edited one of the values in a textbox it just added the new value to the end of the array..

i know there must be a way of doing this but i'm all out of ideas!

i have attached the .fla in case more detail is needed...

hope someone can help.. thanks in advance!

sars

Dynamically Adding CuePoints
My question is simple. How do you add dynamic cuePoints to a flash movie. What I mean is this...

myMedia.addCuePoint(cuePointName, cuePointTime)

This is the actionscript syntax for adding a cuepoint. However, I would like to input a variable (probably from an external text file) for "cuePointTime" instead of a hard coded number of seconds.

Can this be done (or is there another solution to achieve the same result)?? Just putting in a variable name for "cuePointTime" does not work. Seems like flash only wants to see a number there.

Can someone help me? Thank you very much!!

Dynamically Adding A % Sign Using AS..How?
Hi. I have seen many websites that have perfectly sized "percent loaded" text (such as 50%), and I'm pretty sure it's not done through dynamic text boxes.... How do I do this, mostly adding a percent [%] sign to the text dynamically so it's always in the right position, but also dynamically "writing" the text using AS?

Here's the script I have so far:
code:
totalBytes = this.getBytesTotal();
loadedBytes = this.getBytesLoaded();
remainingBytes = totalBytes-loadedBytes;
percentDone = int((loadedBytes/totalBytes)*100);
totalBytes = this.getBytesTotal();
loadedBytes = this.getBytesLoaded();
remainingBytes = totalBytes-loadedBytes;
percentDone = int((loadedBytes/totalBytes)*100);
bar.gotoAndStop(percentDone);
bar2.gotoAndStop(percentDone);
if (_framesloaded == _totalframes) {
gotoAndPlay(3);
}

How can I manipulate this AS to achieve this? (if I can). If it is not possible with this piece of AS, please direct me to some, or a tutorial.
Thanks,
Sportzguy933

Dynamically Adding Images To An Swf
Is it possible?

My client wants to make a scrolling line of pictures editable (link below) and wants to do so in Flash because the java they are currently using tends to bog things down too much. I told them that I didn't think it was possible, but I've been wrong before and thought I would check with the true experts at Flashkit.com

http://www.filmdisc.com/

Any suggestions as to how to make this dynamic without using the Java that they are using now?

Any help is appreciated!

Adding A Filter Dynamically
Greeting. this is likely a retarded question, but it also looks like the right forum to post it in so thats alright. I am trying to set optionEnable and optionDisable variables for some movieclips that are submenu buttons. so i made

var optionDisable:GlowFilter = new flash.filters.GlowFilter(color:#FFFFFF, null, blurX:7, blurY:7, strength:50, quality:3, false, false);

var optionEnable:GlowFilter = new flash.filters.GlowFilter(color:#FFCC00, null, blurX:7, blurY:7, strength:146, quality:3, false, false);

and then tried to manually activate them with

this.updatesButton.GlowFilter(optionEnable);
this.showreelButton.GlowFilter (optionDisable);

can someone enlighten me on how to remedy my bogus ways?

Adding Flash In IE Dynamically
I have some code whose IE version looks like this.
The code here is used to add a flash obj present in URL to a document.
This does not seem to work . I saw in Dom Inspector that the object is present in the dom but the swf did not get loaded. Apparently on changing the content of object tag and saving it on Dom Inspector giot me the flash.
So it seems that appendChild will not work. I read somewhere that this can be done using innerHTML but I dont like using that as it is unmaintainable.
Can some one help.


Code:
function addFlashIE(url) {
var flashElem = document.createElement("object");
flashElem.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
flashElem.setAttribute("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0");

addParam("movie", url, flashElem);
document.appendChild(flashElem);
}

Dynamically Adding MCs To The Stage
Hello,

I've been trying to figure this out for some time but apparently this isn't something for an ActionScript noob. So I need some guidance from someone who knows something.

I need to take a collection of movie clips and get them to scroll across the stage left to right one after another. When it gets to the end of the list, start over in sort of a marquee effect. The movie clips contain nothing but a single word of text in four different color states. I can deal with the event handling and state management. What I'm lost on is getting the MCs to appear on the stage and start moving. They can be added one after another in a set interval. But it would be best if they were placed randomly instead of in alpha order.

My thought was to create an array and place the MC names into that and then use a randomizer to grab them and then a function to spit them out onto the stage. Creating the array was the easy part. I'm stumped on the rest.

Can anyone give me some guidance on how best to approach this?

Thank you!!

>>M

Adding A New Frame Dynamically?
If I have a flash movie that contains two frames, is it possible to dynamically (ie. at run-time) add a third frame to the movie via AS 3.0?

Dynamically Adding Actionscript To A _mc
I have been able to make as many MC instances as i want using the attachMovie() funciton. e.g.

for (x=1; x<=10; x++){
_root.attachMovie("box_mc","box"+x+"_mc",x);
}


Now lets say i have some actionscript (same code) that i want to add to each instance of that mc ... how would i go about doing that without having to actually make each instance manually and add the code?

Any help would be greatly appreciated

thanks

[AS2] Dynamically Adding MovieClips
Hi, I'm just starting to learn AS2 OOP and I've seem to run into a problem. I'm currently building a match making class, but im having trouble with the constructor and attaching MovieClips to the stage. Here's my code:

Frame 1:

ActionScript Code:
var Type:String = "stockMelee";var timeLimit:Number = 0;var Player1:MovieClip = attachMovie("Player1", "Player1", 50);var Enemies:Array = ["Player1"];var Allies:Array = ["none"];var currentLevel:String = "testingGround";var eLimit:Number = 1;var lvLim:Array = [1000, 1000, 1000, 1000];var _Grav:Number = 8;var wGrav:Number = 3;var currentGame = new Game(Type, timeLimit, Player1, Enemies, Allies, currentLevel, eLimit, lvLim, _Grav, wGrav);


Game.as

ActionScript Code:
class Game{    //Varibales    //Level    var matchType : String;    var matchTime : Number;    var levelBounds : Array;    var Level : String;    //Characters    var Player : MovieClip;    var Pl;    var Enemies : Array;    var Allies : Array;    var enemyLimit : Number;    //Gravity    var Gravity : Number;    var waterGrav : Number;    //End Vars    function Game (_Type : String, /*_Stock:Number,*/ _Time : Number, _P, _E : Array, _A : Array, _Lev : String, EL : Number, LB : Array, _G : Number, WG : Number)    {        matchType = _Type;        matchTime = _Time;        levelBounds = LB;        Level = _Lev;        Player = _P;        Enemies = _E;        Allies = _A;        enemyLimit = EL;        Gravity = _G;        waterGrav = WG;        createLevel (Level);        spawnFirstChars ();        var Pl = new Human ("Player1");    }}

Dynamically Adding MovieClip
I have a MovieClip in my library which is defined as a class that I have in an external actionscript file. That is, I have a MovieClip "mc_PortfolioElement" in my library and the linkage properties have "class: PortfolioElement". This PortfolioElement is an AS class that I have defined.

My publish settings have classes exported in Frame 2, but when I tell my MovieClip not to export in the 1st frame it does not show anything when I create a new object of its type. Then when I check "Export in first frame" it shows up when I create a new object of type PortfolioElement.

The only code that is relevant to this is:


Code:
var element = new PortfolioElement();
addChild(element);
How can I have the MovieClip export on a frame other than frame 1 and still display itself? Or it would even be great to know why it is NOT displaying itself when I tell it not to export in frame 1....do I need to manually load it in?

Dynamically Adding Actionscript To A _mc
I have been able to make as many MC instances as i want using the attachMovie() funciton. e.g.

for (x=1; x<=10; x++){
_root.attachMovie("box_mc","box"+x+"_mc",x);
}


Now lets say i have some actionscript (same code) that i want to add to each instance of that mc ... how would i go about doing that without having to actually make each instance manually and add the code?

Any help would be greatly appreciated

thanks

Adding An OnEnterFrame Dynamically
hi all, i have an onEnterFrame event happening when the movie first loads. this onEnterFrame i hardcoded.


Code:
menuItems.onEnterFrame= function () {
var distance = _root._xmouse-xCenter;
/*etc code*/
}
I know how to delete it when i don't need it anymore,

Code:
menuItems.onRelease=function () {
delete menuItems.onEnterFrame
}
but i don't know how to add one back in when i need it again. I just can't figure out the correct syntax.

let's say i want another btn to add an onEnterFrame.

how do i do that?

thanks!

Adding Buttons Dynamically, Is It Possible?
Hi all,

Does anybody know how to add buttons dynamically in a flash movie? What I want to do is to create a menu dynamically depending on the parameters the movie receives.

As additional information, each of the options in the menu calls a VB form.

Any help would be really appreciated. Thanks in advance.

God Bless.

Load Swf File From ListBox, When Close Swf ListBox Disappear
Hello all,

I seemed to have problems with Listbox for days now. I managed to write actionscript to load external swf file when selecting a choice from the listbox. However, when the close the swf file by writing the script 'unloadmovie'. It returns to the main scene however, the problem is the ListBox disappears!... anyone advice me please what I did wrong

Thank you very much
Any help appreciated.

Peddie

Adding Frame Labels Dynamically?
Is it possible to add a frame label dynamically? I want to be able to add a #p dynamically to a frame so that the user can print the current page that they are on. Is that possible or is there another way to go about this.
Thanks

Dynamically Adding A New Item To RecordSet
I know that one can add a new record to a RecordSet like this:
code:
var myRS = new RecordSet("post_id","post");
var newItem = {post_id: 1, post: "This is the first post."};
myRS.addItem(newItem);
I also know that one can fill in the values of the "newItem" like this:
code:
var myRS = new RecordSet("post_id","post");
var myItems[1,"This is the first post."];
var newItem = {post_id: myItems[0], post: myItems[1]};
myRS.addItem(newItem);
However, what if the field names need to be dynamic? How would I accomplish that? Here is the code:
code:
var myFieldList = ["post_id","post"]; // create an array with field names
var myRS = new RecordSet([myFieldList]); // this works
var myItems[1,"This is the first post."];
var newItem = {myFieldList[0]: myItems[0], myFieldList[1]: myItems[1]}; // this does not work
myRS.addItem(newItem);
As you can see, the only problem is referencing the field names dynamically. I've tried all sorts of things:
code:
var newItem = {this[myFieldList[0]]: myItems[0], etc...};
var newItem = {eval(myFieldList[0]): myItems[0], etc...};
var newItem = {eval(myFieldList[0] + ":" + myItems[0]), etc...};
and so on . . . I've even tried defining each field individually with "RecordSet.setField()", but nothing so far.

Anyone have any ideas?

retrotron

Adding Items Dynamically To FListBox
Could someone review this snippet of code and see if I've missed something? I've created an empty movie clip(menu3) from the root timeline, then I load a clip(shopCart.swf) into it and then add an item to the list box dynamically. everything works except the addItem piece of the code. I'm calling the function from the loaded movie, but the function resides on the root. Have I confused my dot syntax reference? anyway, here's the code:

function addToCart(Item, Description, Price) {
loadMovie("shopCart.swf", menu3);
output = new String(Item + " " + Description + " $" + Price);
_root.shopCart.SCBox.addItem(output, Price);
trace(output);
}

The trace function shows the variable "output" properly, it's just not making it into the listbox.
Any help would be appreciated.

Radmo:0}

Adding Items Dynamically To FListBox
Could someone review this snippet of code and see if I've missed something? I've created an empty movie clip(menu3) from the root timeline, then I load a clip(shopCart.swf) into it and then add an item to the list box dynamically. everything works except the addItem piece of the code. I'm calling the function from the loaded movie, but the function resides on the root. Have I confused my dot syntax reference? anyway, here's the code:

function addToCart(Item, Description, Price) {
loadMovie("shopCart.swf", menu3);
output = new String(Item + " " + Description + " $" + Price);
_root.shopCart.SCBox.addItem(output, Price);
trace(output);
}

The trace function shows the variable "output" properly, it's just not making it into the listbox.
Any help would be appreciated.

Radmo:0}

Dynamically Adding URLs To Buttons
I have an XML file that has a large group of buttons. (ex below)
code: <unitedstates>
<state name="WA">
<enabled>1</enabled>
<bordercolor>3F3F3F</bordercolor>
<color>336699</color>
<url>http://www.hotmail.com</url>
</state>
<state name="OR">
<enabled>1</enabled>
<bordercolor>3F3F3F</bordercolor>
<color>336699</color>
<url>http://www.gmail.com</url>
</state>
</unitedstates>
I want to be able to dynamically have each of those buttons go to the URL I specified in the <url></url> tag.

This is the code that I am trying to do as I loop through the XML file, but it's assigning it onrelease. I want to assign it at the beginning.

code:
for(var i = 0; i < xmlDoc_xml.firstChild.childNodes.length; i++){
var strURL = xmlDoc_xml.firstChild.childNodes[i].childNodes[3].firstChild.nodeValue;
eval(stateName).onRelease = function(){
trace(strURL);
getURL(strURL, "_self");
}
}

the problem with this is that it assigns the last URL in the XML file to the every button I click on. So in this instance, the WA button AND the OR button will both go to gmail.com because that's the last one it was assigned to.

How do I add the right URL to the right button in that loop and have it stick?

Thanks.

[F8] Adding Numbers Dynamically In A Form
I am working on a form for an online store, which allows the user to select a bunch of options. I need the total to change as the user selects different options with checkboxes. Then I need to export the total to another frame, where the confirmation page is.

It is the first time I do this, so I am a little confused.
What I got so far, (which doesnt work...of course)



Code:
var TotalSuitCost:Number = 425 ;

function getTotalSuitCost() {
if (form_mc.armGrip_cb.selected) {
TotalSuitCost + 10;}
return;
}
confirmation_mc.totalCost_txt.text = "Total: $" + TotalSuitCost ;

I know I am missing some crucial parts here...
if anyone would have any suggestions to help me, I would be the happiest person on earth for the moment...:-)..and maybe get some sleep too...

Thanks
sandra

Adding Events To Dynamically Attached MC
hii every one.

I have one doubt. i have jus started to work in flash.

I have done a sample in which there will be a main stage (movie) and a few icons by the side of it.

Icons on the side can be dragged and dropped on the main stage. (for that i have duplicated the icon and dragged it.) after placing the icon, it is attached to the main stage and it can be moved only with the main stage.

am able to achieve this with some excellent guidance from members of this forum.

Now the requirement is that i have to load all the icons dynamically.

Previously all coding was written for the icon itself. now as am loading external icons (swf or jpgs), how can i get all the events attached to that dynamically loaded icon

any help would be great

thanks

Problems Adding Events Dynamically
Hi everybody,

I'm newbie in AS and im having some problems trying to add events dynamically, take a look :


Code:

function abrePopup(obj)
{
getURL(site);
}

conteudo = new XML();
conteudo.ignoreWhite = true;
conteudo.onLoad = function(ok)
{
for ( x = 1; x <= 5; x++ )
{
item = conteudo.firstChild.childNodes[x-1].attributes;
loadMovie(item.path, ("thumb" + x));
(eval("thumb"+x))._xscale = 20;
(eval("thumb"+x))._yscale = 20;
(eval("thumb"+x)).onPress = abrePopup(item);
//trace ( conteudo.attributes.path );
}
}
conteudo.load("myfile.xml");
The problem occurs here:
(eval("thumb"+x)).onPress = abrePopup(item);

I have 5 thumbnails that receive images based in XML.

What i need is, when the user clicks on the thumb, it opens a pop-up.

BUT what is happening is different, when the images are loaded, the events occurs.

Could someone help me plz ?

PS: Sorry 4 my english

Dynamically Adding Sprite - Always Zero Width?
i'm trying to load images from an external XML file. when i try to position the sprites based on its width, the width is always 0 even though the image loads correctly. the result is the images are stacked over each other, instead of being positioned relatively to each other based on its width.


Code:
for (var i:int=0; i<6;i++) {
loader = new Loader();

s = new Sprite();
s.name = "image" + i;
s.buttonMode = true;
s.addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
s.addEventListener(MouseEvent.ROLL_OUT, handleRollOut);
loader.load(new URLRequest(xmlImages.item[i].imageUrl));
s.addChild(loader);
this.image_container.addChild(s);
s.x = (s.width+20) * i;
}
The same happens when I try to add Labels. i don't really understand how actionscript determines the widths of dynamically added components. For instance, the Label component always defaults to 100px unless I add the RESIZE event handler to position the x-coordinate based on its true width.

Am i missing something? Or should I be handling this type of situation differently? advice would be most appreciated!

Dynamically Adding TextField To MovieClip
I am trying to add TextField to a MovieClip using AS 3.0 with following code:


Code:
mc = new MovieClip();

mc.graphics.beginFill(0x000000);
mc.graphics.drawRect( 0, 0, 200, 200 );
mc.graphics.endFill();

var t:TextField = new TextField();
t.embedFonts = true;
t.antiAliasType = "advanced";
t.text = "TEST";

var tf:TextFormat = new TextFormat();
tf.color = 0xA5C71B;
tf.size = 30;
tf.font = "Arial";

t.setTextFormat(tf);
mc.addChild( t );

stage.addChild(mc);
But the problem is that MovieClip (black rectangle) is displayed on stage but without the text. Anyone knows what's the problem?

thanks,
best regards

Dynamically Adding Movie Clips
Hello all. I've recently moved from Flash 6/AS1 (please hold your laughter) to CS3 and AS3. I have a bit of code I wrote and I'm wondering if AS3 gives me a better, more efficient way to do it.

Here's the code:

ActionScript Code:
for (ix=0;ix<arrayOfThings.length;ix++) {
 var MovieName = "mc" + ix;
 attachMovie("movClip",MovieName,0{_x:0,_y:0});
 eval(MovieName).myTextBox.text = "Hello";
 // More data here
}

So basically, depending on the length of the array, I make ix movieclips named sequentially "mc1", "mc2" etc. Then I have to eval() the MovieName variable to change it's data.

Is there a better way via AS3 to do this? Thanks

Dynamically Adding Movie Clips On A Map..
Hi everybody,

i just had this strange idea of making an interactive map
where a user could click on the map and add shapes with some
description on them and then save the whole thing (maybe
in a text file - coordinates and descriptions of the new shapes)
so a visitor sees the map updated. I don't know if i'm clear.
Somekind of a "dynamic" map.
Any ideas if this could be done with flash?

thanks in advance

Manolis Gerasidis
www.gerasidis.gr

Adding Content Dynamically To The Stage
Hi -

I have an XML file with a list of photos. I have loaded the XML file into
Flash (CS3 / AS 3.0) and I am iterating through the list to load the photos.
The problem is only the last photo displays. I would like to load each photo
and then create a movie and "copy" the loaded content into the movie clip.
Here is my code:

var myFrontLoader:Loader = new Loader();

function loadClips() {
url = new URLRequest(photoArray[arrayPosition]);
myFrontLoader.load(url);
myFrontLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
progressHandler);
}


function progressHandler(event:ProgressEvent):void {
if (event.bytesLoaded == event.bytesTotal) {
holderClip = new MovieClip();
holderClip.addChild(myFrontLoader);
arrayPosition++;
if (arrayPosition < photoArray.length) {
loadClips();
} else {
// done!
}
}
}


Any ideas?

Thanks,


Rich

Adding Functions To Dynamically Created MC's
I am having trouble accomplishing the following:


Code:
var some_xml:XML = new XML();
some_xml.onLoad = function(success) {
if (success) {
var rootNode:Object = some_xml.firstChild;
for (n = 0; n < rootNode.childNodes.length; n++) {
_root.createEmptyMovieClip("new_mc" + n, n);
_root["new_mc" + n]._y = n * 20;
_root["new_mc" + n].createTextField("text_txt", 10, 0, 0, 100, 15);
_root["menu_mc" + n].onPress = function() {
//this is what I can't to work.
loadMovie(rootNode.childNodes[n].attributes.loc, _root.empty_mc);
};
}
}
};
some_xml.load("some.xml");
This works fine if I use a number, but as soon as I try to use "n" within the function it throws an error. Would eval do this for me? I haven't used eval before. Thanks.

Dynamically Adding TextField To MovieClip
I am trying to add TextField to a MovieClip using AS 3.0 with following code:


Code:
mc = new MovieClip();

mc.graphics.beginFill(0x000000);
mc.graphics.drawRect( 0, 0, 200, 200 );
mc.graphics.endFill();

var t:TextField = new TextField();
t.embedFonts = true;
t.antiAliasType = "advanced";
t.text = "TEST";

var tf:TextFormat = new TextFormat();
tf.color = 0xA5C71B;
tf.size = 30;
tf.font = "Arial";

t.setTextFormat(tf);
mc.addChild( t );

stage.addChild(mc);
But the problem is that MovieClip (black rectangle) is displayed on stage but without the text. Anyone knows what's the problem?

thanks,
best regards

Adding Clips Dynamically From Library...
I am trying to dynmically add sprites from the Library in AS3, but don't know how to do this.

Assuming that 'Bubble' is an artwork clip in my Libary, I can do this:

var mc:Sprite=new Bubble();

but want to do something like this, where the sprite is derrived from a string:

var str="Bubble";
var mc:Sprite=new [str]();

Obviously this won't work. Any thoughts?

Thanks,

Bill

Dynamically Adding Buttons In A Loop
Hi all,

This really has me stumped. I have a loop running based on some XML tags - the AS loops through each instance of a particular value in an XML file. for each instance, I'm attaching a button that needs to display particular information associated with each entry in the XML file. I can get the buttons to appear, and show up in the right places (with _x and _y values defined in the XML file), but I can't get the button functions' to behave properly. Every button attached has the same value when it comes to calling individual functions (the value of the last loaded button). Here's the code I'm using for the entire function:


Code:
function add_brewers(province:String) {
var globalDepth = null;
var brewtxt_xml:XML = new XML();
brewtxt_xml.ignoreWhite = true;

//set the onLoad event handler
brewtxt_xml.onLoad = function(success:Boolean) {
//if the data parsed, extract it
if (success) {
//use XPath to select all article titles into an array
var city_array:Array = XPath.selectNodes(this.firstChild, "/provinces/province[@name='"+province+"']/brewer/name");
//use XPath to select all author names into an array
var loc_x:Array = XPath.selectNodes(this.firstChild, "/provinces/province[@name='"+province+"']/brewer/xloc");
var loc_y:Array = XPath.selectNodes(this.firstChild, "/provinces/province[@name='"+province+"']/brewer/yloc");
var bName:Array = XPath.selectNodes(this.firstChild, "/provinces/province[@name='"+province+"']/brewer/name");

if (globalDepth == null) {
var globalDepth = 100000;
_global.globalDepth = 100000;
_global.setDepth = function() {
return (globalDepth++);
}
}

var text_name:Array = [];
for (var i:Number = 0; i < city_array.length; i++) {
var m = attachMovie("brew_info", "brew_button" + setDepth(), setDepth());
m._x = loc_x[i].firstChild.nodeValue;
m._y = loc_y[i].firstChild.nodeValue;
m.text = city_array[i].firstChild.nodeValue;
m.onRollOver = function(){
info_box._alpha = 100;
}
m.onRollOut = function():Void {
info_box._alpha = 0;
}
text_name.push(m);
var info_box = attachMovie("brew_box", "brew_box" + setDepth(), setDepth());
info_box._x = 500;
info_box._y = 130;
info_box._alpha = 0;
info_box.bName.text = city_array[i].firstChild.nodeValue;
}
}
else {
trace("unable to load XML");
}
}
brewtxt_xml.load("xml/provinces.xml");
}
My main question is this: How can I attach the buttons so that the variable 'm' has a unique value (and therefore shows the proper 'info_box' movie clip when moused-over)?

I'd really appreciate any help in this matter. Thanks!

Adding Items Dynamically To FListBox
Could someone review this snippet of code and see if I've missed something? I've created an empty movie clip(menu3) from the root timeline, then I load a clip(shopCart.swf) into it and then add an item to the list box dynamically. everything works except the addItem piece of the code. I'm calling the function from the loaded movie, but the function resides on the root. Have I confused my dot syntax reference? anyway, here's the code:


ActionScript Code:
function addToCart(Item, Description, Price) {
loadMovie("shopCart.swf", menu3);
output = new String(Item + " " + Description + " $" + Price);
_root.shopCart.SCBox.addItem(output, Price);
trace(output);
}


The trace function shows the string "output" properly, it's just not making it into the listbox.
Any help would be appreciated.

Radmo:0}

Adding Global-classpath Dynamically
Hey all,

Does anyone know if there is a location in the FMX2004's Program Files or Documents & Settings to find a config file of Flash's global-classpath's settings?

Reason why I'm asking, I'd like to make some sort of ActionScript editor, and also some kind of Flash-framework to make windows-based programs. So then, if I have all these pre-built classes mandatory for the Editor to compile and work with FMX2004, I would need to add a new global class path.

So I'm looking everywhere on my system to find some kind of text/xml/config file read by Flash, not much luck, and no luck at all in the Registry. If I could find the file then I could just append a new path when the Editor is installing.

Of course, I could provide the instructions to the user upon installation of the Editor, but its always nicer to do it behind their back

Any info on this?

[as-2] Adding OnPress To Dynamically Generated MC
hi

i am generating dynamic movieClips , retreiving their names from an XML file , afterwards i want to add them an onPress method. ( this part didn't work so far)

can anyone help me on this ?

Dynamically Adding Variables To Classes AS2.0
How would I go about dynamically adding a proberty or public variable to a Class in ActionScript 2.0???

I'm desparate, help me

Dynamically Adding Items, Links, Possible?
Hey guys.

I'm working on a project right now which is a jewelry menu selection system.

http://www.reddiamonddesign.com/couture/whiteisle/

My boss wants me to make it so we can dynamically add elements without going through flash. In other words, to dynamically be able to add menu items, price, description, etc.

Can anyone point me in the right direction? Is this doable?

Thanks!

-Drew

Dynamically Adding TextField To MovieClip
I am trying to add TextField to a MovieClip using AS 3.0 with following code:


Code:
mc = new MovieClip();

mc.graphics.beginFill(0x000000);
mc.graphics.drawRect( 0, 0, 200, 200 );
mc.graphics.endFill();

var t:TextField = new TextField();
t.embedFonts = true;
t.antiAliasType = "advanced";
t.text = "TEST";

var tf:TextFormat = new TextFormat();
tf.color = 0xA5C71B;
tf.size = 30;
tf.font = "Arial";

t.setTextFormat(tf);
mc.addChild( t );

stage.addChild(mc);
But the problem is that MovieClip (black rectangle) is displayed on stage but without the text. Anyone knows where's the problem?

thanks,
best regards

Help: Adding On Actions To Dynamically Created Buttons
is there any way to do this?

I am loading a series of jpg images into a target MC. Then I am loading a series of invisible buttons to overlay them to make them interactive.

is there any way to set on(mouseaction) events to a button that is created dynamically?

thanks

.fe.

i may not have explained that well, but sometimes it is hard to..

Adding Preloader To Dynamically Loading Images
Hi I was wondering how I add a loading bar to images taht are being Dynamically loaded, do I have to make them all .swf files or is there another way..Thanks in advance

you can see what I'm meaning on my site
Visions of them

the images take a little bit to down load even though I have them at most 40k

Adding Elasticity To Dynamically Created MovieClip
hi,

I have a problem at the minute where i have the following code


Code:
for (i=1; i<9; i++) {
_root.createEmptyMovieClip("button"+i, 100+i);
_root["button"+i].lineStyle(1, 0x000000, 100);
_root["button"+i].beginFill(0x0066CC, 100);
_root["button"+i].moveTo(-95, -20);
_root["button"+i].lineTo(95, -20);
_root["button"+i].lineTo(95, 20);
_root["button"+i].lineTo(-95, 20);
_root["button"+i].endFill(-95, -20);
_root["button"+i]._x = i*95;
_root["button"+i]._y = 365;
}

// Give button actions
button1.onRelease = function() {
loadVariables("text1.txt", "_root");
};
button2.onRelease = function() {
loadVariables("text2.txt", "_root");
};

//.....actions for buttons 3,4,5,6,7 & 8

..which create my menu system fine. However i wish to add a nice little elasticity function to the menu system which i have found.
The code for the elasticity stuff is:


Code:
onClipEvent (load) {
this.elasticScale = function(tar, accel, convert) {
xScale = xScale * accel + (tar - this._xscale) * convert;
yScale = yScale * accel + (tar - this._yscale) * convert;
this._xscale += xScale;
this._yscale += yScale;
}
}
onClipEvent(enterFrame){
if(this.hitTest(_root._xmouse,_root._ymouse,true)){
this.elasticScale(125,0.7,0.4)
}else if (!this.hitTest(_root._xmouse,_root._ymouse,true)){
this.elasticScale(100,0.7,0.4)
}
}


However because clip events are only permitted for movie clip instances this is not going to work.
How can I recode the OnClipEvent portion of the code in a way that it applies to the menu system I have just created.

Any ideas would be welcome

Copyright © 2005-08 www.BigResource.com, All rights reserved