ActionScript 3.0 :: Dynamically Placing New Buttons
Feb 15, 2009
It's been a few years since I've last used ActionScript, so I'm a bit rusty Anyways, I have 16 buttons in my library with linkage names btn0-btn15. I can successfully add them onto the stage by saying something like:
Code:
var tempBtn:SimpleButton = new btn0();
stage.addChild(tempBtn);
I'm going to be tinkering with the buttons layout and positions, and I would like to add each of the different buttons to the stage dynamically with a for loop. I've been trying different variations of this:
Code:
for (int i:int=0; i<16; i++) {
var tempBtn:SimpleButton = new ["btn" + i]();
}
but I just can't seem to find the right syntax for doing this correctly.
View 3 Replies
Similar Posts:
Feb 22, 2010
How can I place a startdrag correctly on dynamically loaded objects?
View 1 Replies
Jun 24, 2010
I am trying to create a navigation element. The items in the navigation are created dynamically from data in an XML file. What I would like to do is create a new movie clip then place all of the navigation elements into that movie clip so I can move it around as one piece.
Here is a simplified example of my code:
Code:
var navContainer:MovieClip = new MovieClip(); //clip to add elements to
addChild(navContainer);
//Create nav elements that I want inside navContainer//
[Code]....
View 3 Replies
Aug 20, 2010
I have created set of dials/meters with moving arms that change as buttons are pressed. The arms move based on a "Classic Tween" set-up I created. I then applied my buttons to the flash document and then coded in some "gotoAndPlay" on an actions layer to get the arms on the dials to move when I click on the buttons. My problem is that since I have 3 buttons (High, Medium & Low) and the tweens follow one frame right after another (0, 41,78) there is no stop. When I click on Low it plays the low tween, the medium one, and the high tween. When I click on the medium it plays both the Medium and then the High. The High button obviously only plays itself. I don't know how to insert a stop between these buttons.
stop();
low_btn.addEventListener(MouseEvent.CLICK, onLow); function onLow (Event:MouseEvent):void {
gotoAndPlay(0) }
med_btn.addEventListener(MouseEvent.CLICK, onMed); function onMed (Event:MouseEvent):void {
gotoAndPlay(41) }
high_btn.addEventListener(MouseEvent.CLICK, onHigh); function onHigh (Event:MouseEvent):void {
gotoAndPlay(75)
}
View 3 Replies
Oct 15, 2004
I used attachMovie to load a movieclip from the library into the stage. And in the movieclip, it has another movieclip named "imageHolder". As I wanted the movieclip to be placed on the stage like a list of buttons. The code goes as follows:
for(var i=0; i < 5; i++) {
_root.attachMovie("menuBtn", "menuItem" + i, 0);
_root["menuItem" + i]._x = 150;
_root["menuItem" + i]._y = 150 + setHeight * _root["menuBtn" + i]._height;
_root["menuItem" + i].imageHolder = loadMovie("something.jpg" , "imageHolder");
}
But the something.jpg doesn't appeared when I test the movie. And something.jpg is in the same directory as the .fla file.
View 10 Replies
Sep 23, 2009
Does anyone know the code for finding the global positioning of X & Y co-ordinates of a click of a button which is constantly rotating, and then secondly the code for when you click on the button it displays a movie clip on top of it -(position of x & y when clicked) at the angle that you clicked it,so underneath the buttons are still rotating so other people can click them where they are?
to explain the context, I'm trying to design a mock up of a circular interactive table Dynamically placing movie clip at the angle and global position of a mouse click (button) which is constantly rotating.when someone comes up to it and clicks on one of the buttons that are moving, it reads where the person clicked it and opens up a new box (movie clip) where they clicked it (at the angle) so its not upside down if you are at the top.
I've included my .fla file which shows the four buttons moving and a little diagram explaining what I'm trying to do.
View 3 Replies
Sep 23, 2009
Does anyone know the code for finding the global positioning of X & Y co-ordinates of a click of a button which is constantly rotating, and then secondly the code for when you click on the button it displays a movie clip on top of it -(position of x & y when clicked) at the angle that you clicked it, so underneath the buttons are still rotating so other people can click them where they are?
I'm trying to design a mock up of a circular interactive table when someone comes up to it and clicks on one of the buttons that are moving, it reads where the person clicked it and opens up a new box (movie clip) where they clicked it (at the angle) so its not upside down if you are at the top.
I've included my .fla file which shows the four buttons moving and a little diagram
explaining what I'm trying to do.
View 1 Replies
Sep 23, 2009
Does anyone know the code for finding the global positioning of X & Y co-ordinates of a click of a button which is constantly rotating, and then secondly the code for when you click on the button it displays a movie clip on top of it -(position of x & y when clicked) at the angle that you clicked it (so underneath the buttons are still rotating so other people can click them where they are)to explain the context, I'm trying to design a mock up of a circular interactive table when someone comes up to it and clicks on one of the buttons that are moving, it reads where the person clicked it and opens up a new box (movie clip) where they clicked it (at the angle) so its not upside down if you are at the topI've included my .fla file which shows the four buttons moving and a little diagramexplaining what I'm trying to do.
View 5 Replies
Feb 2, 2009
I'm testing out a method using AS2 to place two buttons on top of the rollover image of another button.
I'm using a structure and script that I found elsewhere on the web, but have one problem: I want the rollover image to remain active when the pointer hovers and clicks on the two smaller buttons.
The .fla is here...
[URL]
This is just a test, so the graphics are random.
The grey background image changes to the blue image on rollover.
The top and bottom grey buttons are both simply buttons that link to URLs -- one links to google and the other links to yahoo. The point is, I want the background image to stay blue when the pointer moves over the grey buttons. As it it, it reverts back to the off state.
View 1 Replies
Feb 4, 2010
Let's say I have this function
function Do(x:String){}
How can I make so that each time this function is called, it will add a form into a hbox, and that form will have 2 buttons yes and no and put x into the text of a label.When the user is going to click on Yes I need to trace(x) and remove the Form from the hbox
View 1 Replies
May 19, 2009
I've tried to access buttons in my menu. I only want to add listeners to the items that is in the XML file im loading.The thing is, i dont know how to call a button i've named "Var1_btn" when i've got a string "Var1".Does anyone know how to call buttons from a for-loop?
for each(var chapter in presentation_xml.*)
{
chapter + "_btn".addEventListener(MouseEvent.MOUSE_DOWN, traceit);
[code].....
View 4 Replies
Aug 14, 2009
well i wanted to make a navigation menu were you have say, 4 buttons or however many you want to have on the stage, this is controled by a variable. now next to the buttons on each side will be an arrow. now then i wish to have a variable that controls how many there will be in total. so if there is eight in total and only 4 showing then when you press the right arrow they will all dynamically move to the next set of buttons.
but the thing is, i need it to have a mask so you can't see them moving behind the arrows and it would look wierd if you could see the buttons that should be able to be seen. i've been trying to accomplish this but theres so much to get my head around i can't seem to go any further then i have now. also i'm trying to make it so i can have a click event for each button, and also i'm trying to find a way i can use this method to dynamically place the buttons down like i am but have different symbols for each button.
View 9 Replies
Sep 26, 2004
I want to make a site for my personal gallery and i'm asking you if there is another method to make my gallery, other that the one when the user click Back and Next to navigate through thhe images in the order that i chose. I want to create some buttons dynamically (so i will be able to add images to the gallery without replacing the SWF) and assign each of these buttons an on(release) or on(press) event handler that will show the image for that button
View 4 Replies
Jun 22, 2005
How do you dynamically remove buttons
View 4 Replies
Jun 29, 2007
I'm using Flash CS3, Actionscript 2.0 and I'm trying to create buttons dynamically.I tried to follow the code in the link below. The code is correct for the most part but the only problem I have is that only the last button appears. For example, if I try to create 10 buttons, only the 10th button is created.
View 6 Replies
Oct 30, 2007
I'm creating buttons dynamically, but I want to add code also. something like (psuedo)[thumb + i].on Release = "_parent.thumb" + i + "Pressed()" can that work? I think I need targetMc?
View 3 Replies
Aug 15, 2009
So I have this loop generating buttons based upon how many entries there are in my XML:
Code:
for (j=0; j < base.image.length(); j++) {
trace(j);
var newButton:imgButton = new imgButton();
[Code]....
Now I'm just wondering what the best way of assigning control to the buttons is (i.e. making them do something,). I'm wanting each created button to load a different image (defined in the xml) if that's of any use.
Do I need to add event listeners dynamically or something?
View 1 Replies
Sep 26, 2004
I want to make a site for my personal gallery and i'm asking you if there is another method to make my gallery, other that the one when the user click Back and Next to navigate through thhe images in the order that i chose. I want to create some buttons dynamically (so i will be able to add images to the gallery without replacing the SWF) and assign each of these buttons an on(release) or on(press) event handler
View 4 Replies
Oct 16, 2002
here is my contribution with this script you can create buttons dynamically and remove them (howmany) is the variable of the number of the buttons to create.
Code:
function makebuttons(){
// if we have buttons created at first time we remove them to recreate others ones
if(_global.createdClips.length>0){
[Code].....
View 2 Replies
Mar 8, 2004
There is a button in my library say mybutton_btn.I want to dynamically create an instance of it add it on stage something like insName=new myButton_btn();. How can this be achived?
View 7 Replies
Sep 16, 2011
I have 4 coordinates from which i created a rectangle(using lines). I also created buttons dynamically. It works great for straight line. But when the coordinates generate diagonal lines im having a problem in making it go below the lines or fitting it inside the figure.See my pic for better understanding. I have also figured out how to rotate the button. Here is my screenshot:Here is my code: To generate the lines:
Code:
var myLine:Shape = new Shape;
myLine.graphics.lineStyle(1, 0xFF0000, 1);
[code].....
View 1 Replies
Sep 4, 2008
I have a cfc that returns categories from the database. Is there a way to dynamically create buttons for all the categories?
View 1 Replies
Aug 6, 2011
I am dynamically creating panels based on information i get from an XML file but i'm having a problem with adding buttons to these panels. These buttoms are also created based on information taken from the XML file. The problem seems to be in the way i give the panels an Id name.[code]...
View 1 Replies
Aug 14, 2009
Here is my code:
ActionScript Code:
var sp:Sprite = new Sprite();
addChild(sp);
[Code]....
How to get through to my MovieClips?
View 6 Replies
Aug 24, 2009
In my main application I consume a web-service which gives me an array of vendors.There is a add button in the main application, which when clicked a pop-up is opened.I want to display one radio button for each vendor in this pop-up window.This is all I have done so far: 1. In the pop-up I created a radiobutton group (id = vendorGroup).2. vendorGroup has one radio button called Others (this is the default).
In the main app I call pop-up using:
private var addItemDB:addItemForm;
addItemDB = PopUpManager.createPopUp(this,addItemForm,true) as addItemForm;
[code]....
View 0 Replies
Aug 3, 2010
figure out how I can create Button from Library dynamically ?
View 4 Replies
Sep 16, 2011
I have 4 coordinates from which i created a rectangle(using lines). I also created buttons dynamically. It works great for straight line. But when the coordinates generate diagonal lines im having a problem in making it go below the lines or fitting it inside the figure. See my pic for better understanding. I have also figured out how to rotate the button.[code]...
View 1 Replies
Jan 22, 2010
i'm developing a website for my client. Here is the test version [URL] will look like this:[URL]There will be a menu created dynamically from a XML file, after clicking a menu button a MovieClip with a photo and category description will show up.After clicking the button "View more" the MovieClip with description will be removed and MovieClips with category products will show up through a for-loop on XML products nodes from this category.
The XML will look like this:
Code: Select all<category name="torty" url="torty.jpg" description="Category description">
<item name="Tiramisu" make="Balconi" url="tiramisu.jpg"><![CDATA[Product description...]]></item>
<item name="Cake" make="Balconi" url="cake.jpg"><![CDATA[Product description...]]></item>
[code]....
I can create the navigation menu, and maybe i will manage to create first MovieClip with the category photo and description but i don't have how to create those next MovieClips with products desciption after clicking the button "View more".
View 2 Replies
Jul 22, 2005
I have some basic knowledge in PHP and am learning XML, and basically have decided to prepare my site for the future by switching to strict XHTML / php (plus it needs to be updated anyway). It is a hybrid site with HTML and Flash elements, and each HTML (soon to be .php) page has a single .swf as the nav bar. Is there a way to externally assign hyperlinks to the nav buttons within this .swf? I've done basic external assigns (with .txt files into dynamic text boxes), but this seems a bit trickier. Basically, I want to be able to update the .swf without opening flash, changing the links, and then publishing a new .swf.
View 6 Replies
Feb 27, 2006
I am using the tutorial about dynamically loading images, that then fade when a button is pressed and change to the next image, however I want to load the images and have them fade in and out without pressing anything i.e. an mc that rotates the images, fading them in and out.
The script I have been using is this:
[Code].....
View 6 Replies