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




Dynamically Generated Txt In Buttons



I have this script to dynamically generate buttons. How would I get text to be dynamically generated 'in' the button? Any direction would be greatly appreciated!!!
Thanks!
Va.


buttonArray = new Array("Home","Privacy & Security","Contact Us","DoD Warning")
theButton._visible = false
for(i = 0; i < buttonArray.length; i++)
{
duplicateMovieClip("theButton", "Button" + i, i + 1);
thisButton = this["Button" + i];
if (i > 0){
thisButton._x = this["Button" + (i - 1)]._x + this["Button" + (i - 1)]._width + 2;
}
thisButton.buttonText = buttonArray[i];
}



FlashKit > Flash Help > Flash ActionScript
Posted on: 09-11-2002, 11:21 AM


View Complete Forum Thread with Replies

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

Use Of 'ID' For Dynamically Generated Buttons
This 'for' loop below is giving me an undefined error (though the trace gives me the correct number readout). Any ideas as to why this is the happening? (If more code is needed to determine the problem I am happy to supply it of course).

Error opening URL 'file:///USB%20Disk/%2Bderek/test/undefined'


Code:
function loadBtns() {
for (i = 0; i < Urls.length; i++) {
var mov:MovieClip = attachMovie("numClip", "numClip"+i, this.getNextHighestDepth(), {_x:xPos, _y:yPos});
xPos += this["numClip"+i]._width+5;
this["numClip"+i].ID = i;
this["numClip"+i].onRelease = function() {
trace("Button #"+this.ID+" was pressed");
holder.loadMovie(Urls[i]);
}
}
}
Thanks / help appreciated

Dynamically Generated Buttons Links
Is there a way to generate the url link in the hit state of a button (an animated button, not a text link url) in a swf using a dynamically generated txt file?

For example in a swf I have an animated button with this code below in it so it loads page2.html. Is there a way to dynamically load the url path (page2.html) so if you needed to update the url you could open up the txt file and make the edit there rather then opening up each flash file to update/edit the url?


on (press) {
    getURL("page2.html");
}


any help would be great.

thanks!


Accessing Instances Of Dynamically Generated Buttons
After generating buttons with the following for loop I am attempting (unsuccessfully) to assign actions to them like so. Error I get here is: "Access of undefined property btn0." Any clue as to what I'm doing wrong here?


Code:
var spacing:Number = 10;

for (var i:int = 0; i < 3; i++) {
var btn = new Btn;
btn.x = 145 + i*(btn.width + spacing);
btn.y = 460;
btn.alpha = .5;
btn.name = "btn"+i;
addChild(btn);
}

btn0.addEventListener(MouseEvent.MOUSE_OVER, onBtn0_Over);
function onBtn0_Over(evt:MouseEvent):void
{
trace("works");
}
Thanks / help appreciated

How Can I Get Button Pressed From Dynamically Generated Buttons?
I have generated a series of buttons using this:


Code:
duplicateMovieClip(sign, "sign"+z, z)
while still inside the loop that is creating the buttons I can get to each sign:


Code:
_root["sign"+z]._xscale = 240;
etc.

So, once the signs are on the stage - how do I determine which sign is clicked?

Code:
on (press){
trace(this._root.sign)
}
results in this ..._level0.sign... instead of say, ..._level0.sign0...
obviously because there is no loop.

Trying to access _name does the same.

Thanks
Charles

Problem Attaching GetURL Links To Dynamically Generated Buttons
I have a series of buttons on stage - dynamically generated from a single mc - inside of which is a button. After the buttons finish populating the stage I want to be able to click on each one and getURL.

Here's the code I have so far - but it disables the rollover effect of the button and each URL is the last one when clicked - even though I've added a counter.


Code:
for (z = 0; z <= mySignsLength-1; z++) {

//"sign"+z are the mcs at level0.sign0, _level0.sign2, _level0.sign4, etc.
this.signMC = eval("sign"+z);

//names is the array - letterNum is letter of the alphabet, 2nd element is the URL for each one
var addressz = names[letterNum][z+1];

signMC.onPress = function () {
getURL(addressz);
trace("click")
trace(addressz);
}

//increment to get each mc and skip URLs
z++
}
Any idea what I'm doing wrong here?

Thanks
Charles

Dynamically Generated Nav Bar
I am using Flash 8 for a web site and the client has asked me to build a nav bar in the image gallery that looks like this:

http://www.capitalwebtec.com/clients...nd-gallery.jpg

Here is the catch...The number of images will be determined by the client and they will put that number in a text file that will reside on the server. The nav bar has to build itself dynamically by pulling in the thumbs from the server (they will be named in sequence). So the pics have to come in externally, plus the number of pics has to be able to change each time the file is loaded.

There will only be four thumbs displayed at a time, but I have to set it up so that you can rotate through as many as there are by clicking on the arrows on the left and right side of the nav. Is this clear? I have no idea where to begin building this dynamically.

Help!

Thanks,
Brian

Dynamically Generated Images
Hey,

I'm about to design a site that has a very large art gallery section. Does anyone know if Flash can dynamically import images (.jpg or .gif) using ColdFusion and/or JavaScript?

Any suggestions would be appreciated.

thanks,
Janet

Printing Dynamically Generated MC's...
i've built a function that basically generates a table that displays client information from a coldfusion database.. basically there are 8 tables that need to be made, and each needs to be printable... the only way that i thought that this could be possible is to have each table in a separate frame and then print the level or the MC with a bounding box...

