ActionScript 3.0 :: How To Assign Code To Buttons
Sep 13, 2011the current code I have on the timeline now (where the buttons reside) is:
stop();
function playLifeboy(event:MouseEvent):void
{
[code]......
the current code I have on the timeline now (where the buttons reside) is:
stop();
function playLifeboy(event:MouseEvent):void
{
[code]......
I'm new to AS3 coming over for AS2 and trying to figure out how to code a simple load sequence. I've got two scenes, "Scene 1" and "Scene 2". I've got a MC that is a simple shape tween that loops in the "Scene 1". I'm trying to assign code to this MC that will check to see if frame 40 of Scene 2 is loaded. If it is, gotoAndplay Scene 2 frame 1. If frame 40 of Scene 2 is not loaded, continure to loop the MC unitil it is. Here is the code I've got for the MC in the "Scene 1"
onClipEvent(enterFrame) {
if (i > 40) {
gotoAndPlay("firstframe", "Scene 2");
}
}
"firstframe" is the frame label for the Frame 1 in Scene 1. This seems more difficult in AS3 than AS2.
But anyway, my problem is that, I have 52 Button instances on Scene 1 as bellow:
B1 , B2 , B3 , ... , B52
and I want to assign seperated actions for each of them.
The way I currently CAN do that is this:
B1.addEventListener(MouseEvent.MOUSE_DOWN, B1F);
B2.addEventListener(MouseEvent.MOUSE_DOWN, B2F);
B3.addEventListener(MouseEvent.MOUSE_DOWN, B3F);
[Code].....
But "test.addEventListener(..." does not work, and Flash searches for a function named "test" instead of working with the VALUE of "test".
could anyone help me modify the code for these checkbox components? right now, the SUBMIT button checks which ones of the checkboxes are checked and gets their label, then writes the appropriate labels in a dynamic text box.[code]For the program I am doing, I need to have a maximum of 6 checkmarks and each one of the checked label must go into its own variable. (see gray part of the swf) I would also like the labels to appear in the right order, right now it's inversed.
View 1 Repliesright now, the SUBMIT button checks which ones of the checkboxes are checked and gets their label, then writes the appropriate labels in a dynamic text box.
// HERE IS THE CODE FOR THE Checkbox Components-----------
// Array of the instance names of the checkboxes
myCheck = [one,two,three,four,five,six,seven,eight,nine]; // Function
[code].....
I am not an expert in Flash and my problem might looks silly.But anyway, my problem is that, I have 52 Button instances on Scene 1 as bellow:and I want to assign seperated actions for each of them.The way I currently CAN do that is this:
B1.addEventListener(MouseEvent.MOUSE_DOWN, B1F);B2.addEventListener(MouseEvent.MOUSE_DOWN, B2F);B3.addEventListener(MouseEvent.MOUSE_DOWN, B3F);...B52.addEventListener(MouseEvent.MOUSE_DOWN, B4F);
[code].....
One of the things that I love about AS 1/2 is with scrpt assist on, the ability to click a box and assign an action to a button (over, rollout, rollover, click, etc.). With action script 3, at least in CS4 that interaction isn't there and you have to write the code.I'm wondering if in CS5 there is that ability with AS3? Am I the only designer who misses this function.
View 1 RepliesI am new top actionscript that is why I am trying to learn AS3 instead of the AS2 etc.anyway I am trying to create a number pad in flash (like a calculator but wothout the add, subtract etc) so that when I press a number its displays the number in the flash movie. I nearly have it but it only displays one number at any one moment but i need to be able to add upto 5 digits in the display, so that later on in the project I can validate this field to make the input is correct.here is the code that I have made but remember this is my first AS3 flash program so go easy on me
stop();
display.maxChars = 5;
// start of the array
[code].....
how to assign movies to buttons. I don't know how to do this in MX. In five I used to use tell targets to assign actions. Is it the same in MX.
View 5 Replies//AS BEGINS
var productList:Array = Array("diabeoff", "cholestoff", "inulina", "colageno", "power", "castoff", "dieta", "miel", "extrapower");
[code].......
[code]...
i have a buttons name list1, list2, list3 .... and so on and movieclips playlist1 , playlist2 .. and so on basically what i want to do is assign same action in the buttons, the code above is what i did and it doesn't work
Is there an efficient way to assign the following switch statement to two different buttons (movie clips)?
[Code]...
i have a rookie question to ask and it's how to assign the same event listeners to multiple buttons in as3 instead of having to write out the same code over and over again like so...
ActionScript Code:
listing.home.addEventListener(MouseEvent.ROLL_OVER , butOver)
listing.home.addEventListener(MouseEvent.ROLL_OUT , butOut)
listing.home.addEventListener(MouseEvent.CLICK , released)
[Code]...
I've got 5 movie clip buttons. When a user rolls over a button, I want one movie clip to play. When a user clicks on that button, an alternate movie clip plays. I'm trying to use an array to assign certain movie clips to certain buttons and actions, but I'm not doing something quite right. I can get one button to work correctly, but then am having issues getting the other buttons to work.
Here is the code I have:
var currentPage:MovieClip;
var currentScreen:MovieClip;
var prevPage:MovieClip;
[Code].....
I am amateur in flex, and started my final year project in flex to learn it, I am stuck in place where I have to create rows of drop down lists when the user pressed add more, E.g.: like the ones in mail attachments. I think I have found a way to generate rows, I am not even sure whether it is a correct way, how I generate the rows:
<mx:states>
<mx:State name="newRow">
<mx:AddChild relativeTo="{cityDropdown}">
<s:DropDownList id="newbutton" creationComplete="hotelDropdown_creationCompleteHandler(event)" labelField="Name">
<s:AsyncListView list="{getAllHotelResult.lastResult}"/>
</s:DropDownList>
</mx:AddChild>
</mx:State>
</mx:states>
Now when I generate more rows the dropdownlist ids will conflict, so I want to know a way to generate ids, I think I cant even call a function in there.
How to dynamically create buttons and assign them names to use later on in the code.? For example:
ActionScript Code:
If(a==3) {
create three buttons:
[Code]...
And then assign some functions for these buttons - like:
ActionScript Code:
but1.addEventListener.....
I'm fairly new to AS3. What I'm trying to is create a multiframe SWF (main.swf) that loads several external SWFs (ext.swf) on each frame. I've got that to work. My problem is that I'm trying to assign actions to buttons/MovieClips in the external swfs that navigate to different frames in my main.swf. I want to avoid hard coding the buttons because there are about 30 external SWFs and they don't all have the same number of buttons within them. The approach I took was creating two arrays in each ext.swf, one to hold the button instances and the other to hold the frame destination labels.
Code:
var buttons:Array = [link1, link2, link3, link4, link9, link10, link20, link21];
var links:Array = ["c1", "c2", "c3", "c4", "c1", "d1", "d2", "e1"];
Then in the main.swf, I created a function that loads the ext.swf and runs a "for" loop that assigns EventListeners to the contents of the "buttons" array to go to the frame labels defined in the "links" array.
[Code] .......
The "for" loop in the "assignLink" processes and traces the "links" array just fine, but it always assigns the last array item to every button.
I am trying to assign buttons my on my 'gameScreen' to move my character. though I am receiving an error msg saying: Error #1010: A term is undefined and has no properties.at Mainas()
package{
import flash.display.MovieClip;
import flash.events.MouseEvent;[code]....
I have a 13 buttons to wich I added Event listeners using a for loop:
Code:
for (var i:Number = 1; i < 13; i++)
{
[code].....
I made a basic text editor that lets users insert predefined strings into the document with button clicks. What I need to do now is let the user define their own buttons and string values. For example I have a button that inserts "Hello" into the text. The user may want to create a button that adds "Goodbye".To accomplish this I figured I would create a .txt file called buttons.txt or something. i would readutfbytee, loop through it to create the buttons. problem is I know what I want to do but not sure where to start
View 2 RepliesI know this should be do-able, but i am stumped... I created a row of movie clip buttons + eventListeners (CLICK) with a for-loop. i now want to take an array that consists of a list of swfs (i.e., var myArray:Array=new Array(); myArray=["thing.swf","dog.swf",more.swf",etc}--and programmatically assign a loader + URL request to each of the created movie clip buttons that will load the swfs on the button click.
View 1 RepliesI got one movieclip with several buttons and another movieclip where i use: this.loadMovie("news1.swf"); What Id like to do is, if its possible, to do, on the main timeline, assign, to the buttons what news.swf to load into the other movieclip where i load it. So i can assign one button to load news1.swf and another load news2.swf.
View 5 RepliesI'm trying to learn shared objects by attempting a basic function. I would like to have an .sol file remeber what buttons are clicked on by a user and assign an alphavalue for the buttons that have been clicked. Here's what I have..
[Code]...
What I need to do is assign 5 separate dynamic text fields to 5 seperate buttons and at the same time to those same five buttons i would like to add 5 images that i would be able to change merely by swapping out the images in the file theyre in on the server.I would also like to get a nice transition between the images...ALSO i want to dynamically load the images for the buttons that will be used for switching from picture to picture(which im thinking i will be able to do after i know the how to do point the aforementioned things.)
Through tutorials I've found around the net I've been able to get most of the parts together... but i get lost because what they show you for AS2 they don't for AS3 and vice versa, at least that ive seen.so... I guess my question is... would i need to set up 5 seperate dynamic text fields on the stage and then set each one of them to one of the corresponding button. If so what AS code would i need to use to do so. And if not what would i need to do?
The other part of the question would be I know about the UILoader... would i be able to use it as my buttons and images, if so would i need 5 seperate ui loaders for both the Thumbnail buttons and the images or is there a way that would be better to do it? and once i do that would i do the transitions using frames and tweens like with AS2?
I have a pre built flash navigation menu. I am trying to add a getURL code to the buttons. The code looks like this:
function butnClick(event:MouseEvent):void {
if (event.target.num == 0) { // For the 1st button:
// Add your button click actions here[code]............
Im getting syntax errors and I know its wrong but thats the only way I know how to write it so far.
I am building a image presenter in Flash with as3 but i need a piece of code to make the two buttons work correctly. The code i have is as2 and i get 10 errors using it.[code]
View 3 RepliesSo I have 10 buttons, and I would like them to all do similar actions, but I was wondering if it's possible to optimize the code somehow.
When you rollover the button I would like it to alpha IN, and then when you rollout I'd like it to alpha OUT. Lastly, onPress I'd like to go to a different keyframe in the scene.[code]...
I would like the code or links to the code to help me make buttons and plain text to navigates to various pages in a flash site.
View 1 RepliesHow to declare the buttons in the following AS code What is the library that needs to be included
package
{
public class caml extends Sprite
[code].....
I am using an accordion code that uses XML for the buttons. Here's an example of one of the buttons:
[Code]....