ActionScript 2.0 :: Functions Applied To Button Array Not Execute Properly
Nov 6, 2008
I have some functions that when applied directly to buttons work as planned, but when I create a function from them to apply to the array, they fail to execute properly. This function is meant to set all 56 buttons to alpha 0, and as unselected. What happens is the buttons flash onscreen at 100% before setting to alpha 0. They do behave as if unselected, but don't know if that's due to the code.
Code:
for (_root.i = 0;i<56;i++){
_root["btn"+_root.i].onEnterFrame = function() {
this._alpha = 0;
this.bSelected = false;
this.onEnterFrame = null;
}}
This function should fade the button up on rollover. But on rollover the button only increase by 10% then stops. Each subsequent rollover increases it another 10%.
Code:
for (_root.i = 0;i<56;i++){
_root["btn"+_root.i].onRollOver = function() {
this._alpha<100 ? this._alpha += 10 : this.onEnterFrame = "";
}}
This function should fade the button out on rollout. Since the rollover increases them only by 10% increments (above), the result is the buttons just bounce back and forth between alpha 20 and 30.
Code:
for (_root.i = 0;i<56;i++){
_root["btn"+_root.i].onRollOut = function() {
(this._alpha>20 && this.bSelected==false) ? this._alpha -= 10 : this.onEnterFrame = "";
}}
Last one: This function should set several behaviors on release. Right now none of them appear to work.
Code:
for (_root.i = 0;i<56;i++){
_root["btn"+_root.i].onRelease = function() {
this.bSelected = true;
this.enabled = false;
pastBtn.enabled = true;
pastBtn._alpha = 20;
pastBtn.bSelected = false;
pastBtn = this;
}}
View 4 Replies
Similar Posts:
Mar 21, 2011
This is my first real programming endeavor and this is the last thing holding my little project back from being a success.
My goal with this code is to add event listeners to an array of Movie Clips that will drag and drop them on the stage.
Here is the code:
var itemBank:Array = new Array(d1_anim.drawer1.test01.movieClip_1, d1_anim.drawer1.test01.movieClip_2);
for(var i:int = 0; i < itemBank.length; i++) {
[Code].....
View 1 Replies
Oct 17, 2010
I'm putting together a pretty basic website/portfolio. The buttons/code that go from page to page work great. The code I'm using to access larger images from thumbnails is basically the same, however it's not working.I have the site setup so that each larger image is it's own separate page, so basically the thumbnails act as buttons to access a specifically labeled page. Ex- Thumbnail/button "Character1_btn" goes to the page labeled as "Character1" to display the larger image. I hope this makes sense.Below is the code I'm using. As I said- all functions but the character1 function are working properly.. I really need the character 1 function to work.Quote:
stop ();
home_btn.addEventListener(MouseEvent.CLICK,playhom e);
function playhome(event:MouseEvent):void{
[code].....
View 2 Replies
Sep 11, 2009
I somehow am able to write bits of code but am still learning how to restructure code so that it is more efficient.I have 15 buttons. Each one, when rolled over, should change the color of 2 movieclips underneath it (and when rolled out, should change back). I have the below code so far but I don't think I have to re-write the functions each time. How do I "re-use" the function code (or, only write the function code once), but specify what movieclips the function should be applied to? These are just 2 of the buttons of the 15:
Code:
menu_mc.invis1.addEventListener(MouseEvent.MOUSE_OVER, changeColor);
menu_mc.invis1.addEventListener(MouseEvent.MOUSE_OUT, changeBack);
function changeColor(event:MouseEvent):void[code].................
View 9 Replies
Nov 11, 2010
I have these images that will load when I input a certain string of text but I don't know how to combine functions to make a generic one that will work for all of the images. These are just two and they're basically the same thing except I have to make each function (something)1 and then (something)2 for the next image.
[Code]...
View 2 Replies
Nov 5, 2006
I have three functions like this;
[Code]...
What I need is to make them run in a sequence, someone have a clue?
View 4 Replies
May 25, 2007
Why can't I execute an anonymous function directly, like:[code]The trace statement should output 'hello', but it just outputs 'undefined'. This is supposed to work in JavaScript (according to Mr Douglas Crockford). I thought Actionscript was compatible with JavaScript in this regard...
View 5 Replies
Jul 15, 2004
I currently have a class that has a method that creates new duplicates of a clip on the screen, changes some of their properties (such as color, and text display), and then arranges them in a straight column.Inside that method, I have some clipEvent Statements for each button.
Code:
currentButton.onRollOver = function() {
this._alpha = 70;
expandButton(this);[code]....
Now, the two functions that are called, expandButton() and shrinkButton(), will not execute. (they are other functions built into this class.)
View 4 Replies
May 9, 2010
My needs are to execute a javascript whitout calling any external function of the html file when a flash button is clicked. I need to obtain the effect that happen when the user put in his address bar the text javascript:"alert("Hello World!"); and press enter I need to do this whitout calling any external functions, whitout calling anything in the html file, all just with the swf. Of course the script that i must call is another than javascript:"alert("Hello World!"); but let's begin with this easy script and when working i can thikn to implement the complex one
i tried this
ActionScript Code:
on(release)
{
function runJS(script:String):Void {
[Code]...
but is not working, i get a syntax error, maybe cuse of the " in "Hello World!"
I want to ask if what i need to do is possible and, if yes, why my AS code is not working.
View 4 Replies
Oct 16, 2009
I have 3 functions in my main document class that I want to execute when the main timeline reaches a particular frame number. how do I do that? see the code and comments
[Code]...
View 2 Replies
Apr 23, 2010
I'm having some weirdness with a project that I'm doing in IE. Long story short, I've got a basic shell that loads in external SWFs based on user feedback. Once those SWFs get loaded in, they execute functions from the shell (_root) movie. It works great in Firefox, but immediately breaks (no way) in IE. The movie gets loaded in, but none of the functions run.
I suspect it has something to do with security, because, for a variety of reasons, I have to load the SWFs from their absolute location, rather than their relative location. When I test it locally (but loading the movies from their absolute, live location), everything still works, but I get that damn security warning that reads like this:
[Code]....
View 2 Replies
Jun 1, 2009
I am setting up a flash game with seven toggle on/off buttons that all do the same thing.I know how to assign them all to be able to do the same function in the main timeline. What I can't figure out is how to get them all to also do the same function within each of their respective movie clips.
Here's the code:
Code: Select allstop();
DontDrive.addEventListener(MouseEvent.MOUSE_OVER, RO_DontDrive);
DontDrive.addEventListener(MouseEvent.MOUSE_OUT, ROut_DontDrive);
[code]....
View 5 Replies
Apr 11, 2012
I have a list of buttons:
[Code]...
Container is another movieclip and inside of it are the last 2 buttons. How can I put it in array and have all the same listeners applied to each of them?
[Code]...
View 2 Replies
Feb 15, 2011
I have used a method to shuffle a part of a Array, but i noticed that it does not work very well.When i run this method I sometimes get empty array values.So if you would try the example below and test it out some times you would get a right result but sometimes a wrong result.For example when i run this i get in my trace output:
a,b,c,d,g,,e,f (here after the g it goes wrong)
a,b,c,f,g,d,e (here it goes right)
a,b,c,d,,g,f,e (here it goes wrong)[code]...
View 8 Replies
Apr 21, 2010
How do I execute callback functions dynamically by passing a function in as an argument to another function?
Look at this example:
Code:
package {
public class myClass extends MovieClip {
public function myClass(callback) {
[code]....
View 2 Replies
Apr 10, 2010
I have been able to change the variables to fit my parameters, which was really exciting and I am pretty sure I know what is going on.
However I noticed that while the navigation cycles through each segment, occasionally it breaks the order and jumps to a random segment. how to maintain a strict order when you use either button, i.e. right button cycles 1,2,3,4, left button 4,3,2,1...
Code: Select allimport fl.transitions.Tween;
import fl.transitions.easing.*;
mc.x = 10;[code]..............
View 1 Replies
Sep 13, 2005
I'm trying to get the jitter effect applied to a button.I currently have a mc called suggestcaption_mc with the following code applied to it.
Code:
onClipEvent (load) {
this._x = 103.9;
this._y = 30.2;
[code]....
This works fine. Now what I am trying to do is turn this into a button which does this effect on rollover?I tried sticking the mc in the hover keyframe of a button but this does nothing.
View 3 Replies
Oct 16, 2009
I have 3 functions in my main document class that I want to execute when the main timeline reaches a particular frame number. how do I do that?
see the code and comments
public function mainClass()
{
//stage declaraction
stage.align = StageAlign.TOP_LEFT;
[Code]....
View 5 Replies
Oct 20, 2009
I'm trying to use an array to store function names then recall the names later to execute the fuction.
Here is the code that I'm trying to use...
function BackClick(evt:MouseEvent):void{
var RedoPop:Object=MovieClip(parent).Undo.pop();
MovieClip(parent).Redo.push(RedoPop);
[Code].....
The variable "UndoPop" contains the name of a previousely defined function and I would like to let flash know to execute that function.
View 0 Replies
Sep 26, 2009
I have a function that executes when a button is pressed:
btnRandomAll.addEventListener(MouseEvent.CLICK, clickHandlerBtnRandomAll);
function clickHandlerBtnRandomAll(e:Event)
{
...but, I need it to also execute once, upon the file loading.
View 7 Replies
Jun 17, 2004
I have one function that puts text in a text field and makes a button goto a url onRelease.The code is like this:
Code:
item.onRelease = function() {
myButton.onRelease = function() {
getURL("http://google.com", "_blank");
}
talk = this.txt;
}
the only problem is that the button doesn't work onRelease. i think that it is because there are too many functions there, but at the same time,
View 5 Replies
Dec 21, 2011
I'm having issues with implementing a flex button componentI have applied a CSS style to button and set border-color to, say #555555.So far, it works as expected.Then, when my application is resized, the border of the button component becomes blurred and its width automatically changes from 1 pixel to 2 pixels, which doesn't look very well.hen I maximize the app again, after the border is blurred, the buttons' border becomes 1 pixel and looks nice.
View 1 Replies
Nov 7, 2009
I've created a new symbol - button type. Then created a single frame in a time-line, put my button there and put a simple code into frame[code]...
View 3 Replies
May 15, 2009
I'm creating my first website. I've managed to create a homepage. On the homepage is a enter site button, which once it is pressed starts thetimeline... I have an actions/labels layer which I am writing my code in. On frame number 'one' is my code below.
stop ();
enter_site_btn.addEventListener (MouseEvent.CLICK, buttonClicked)
function buttonClicked (event:MouseEvent): void
[code].....
View 5 Replies
Mar 21, 2010
I'm making a Century club timer, it is to execute on pressing the start button, and then run until finished (our paused, but thats not implemented yet). To keep the timer accurate I had to use the Date() function.The timer() function is used to update the displayed time. I tried using a while-loop for this, but then the whole thing would just freeze. :S So instead a use a infinite timer that ends when currentTime == targetTime.
[Code]...
View 4 Replies
May 21, 2009
I'm using the following array to storing multiple variables for similar movieclips: public var ballPlaced:Array = new Array(false, false, false); ....however, its not storing the boolean value properly in the array? I'm using the following code in the ZoneFill and ZoneEmpty to assign it a value of true or false, e.g;
[Code]....
View 3 Replies
Oct 20, 2009
how to clear the stage of everything I have loaded it with. This would be done upon click of one of the buttons I have on the stage. That button also needs to execute a different class I have programmed. You can even just tell me what to search under to find out this data.
Explanation: I have 2 different classes. Buttons class and Videos class. Buttons class loads the stage with 9 different buttons. Each button is supposed to lead to its own video. (I have the buttons ready with programming to load the video and all of the programming works).
The Video class loads the video onto the stage and has the controls for it to play, pause, stop etc (works pretty much..).
Now, I am not sure what code to put under each of the buttons to clear the stage and load the Video class.
View 2 Replies
Feb 25, 2010
I am trying to figure out how to execute code once a button_btn is hit on stage at runtime.
View 3 Replies
Feb 10, 2006
just need to execute a function - myFunction() when roll over a button i can do it coding the button like so:
[AS]on (rollOver) {
_root.myFunction(this);
}[/AS]
or code it in the root where i defined the function, like so:
[AS]myButton.onRollOver = function() {
myFunction(this);
}[/AS]
the thing is, i'm using this for a tween class animation, and when i code it directly in the button it works fine
can i write this AS diferent way?!
myButton.onRollOver = function() {
myFunction(this);
}
View 1 Replies
Dec 20, 2006
my drop-down menu. Sometimes, when I move mouse pointer quickly over buttons, more than one drop-down is opened. I put button whitin menu which on rollon tells flash to go to first frame of menu movie, i.e. initial state. The problem is when I place my pointer over another button, before new frame has occured, it' won't execute rollon button, but initiates another drop-down. this is my site: [URL]
View 5 Replies