on each of the 8 frames, the main function is called to build the table with a certain amount of rows and data.. i have a print button on each frame that works great by printing the movie clip with the "bmovie" bounding box. when i try print all of the tables at once, it prints up 8 empty, unformatted tables... the only other solution that i had was to go to each frame and automatically print and thenn go to the next frame, but only if the printall button was pressed... apparently this is not acceptable to my bosses... is it possible to que all 8 tables at once as opposed to having the user have to press "yes" 8 times, one for each table?...

Dynamically Generated Flash
Hi there,

I'm kinda new to Actionscript so please forgive me if there is something really easy.

Basically, let's suppose I have a list:-

a1,a2,a3,a4
b1,b2
c1,c2,c3,c4,c5,c6
d1,d2,d3

Is it possible to create a function(or the like) that can read the info in the list and dynamically create a page or frame for each of the items? Each item may have it's own content which would be stored in a common place.

Could the info from the list be used to generate a dynamic menu i.e. taking the list above the first menu would contain a,b,c,d, click on any of those and the next menu would be created, so in the case of 'a' it would 1,2,3,4. The list may vary in length but the important thing is the Actionscript would read the list and create the required frames.

Thanks in advance,

Nick

Dynamically Generated Menu
I'm dynamically generating a plethora of instances of a button using attachMovie. The buttons are supposed to collectively function as a menu. Is there any way to make a pressed button stay in the down state until another one is pressed? Also, I need each button instance to be selected and in the down state when it is first created.

I am using Flash MX/actionscript 1.0

Formatting Dynamically Generated Txt
hi

I am working on a mail form that passes variables and formats the users details.

The end result being a dynamic txt box (variable message2send).

What I want to do I format it so the Username, Email, Message etc are in different colours to the rest of the formatted txt.

This is the code im using (just sender name)


Code:
message2send = "Hello" <font color="#FFCC33">sender_name</font> + Newline + " " + Newline + "You are about to send this message: " + Newline + Newline + sender_message + Newline + Newline + "Your E-mail is: " + Newline + " " + Newline + sender_email;



Thanks very much

Grub

Dynamically Generated Titles
I am trying to get my Flash file to generate a dynamic title depending on what page the flash file is on. For example, if my flash file loads on index.htm I want the title to display 'Welcome'. If the flash file loads on ContactUs.htm then the title should display 'Contact Us.' I am new to this so please be detailed in your explanation. Any help would be greatly appreciated

Dynamically Generated Content Help
I've run into a problem that I've tried to get around for some time now,
but have always failed miserably. I have this bit of code attached to a movie
clip here:


function dot(){
i++;
duplicateMovieClip(_parent.tap_mc,"ball"+i,i);
b=eval("_parent.ball"+i);b._x=this._x;
b._y=this._y;
b.onEnterFrame=function(){
b._y-=speed;
if(b._y<215){
removeMovieClip(b);
}
}
}

This mostly works, the problem is that whenever I use the function again while another duplicated movie clip is on screen, the onEnterFrame bit stops working and the earlier movie clip stops moving.

Any ideas? thanks

Dynamically Generated Forms
My company has a database-driven system of web forms, each of which consists of many questions in various layouts (2-column radio, 1 column checkbox, etc). The forms are never hard-coded. Each HTTP request causes Java code to perform DB queries to dynamically generate the various questions and answers. Those questions are then rendered through JSP and Struts tiles into HTML.

The HTML also contains JavaScript functions to hide/show conditional questions on the web page based on answers to earlier questions.

Now we're trying to figure out the best way to adapt this system to use a Flash front-end instead of HTML/JavaScript.

My preliminary research suggests at least two possible approaches:

1. A pre-compiled SWF could send a request with certain parameters, and the server could respond with an XML description of the form to build. Then the SWF could parse that XML and dynamically generate the form using attachMovie for each form element (with a lot of math to determine relative positions of elements with variable sizes, like text labels).

2. Flex might reduce the code for placing elements, by using MXML to describe the form structure as well as visual arrangement. I haven't used this yet, and I'm wary of Flex 2 simply because it requires Flash Player 9 which is only at 50% browser penetration (http://blog.flashforwardconference.c...me-highlights/) but I might try an earlier version of Flex if it helps.

Does anyone have a suggestion about the best approach to solving this problem?

Thanks in advance for any advice.

Problems With Dynamically Generated Xml.
Hi all,

In order to learn how AS3 works with php,xml, and mysql better, I'm trying to get flash to read from a dynamically generated xml file from php, which is getting its data from a mysql database. However, when I tell flash to open up the php file I get the following error code. But, Im pretty sure it shows up as a valid xml file. Please have a look at the code.

Error:

Code:
TypeError: Error #1088: The markup in the document following the root element must be well-formed."
Flash:

Code:
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onLoaded);

var xmlData:XML;

function onLoaded(e:Event):void {
xmlData = new XML(e.target.data);
trace(xmlData);
}

xmlLoader.load(new URLRequest("mailList.php"));
PHP:

PHP Code:



<?php

$con = mysql_connect("localhost", "user", "pass");
mysql_select_db("mailList");

$query = ('SELECT * FROM persons');

$results = mysql_query($query);

echo "<?xml version="1.0" encoding="utf-8"?>
";
echo "<mailList>
";

while($line = mysql_fetch_assoc($results)) {
    echo "    <person>
";
    echo "        <name>" . $line["name"] . "</name>
";
    echo "        <email>" . $line["email"] . "</email>
";
    echo "    </person>
";
}

echo "</mailList>
";

mysql_close($con);

?>




Resulting XML:

Code:
<?xml version="1.0" encoding="utf-8"?>
<mailList>
<person>
<name>Person1</name>
<email>person1@mail.com</email>
</person>
<person>
<name>Person2</name>
<email>person2@mail.com</email>
</person>
</mailList>
Any help on this would be greatly appreciated.

GetRGB Of Dynamically Generated MCs
Hi,

I have loaded a list of RGB colors into an array from an external txt-file.
Then I've assigned these colors to a grid of square MovieClips that have been created with two for-loops.

Now i would like each square MC to trace its color when clicked. How would that work?

This is the code so far but of course it always only traces the same color value which has been assigned last...

var loadColors:LoadVars = new LoadVars(); //colors.txt is being loaded
loadColors.load("colors.txt");
loadColors.onLoad = function(success){
if(success){
myColors = this.colors.split(",");

var i = 0; //square MC is duplicated
for (var x=0; x<4; x++) {
for (var y=0; y<4; y++) {
var mc = square.duplicateMovieClip("square"+i+"_mc", i);
mc._x = square0_mc._x+(x*(square._xscale));
mc._y = square0_mc._y+(y*(square._yscale));

var new_color:Color = new Color(mc); //colors are assigned to squares
new_color.setRGB(myColors[i]);
i++;

mc.onPress = function(){ //here is where i try to trace the color for each MC
var myValue:String = new_color.getRGB().toString(16);

trace(myValue);
}
}
}
}
}

Any ideas? I appreciate every help a lot as i am new to this.

Removing Dynamically Generated MCs
Can someone recommend an efficient way to remove the clips generated by the following function.


Code:
function loadClips() {

for (i = 0; i < Urls.length; i++) {
var mov:MovieClip = attachMovie("numClip", "numClip"+i, this.getNextHighestDepth(), {_x:xPos, _y:yPos});
xPos += this["numClip"+i]._width+5;
this["numClip"+i].ID = i;
this["numClip"+i].onRelease = function() {
holder.loadMovie(Urls[i]);

}
}
Thanks / help appreciated

Dynamically Generated Menu
I'm dynamically generating a plethora of instances of a button using attachMovie. The buttons are supposed to collectively function as a menu. Is there any way to make a pressed button stay in the down state until another one is pressed? Also, I need each button instance to be selected and in the down state when it is first created.

Linking Within A Dynamically Generated MC
I've got a movie player that I'm building which has a scroll pane whose content is dynamically driven from an array in ActionScript 2. The for loop creates a movie clip using the attachMovie command. The movieclip has several text fields within it populated from various arrays. I've taken care of all that. Now here's my problem.

The first text field has to link to the video player function to start the new video. The third text field has to link to an external website using the GetURL function I would assume since it is linking to external websites, and this will be a projector file.

Is there anyway I can assign an onPress event to a text field or something similar in Action Script 2?

Dynamically Generated Objects
Hi all.

I want to generate a series of 'buttons' dynamically and have them available publically. The 'buttons' are movie clips that I have in the library and assigned linkage 'itemLink'. What I intended was to create a public array and then within the function where the itemLinks are generated I would assign the latest to a new element. Something like this.


var myURLLoader:URLLoader = new URLLoader();
var myURLRequest:URLRequest = new URLRequest('http://www.mysite.com/itemgrab.php');

myURLLoader.load(myURLRequest);

myURLLoader.addEventListener(Event.COMPLETE, dataOK);

function dataOK(myEvent:Event):void
{
var myItems:XML = new XML(myURLLoader.data);
}


var items:Array = new Array();

function createItems():void
{
var noItmes:int = new int(myItmes.node.item.length) // this is not returning number of child nodes of 'node'...
for(i=0; i<noItems; i++)
{
var itemButton:itemLink = new itemLink();
stage.addChild(itemButton);
itemButton.x = itemButton.y = (20*i);
items[] = itemButton;
}
}

I want to be able to manipulate these 'buttons' in another function like so...

function moveItems(key:int):void
{
items[key].x = -200;
}

Any help or pointers would be VERY much appreciated.

[F8 AS2] Loading Dynamically Generated XML?
ok, here's the deal. We are creating an ecard that will be customized by the sender, and sent to soldiers in Iraq. There are about 5 different things that the sender can customize, as well as write a message. The goal is to have their choices sent to a database and then inserting those variables when the receiver watches the movie.

Now, instead of creating possibly thousands of XML files (one for each sender), we decided it would be better to just generate the XML on the fly from the info in the db. But my question is, how do I handle loading that XML? Since this won't just be a static page on the server, I'm not sure how to go about it. I'm wondering if you can use variables when loading XML, for example:

ActionScript Code:
my_xml.load("senderData.xml?user=LyndaSmith");


Basically, how can i create an XML file on the fly with the values from the DB, that can then be loaded into Flash?

I have virtually no experience with db's, so this is the method I came up with because I do have some experience with XML. I have a developer who will actually insert the values into the database with ColdFusion, and he can also generate the XML, I just need to be able to load the dynamic XML in flash when the receiver watches the card.

If anyone has any ideas on this, or alternate solutions, I'd love to hear em. Thanks..

Targeting Dynamically Generated MCs
I have some movieclips....Which i want to make on release actions for;
MCs Made as follows......

Code:
for(i=0; i<allNews.length; i++){

duplicateMovieClip(_root.newsBox.newsCount.allNumbers.newsNumber, "newsNumber"+(i+1), 5+i);
_root.newsBox.newsCount.allNumbers["newsNumber"+(i+1)].digit = (i+1);
_root.newsBox.newsCount.allNumbers["newsNumber"+(i+1)]._x = (numberX+(numberW*(i+1)));
}
I cant seem to target them!
What am i doing wrong?

I have the following on the M-clip that is being duplicated, but i feel i need to generate this somehow after the clips are duplicated on stage in order for this to work...

Code:
on (release){
//function clickedNews(){
_root.newsBox.newsContent.title = allheadings[(this.digit)];
_root.newsBox.newsContent.content = allNews[(this.digit)].firstChild;
_root.newsBox.newspicbox_mc.loadMovie("content/newsthumb"+[this.digit]+".jpg");
Many Thanks for any help people... in advance.

Dynamically Generated Objects
Can an Object be generated in a class by referencing other classes dynamically?

For example:

Code:
public var myArray:Array = ["Item1","Item2","Item3","Item4"];
makeObjects(myArray);

public function makeObjects(myArray:Array):void{
for (var i:uint = i; i<myArray.length; i++){
//This is where the question is...
public var myArray[i]+Instance:myArray[i] = myArray[i]();
return myArray[i]+Instance;
//or slightly different scenario...
public var myArray[i]+Instance:myArray[i]+Alt = myArray[i]+Alt();
return myArray[i]+Instance;
}
}
The Strings represented in the Array are classes that are partial class names. In this example, however, they represent the full class datatype and constructor that already exist.

Is there then a way to dynamically generate the objects that have reference to a specific class without hard coding each one?

Thanks,
Brent

Removing Dynamically Generated MCs
Can someone recommend an efficient way to remove the clips generated by the following function.


Code:
function loadClips() {

for (i = 0; i < Urls.length; i++) {
var mov:MovieClip = attachMovie("numClip", "numClip"+i, this.getNextHighestDepth(), {_x:xPos, _y:yPos});
xPos += this["numClip"+i]._width+5;
this["numClip"+i].ID = i;
this["numClip"+i].onRelease = function() {
holder.loadMovie(Urls[i]);

}
}
Thanks / help appreciated

Dynamically Generated Button
I have this script to dynamically generate buttons. How would I get text to be dynamically generated 'in' the button?
Thanks!
Va.


buttonArray = new Array("Home","Privacy & Security","Contact Us","DoD Warning")
theButton._visible = false
for(i = 0; i < buttonArray.length; i++)
{
duplicateMovieClip("theButton", "Button" + i, i + 1);
thisButton = this["Button" + i];
if (i > 0){
thisButton._x = this["Button" + (i - 1)]._x + this["Button" + (i - 1)]._width + 2;
}
thisButton.buttonText = buttonArray[i];
}

Random & Dynamically Generated Txt
I was trying to figure out how to create an array (simple enough) but then have the array feed into dynamically generated text that appears in a "textCloudMC". Could someone point me in the right direction? Basic thoughts on the actionscript and best practice structure would help a lot!!!
Thanks,
Va.

Loading Dynamically Generated Variables
Hmm... this is kind of an akward problem, and i don't think it's solvable through flash alone, but here goes -

I'm attempting to integrate flash in to dynamically generated HTML. It's an online diary site that that uses the following variables:

%%entry%% - the actual entry
%%time%% - (optional) the time it was entered
%%date%% - (optional) the data it was entered
%%prev%% - (optional) links to the previous entry
%%next%% - (optional) links to the next entry
%%short_description%% - pretty much the title
%%older_entries%% - links to a page that has all of your older entries sorted by date and identiied by their %%short_description%% value.

what i mean is when you 'create' an entry on their site, you have an HTML page that displays them. When you create the entry, you give it a name that will be it's location (.html name to refer to), and his script assigns your form entries to the above variables. So on the main entry page, to display the actual entry, all i would do in the HTML is put %%entry%% (with no links or anything) and whatever i typed in when i created the entry, appears. here is the problem...when i load the %%variables%% into my text fields in flash, i use the following method in my html:

<OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH=320 HEIGHT=240>
<PARAM NAME=movie VALUE="http://member.diaryland.com/images/test.swf?title=%%short_description%%&textbox.entry =%%entry%%">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="http://member.diaryland.com/images/test.swf?title=%%short_description%%&textbox.entry =%%entry%%" quality=high bgcolor=#000000 WIDTH=320 HEIGHT=240 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>

If you can figure it out from the way i load it, i have a dynamic text box on the main timeline called "title" in which i load the %%short_description%% variable, and a dynamic textbox inside a movie clip (textbox.entry) that loads the %%entry%%. Right now, this is all i have in my .swf, so the file is only 3k. what happens is sometimes the data loads, and sometimes it doesn't. when it doesn't if i hit reload a few times, it loads up sometimes. So what i think is happening here is that because of the method that i'm using to load the variables, sometimes the .swf isn't fully loaded before the variables are designated, so it tries to load them once, but because the .swf isn't loaded it fails silently. This isn't a huge problem right now because sometimes it does load, but if i make the .swf any bigger, it will never load.

I've tried loading the variables with the loadVariables() function, but it loads the whole <param> tag after the first <p> tag. what i mean is when the HTML page is loaded, if you look at the source, you don't see the %%variables%% up there, you see the actual value..

So i guess i was wondering if there is any way to make sure the .swf loads, and then load the %%variables%% into the swf... maybe intergrating javascript or somthing? i've pretty much exhausted all of my resources here, so any help would be much appreciated.

thanks

Help On Removing Dynamically Generated MovieClip
hello...

i am creating some movieclips in my script with duplicateMovieClip. i also tried it with attachmovie and createemptymovieclip. then i am using some _lineto,_moveto's with styles, etc. i now need to clear and/or remove only specific clips, again from code to recalculate it and draw again. i tried removemovieclip first, then discovered clear(), which clears all of the generated movieclips. is there a specific way to create the clips, so i can easily remove them?

here is the latest version of my code:


Code:
attachMovie("_root.bo","box" add obj,obj);
with("_root.box" add obj){
if (part==0){
removeMovieClip("box" add obj);
}


tnx for the info you will be providing.

Shared Libraries - Dynamically Generated?
I was wondering if any of you have come across a way to control symbol linkage with ActionScript?
Specifically, if there is a way to dynamically generate the URL field property when you

right-click on symbol in library > linkage > import for runtime sharing

That would be sweet I could tell a SWF where to look for libraries to import without having to modify the FLA with a hard-coded value.

Anyone have any ideas if this is possible? I'm using MX.

XML Dynamically Generated Menu Keeps Rising To The Top
Hey all- I developed an XML based dynamically generated menu and thought that the hard part was done....little did I know
Here's the situation, the menu is created using a duplicateMovieClip function. The problem is that once the menu loads, there is enough content that it must scroll. Unfortunately, I can't mask the menu or put the background in front of it. It automatically rises to the top level no matter what I try. This results in the scrolled content appearing over all other content and not being contained to it's location. Does anyone have any ideas?

Thanks
Cognizen

Dynamically Generated Numbered List
Hey there,

I'd love to get your help on the following:

I have a frame where I have placed a dynamic text box called "totaldisplay". The text that will be displayed in this text box is determined in the frame's action script. I've copied some of it below:

_________________________________________

totaldisplay=""


if (pp300) {
totaldisplay += "Product: Can Opener Item#: PP-300 Quantity:" add _root.pp300qty add " Subtotal:"add _root.pp300sub add "
";}
else{}


if (pp400) {
totaldisplay += "Vegetable Peeler Item#: PP-400 Quantity:" add _root.pp400qty add " Subtotal:"add _root.pp400sub add "
";}
else{}

_________________________________________

And on it goes. So my problem is, how do I make a numbered list with the text this code generates? I can't hard-code in any numbers, because the user may or may not order PP-300. Do you see what I mean? Somehow I need to be able to create a function in my code that can number the lines of generated text dynamically.

Can you help?

Many thanks,
QM

Dynamically Generated Input Fields
Hi all,
I've been trying all kinds of ideas to get this working but to no avail.
What i am doing is querying a database via PHP. All works fine and this is the result i am sending back to flash:

Code:
status=You're in&n=2&name_First0=Darryll&name_First1=Michael&checklog=1
Basically n=number of rows returned. The values name_First are auto icremented with a number at the end, depending on the value for "n".
What i have been trying to do is dynamically create the dymanic text fields that will hold the values for name_First0 and name_First1. Obviously if there were more results in the database the dynamic text fields would need to increase according to this.
Any ideas on how to write the actionscript for this?
Kind Regards,
Suzy

Questions On Dynamically Generated Text
Hi,

In the attached .fla I was wondering a few things:

1) How can I get the text I'm creating to be linked somewhere? Ideally I'd like them to act as buttons that can call a loadMovie function to load another .swf.

2) How can I make them so they're not selectable? I have .selectable = false, but that doesn't seem to work.

Dynamically Generated Volume Slider Help
could someone help me with this dynamically created vol slider and sound? a new instance of the sound is created every time the frame containing the script is entered....obviously i only want one instance to play/loop. i tried a number of things including trying to begin play with onClipEvent (load) and everything else that seemed semi-logical. Been all through the Flash MX Sound Object Tutorial by Kenny Bellew and found nothing there to help me. So I'm hoping i can find an answer here.

Any help is appreciated. thanks in advance

tried posting this in the sound section of the forum, but didn't seem like there was anyone there to help. you can find the file for download at this thread

thanks for your help.

Calling Dynamically Generated Functions
I'm sure this has been covered before, but I couldn't find any posts in the forums.

I need to take a string (which is the name of a function) and call it as a function. Here's a simplified version of what I'm trying to accomplish:


PHP Code:



package
{
    import flash.display.Sprite;
    
    public class CallingDynamicFunctions extends Sprite
    {        
        private var functionName1:String = "function1";
        private var functionName2:String = "function2";
        
        public function CallingDynamicFunctions()
        {
            init();
        }
        
        private function init():void
        {
            var randomInteger:uint = Math.random()*2+1;
            var randomFunctionName:String = "functionName"+randomInteger;
            var randomFunction:Function = randomFunctionName as Function;
            
            randomFunction();
        }
        
        private function function1():void
        {
            trace ("function1() called.");
        }
        
        private function function2():void
        {
            trace ("function2() called.");
        }
    }
}




This is the line that seems to be tripping me up:

PHP Code:



var randomFunction:Function = randomFunctionName as Function;




The reason for this is that I'd like a function name to be passed during a TextEvent dispatch and then convert it into an actual function and call it.

Thanks in advance.

Need A Way To Find A Dynamically Generated Frame's Name.
Hi, here is what I'm working with.

There is a site where I know there will be an iframe, but it's named randomly.

I will have an swf on the page with allowscriptaccess set to never.

I need my swf to be able to find the iframe and get it's name as a variable within the swf.

Alternatively, if there is a way to use a form method post directly to the nearest iframe without needing it's exact name that will work too.

Thanks a lot!

Issue With Movieclip Generated Dynamically
hello!

i'm generating a bunch of Movieclips dynamically. Basically, a "stripContainer" gets attached 3 subContainer MCs "sequence1, sequence2,sequence3", each of which gets attached 100 or so subMCs containing each a jpeg ("image1",image2"...).

so each image mc should have a path that is similar to: _level0.stripContainer.sequence2.image32

Yet they are all attached to sequence0:
_level0.stripContainer.sequence0.image290

the result looks like what i want (up to a point) but when i look in the debugger, i see that indeed all the image MCs are attached to the sequence0.

sequence1 and sequence do get generated but they are empty.

Can you tell where is my mistake?

Here is my code:

ActionScript Code:
var finishedLoading:Boolean = false;
    var h:Number = 0;
    var i:Number = 0;
    var imgLoader = new MovieClipLoader();
    imgLoader.onLoadComplete = function(targetMC)
    {
        i++;
        loadImg();
    };
    var mySequence:Object = sequencesHolder[0];
    var sequenceMC:MovieClip = stripContainer.createEmptyMovieClip(mySequence.instance, stripContainer.getNextHighestDepth());
    sequenceMC._x = mySequence.xPosStart;
    sequenceMC.instance = mySequence.instance;
    sequenceMC.onRelease = function()
    {
        trace("my name is:"+this);
    };
    loadImg = function ()
    {
        if (h<sequencesHolder.length)
        {
            var mySequence:Object = sequencesHolder[h];
            if (i<mySequence.images.length)
            {
                var myImg:Object = mySequence.images[i];
                var myMC:MovieClip = sequenceMC.createEmptyMovieClip(myImg.instance, sequenceMC.getNextHighestDepth());
                myMC._x = myImg.xPosStart;
                myMC.xPos = myImg.xPos;
                myMC._xscale = myImg.startWidth;
                imgLoader.loadClip(myImg.fileToLoad,myMC);
            }
            else
            {
                h++;
                i = 0;
                var sequenceMC:MovieClip = stripContainer.createEmptyMovieClip(mySequence.instance, stripContainer.getNextHighestDepth());
                sequenceMC._x = mySequence.xPosStart;
                sequenceMC.instance = mySequence.instance;
                sequenceMC.onRelease = function()
                {
                    trace("my name is:"+this);
                };
                loadImg();
            }
        }
        else
        {
            finishedLoading = true;
        }
    };

    loadImg();

thanks for your help!

Checking The Load Of A Dynamically Generated XML
I did a search for similar topics and did not find anything quite like this. If I have missed a previous topic, or this is the wrong forum to post this in, please let me know.

The Sitch. We have a map, with locations and data loaded from XML. And it works great from a static XML file. But the client wants it to come from their database, so we are dynamically generating a XML formatted ASPX page when flash calls for it. Here's the problem. The Dynamic page takes several seconds to generate (5-10). I don't know why it's so slow, im a flash guy, not a asp guy. So I tried the standard code to check the load.


Code:
var xmlPath:String;
// path to XML - set from flashvars
// set path for testing purposes
if (xmlPath == null) {
xmlPath = "xml/locations.xml";
}

var map:XML = new XML();
map.ignoreWhite = true;
map.onLoad = function(success:Boolean) {
if (success) {
parseMapXML();
trace("XML loaded successfully");
} else {
trace("XML loading failed !!!");
}
};
map.load(xmlPath);
Of course this code works just fine with a static XML. But when we use it with the dynamically generated, it returns that the file is successfully loaded even though there is NO CONTENT in it for several more seconds. I guess because the aspx file IS loading... it just has no content in it until a few seconds later.

Then I thought I'd try a look to check for specific content in the XML before proceeding... but unless I am doing it wrong, you have to call back to the XML file to check it (becuase if you just reference the xmlObject then your just going to get the same cached nothingess, correct?), and everytime we do that it re-initates the asp function that builds the XML page... so it's an infinite loop.

Does anyone have an idea of how to check for the COMPLETE load of a dynamically generated XML page?

Thanks in advnace.

Capturing Dynamically Generated Content
I'm looking for a way to capture graphics generated at runtime by actionscript to a high-resolution image file and/or quicktime movie. This could be a .fla only one frame in length. Any ideas? Thanks.

Accessing Dynamically Generated Components
Hello I hope someone will be able to help me out with this issue. I am dynamically instantiating input objects like this:


ActionScript Code:
var newHSliderComponent:HSlider = new HSlider();
// DATABASE RETRIEVED VALUE -> idString
newHSliderComponent.id          = idString.toString();
newHSliderComponent.addEventListener(ListEvent.CHANGE, updateValuesFunc);
newHSliderComponent.minimum      = 0;
newHSliderComponent.maximum      = 100;
newHSliderComponent.width        = 273;
newHSliderComponent.liveDragging = true;
newHSliderComponent.labels       = [0,100];
myCanvas.addChild(newHSliderComponent);


var newTextInput:TextInput = new TextInput();
newTextInput.id            = idString.toString() + "_SliderValue";
newTextInput.width = 60;
myCanvas.addChild(newTextInput);

private function updateValuesFunc(event:Event):void
{
    dataStorage[event.currentTarget.id] = event.currentTarget.value;
   
    event.currentTarget.id + "_SliderValue".text = event.currentTarget.value;
   
}

I just posted the relevant code. As you can see I have a horizontal slider that I give an ID that is a value from a DB. I give it an event
listener for when the slider is moved. The "updateValuesFunc" takes the value selected in the slider coponent and stores it in an associative
array with the dynamic ID of the slider as the key. The function then attempts to set the newTextInput to the value from the slider because I
want the user to see the value they selected from a dynamic slider in the dynamic text input.

I attempt the above by setting the ID of the textinput to


ActionScript Code:
newTextInput.id            = idString.toString() + "_SliderValue";

so I set the textinput ID to be the dynamic DB value with the string "_SliderValue" added at the end and so when the slider changes I tried
to set the text of the textinput like this without success:


ActionScript Code:
event.currentTarget.id + "_SliderValue".text = event.currentTarget.value;

These input components MUST be dynamically created - no static mxml code must exist. Can anyone help me out with this? In short I really dont
know how to set a dynamically generated value in a textinput AFTER it has been created on the fly and added to a canvas in my application
because I get "undefined" errors

PLEASE HELP!

Calling Dynamically Generated Functions
I'm sure this has been covered before, but I couldn't find any posts in the forums.

I need to take a string (which is the name of a function) and call it as a function. Here's a simplified version of what I'm trying to accomplish:


ActionScript Code:
package
{
    import flash.display.Sprite;
   
    public class CallingDynamicFunctions extends Sprite
    {      
        private var functionName1:String = "function1";
        private var functionName2:String = "function2";
       
        public function CallingDynamicFunctions()
        {
            init();
        }
       
        private function init():void
        {
            var randomInteger:uint = Math.random()*2+1;
            var randomFunctionName:String = "functionName"+randomInteger;
            var randomFunction:Function = randomFunctionName as Function;
           
            randomFunction();
        }
       
        private function function1():void
        {
            trace ("function1() called.");
        }
       
        private function function2():void
        {
            trace ("function2() called.");
        }
    }
}

This is the line that seems to be tripping me up:

ActionScript Code:
var randomFunction:Function = randomFunctionName as Function;

The reason for this is that I'd like a function name to be passed during a TextEvent dispatch and then convert it into an actual function and call it.

Thanks in advance.

How To Remove Dynamically Generated EventListeners?
Does anybody know how I can remove dynamically generated EventListeners?

In a for statement I use a function addListeners which returns a Function (MouseEvent), how can I remove the Listener?

The code is as follows:


Code:

for (var i:int = 0; i < numberOfRows; i++) {

for (var j:int = 0; j < numberOfColumns; j++) {
square = new Sprite();
square.graphics.lineStyle(2, 0x000000);
square.graphics.beginFill(offColor);
square.graphics.drawRect(0,0,boxWidth,boxHeight);
square.graphics.endFill();

square.x = (j+1)*boxXSpace + j*boxWidth;
square.y = (i+1)*boxYSpace + i*boxHeight;
square.name = "square" + String(i) + String(j);

square.addEventListener(MouseEvent.CLICK,createListener(i,j));
}
}


function createListener(a:int, b:int):Function {
var foo:Function = function (evt:MouseEvent):void {
switchAt(a,b);
}
return foo;
}
Any help is highly appreciated!

Dynamically Generated Motion Guide.
Hi.

I want to make my object (say, a plane) move along the dynamically generated path (like an arc or curve from city to city on a map).
In fact, I can make it "fly" along a curve drawn by pencil tool, but what if I generate an arc or curve in real time and want it to be a motion path for the object.
Still cannot find how to do this trick in Flash. Can anyone be a help?

Masking A Dynamically Generated Rectangle
I deleted my original post due to unclarity. Sooo...

I am using AS to dynamically generate a rectangle with a depth of 1, which will end up being duplicated across the stage. I have a layer above my AS layer which I am using to mask the dynamically generated rectangle. It contains a movieClip which contains a symbol that I am using for the Mask. But when I test the movie the masking does not work and I see the rectangle unmasked. This is still the same even if I use AS to set the depth of the movieClip in the mask layer to 2. BUT as soon as I turn off the Masking you can see that the rectangle is below the mask layer. link to file:

flash - bg.fla

Thanks in advance,
TofuTerror

Want The Movieclip To Be Draggable That Is Dynamically Generated
Hi All
I have a movie clip in a window. When i drag that clip outside the window a duplicate movie of the origianl movie clip is generated. Thats done. But once it is been generated i am not able to drag the duplicate movie clip. Can anyone please help me out with this.
Badly Stuck up with this problem.....
Please write in if anyone has the solution..

Dynamically Generated Popup Issues
I have a bunch of buttons on the stage. When those buttons are pressed a dynamicly generated popup appears in the middle of the stage, over the buttons. Everything works fine except for the fact that when a popup is open I get the hand cursor when the mouse is over a button (that is behind the pop up). My question is why does the hand cursor appear if there is a movie clip on top of the a button.

The following is the function I am using to create the popup box that displays a picture and text.


ActionScript Code:
function popup(pict, txt) {
    //creates new movie clip for the popup
    _root.createEmptyMovieClip("popup_mc", _root.getNextHighestDepth());
    //attactches picture to the movie clip
    popup_mc.attachMovie(pict, "pic_mc", 20);
    pic = popup_mc.pic_mc;
    //Defines margins
    margin = 5;
    //Defines text box
    popup_mc.createTextField("info_txt", 30, margin, pic._height+margin*2, pic._width, 30);
    info = popup_mc.info_txt;
    info.text = txt;
    info.multiline = true;
    info.wordWrap = true;
    info.autoSize = true;
    info.selectable = false;
    //Attaches close button and defines its functionality
    popup_mc.attachMovie("close_mc", "close_btn", 25);
    exit = popup_mc.close_btn;
    exit.onRelease = function() {
        _root.reset_highlight();
        _root.popup_mc.removeMovieClip();
        highlock = false;
    };
    exit.onRollOver = function() {
        this.gotoAndStop("over");
    };
    exit.onRollOut = function() {
        this.gotoAndStop("default");
    };
    //positions close button
    exit._x = (margin*2+pic._width)-exit._width;
    exit._y = pic._height+info._height+margin*2;
    //defines how big of a box needs to be drawn to encompass the picture, text and close button.
    boxW = margin*2+pic._width;
    boxH = margin*2+pic._height+info._height+close_btn._height+exit._height;
    //Moves picture
    pic._x += margin;
    pic._y += margin;
    //draws a box that encompasses the picture, text and close button.
    with (_root.popup_mc) {
        lineStyle(2, 0x1C60A9, 100);
        beginFill(0xC6D7E9, 100);
        moveTo(0, 0);
        lineTo(boxW, 0);
        lineTo(boxW, boxH);
        lineTo(0, boxH);
        lineTo(0, 0);
        endFill();
    }
   
    //centers the popup
    popup_mc._x = Math.round((450-popup_mc._width)/2);
    popup_mc._y = Math.round((430-popup_mc._height)/2);
}

I was thinking that he problem might have something to do with layer depths, but I am not sure. Any help would be great.........


Also, on another note, I am having problem formatting the text in this popup as well.

Removing Dynamically Generated MCs From Timeline
I'm working on a Flash/XML photo album that loads external images via XML. I've created thumbnails that load dynamically and now I want the thumbnail mc's to disappear once the playhead exits the frame where the photo album rests on the root timeline (which is frame 5). This function should be activated via button release that moves the playhead to a different frame in the timeline.

I'm showing two functions, one which displays the thumbnail MC's and the other which unloads the MC's whiche were generated dynamically. I'm having difficulty with the second function. It does not unload the mc's; once the playhead moves to a different frame the mc's are still visible. I have the removeMC function activated by an onRelease button event handler. And what's even stranger is that it only removes the last thumbnail MC.

Any help on this matter would be greatly appreciated. Thanks!

function thumbDisplay(thumbnails) {
var galleryLength:Number = thumbnails.length;
// loop through each of the images in the gallery_array.
for (var i = 0; i<galleryLength; i++) {
/* create a movie clip instance which holds the image, also sets a variable,
thisMC, which is an alias to the movie clip instance. */
thisMC = this.createEmptyMovieClip("image"+i+"_mc", i);
/* load the current image source into the new movie clip instance,
using the MovieClipLoader class. */
mcLoader_mcl.loadClip("photos/"+selectedGallery+"/thumbs/"+thumbnails, thisMC);
// set the _x and _y coordinates of the new movie clip.
thisMC._x = _global.thisX;
thisMC._y = _global.thisY;
// if you've displayed 3 columns of images, start a new row.
if ((i+1)%3 == 0) {
// reset the X and Y positions
_global.thisX = 565;
_global.thisY += 50+1;
} else {
_global.thisX += 50+1;
}
}
if (galleryLength<prevArrayLength) {
for (var j = galleryLength; j<prevArrayLength; j++) {
this.getInstanceAtDepth(j).removeMovieClip();
}
}
prevArrayLength = galleryLength;
}


function removeMC():Void {
for (var i = 0; i<thumbnails.length; i++) {
thisMC.unloadMovie("image"+i+"_mc");
}
}

Dynamically Generated Movieclip Properties
Hi,

I'm currently reading in data from an XML file. Each attribute of a child is assigned as a property of a movieclip as shown in the code attached. However, what i'd like to do is not have the property names already decided as i don't necessarily know how many attributes a child in the xml file will have. Is it possible to dynamically name the properties depending on what number attribute they are...?

thanks in advance

Greg







Attach Code

var slideLength:XMLList = theXML.child(nPosition).children();

for (nCount01; nCount01 < slideLength.length(); nCount01++
{
var propertyArray:Array = new Array();
//create movieClip for each user
var MC:MovieClip = new MovieClip();

//attribute array is an array of the attributes that appear in the xml file, it is parsed to this class.
for(var i:int = 0; i<attributeArray.length;i++)
{
propertyArray[i] = theXML.child(nPosition).children().attribute(attributeArray[i])[nCount01];
}
MC.sTitle = propertyArray[0];
MC.sProject = propertyArray[1];
MC.sVidLink = propertyArray[2];
MC.sVidClip = propertyArray[3];
MC.sClipText = propertyArray[4];
MC.sVidText = propertyArray[5];
MC.buttonMode = true;
theArray[nCount01]=MC;
}

Attaching Actions To Dynamically Generated MCs
Currently I have a Flash menu that load a bunch of numerically named jpgs in my menu. Using this code...

Code:
i=1
currentX = 585
currentY = 88
while( i < 10){
_root.createEmptyMovieClip(i,i+10)
with (eval('_root.'+i)){
_x=currentX
_y=currentY
_xscale = 100
_yscale = 100
loadMovie(_root.section+'/thumb.'+i+'.jpg', this);
}
i++
if (currentX<680){
currentX+=32
}else {
currentX=585
currentY+=32
}
}
Of course the menu, must do something, so I am wondering how i can attach an action, so that when these MCs are clicked they will call a function.

Can anyone tell me how to do this?

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