ActionScript 2.0 :: Function Allowing Only One Instance?
Jan 11, 2005
I'm using two functions, one for an onRollOver event and the other onRollOut.
The problem is that when the second mc calls either of the functions, the inital function running ends its cycle, leaving that animation unfinished.
View 3 Replies
Similar Posts:
Jan 23, 2011
I've set up a game, where the user has to guess what a picture is by moving a small hole/ portal around.I've used the mask feature to do this and managed to attach the portal to the mouse.However,I need to stop the mouse dragging the portal when it moves outside of the picture/instance.This is so the user can then press buttons to go back to main menu etc. Here's the code I've used to attach the portal
onClipEvent (load) {
startDrag("", true);
Mouse.hide();
}
View 1 Replies
Oct 4, 2009
I have a scrollplane instance onstage that I need to skin, but flash is not allowing me to double click the instance to edit its timeline. Does anyone know why this may be?
View 1 Replies
Jan 26, 2009
I have a general / somewhat newbie question. Is it better practice to call a function from another class like so:
[Code]...
Does one way free up more memory or enhance performance?
View 5 Replies
Mar 3, 2011
I have a situation where, upon loading my swf, I add an event listener to the stage to listen for keyboard commands. One of them is to listen for the spacebar, and if it is pressed, it should play a movie. The problem is, that movie is not loaded until later on, depending other user interactions, therefore, until it is loaded, the reference to it would be undefined.
But if I wait and add the listener for key commands only when the movie is loaded, then I can't utilize the listener for other keyboard commands, like RIGHT or LEFT, which are the buttons which get you to the movie in the first place. Is there a way to add a conditional or something to prevent that code from being executed if the video is not defined yet? Here's my code:
[code]...
View 2 Replies
Mar 20, 2009
Does creating a new instance of an Object that uses an identical name to an older instance, delete the previous instance? Or should the original instance be deleted first? The code uses a ridiculous amount of XML vars. Isn't it less memory intensive to parse the XML and save the properties to an Object, and then delete the XML Object, rather than keep the XML Object around and reference it's child nodes directly? Is it better form to break up a huge XML file (>600lines/3200vars) into smaller chunks?
View 1 Replies
May 17, 2009
I have 4 instances of the same button on a single layer in a timeline of the mc 'coverflow_mc' named 'ThatsMe_btn_a' to 'ThatsMe_btn_d' ie same button, same position.. it just changes instance name on 4 keyframes. Why does it call the function fine for button a but not for b,c, or d? There is a stop on each of these frames and I can see from the swf that it is stopping at the correct frames.
function thatsMe() {
right = new Sound();
right.attachSound("right");
[Code]....
View 3 Replies
Mar 2, 2010
So this is my code:
ActionScript Code:
onClipEvent(enterFrame) {
if (!this.already) {
setTimeout(win, 2000);
[Code]....
The problem is that I can't do trace(this); How to get it work? I have tried to do this.setTimeout etc..
View 9 Replies
Jun 4, 2003
I've got this function, in which I declare a variable. according to that variable I want to adress an instancename...
[Code]...
View 5 Replies
Sep 29, 2010
Well I want to set up a function that will calculate the x position of where my MovieClip's instance name will go. Here is the code i currently have.
function xBtnPosition(btnName: String, btnXpercentage: Number):String
{
var xFinalPosition: String = -(((btnName.width * btnXpercentage) / btnName.scaleY));
[code].....
View 3 Replies
Nov 17, 2010
Got 9 MCs which I want a rollover effect for. I made 1, copied it and it's instance name 9 times. And made this script:
Code:
function menu_btn_over() {
myTween = new mx.transitions.Tween(_root.main.menu.btn.btn_parent, "_x", mx.transitions.easing.Strong.easeOut, _root.main.menu.btn.btn_parent._x, 0, inspeed);
[code]...
But it only works for one of the buttons. The one I made the copies from.I figured you could do this since it's the same MC? I could be wrong though. If that is the case, is there some way I can make the same action for every button without having to make a bunch of calls for each one? for example:
"_root.main.menu.btn1 <and> btn2 <and> btn3 <and> etc.onRollOut = function() {"
View 1 Replies
Aug 7, 2009
I have created a function that creates a pop-up text box: I have named instanceName as a String but sadly it doesn't work. The only way I can get it to work is to name the instance within the function. Is there any way of creating a variable for the instance name? [code]...
View 3 Replies
Aug 1, 2004
I have the following code from a tutorial on Kirupa:
Code:
_root.currMovie = "home";
container.loadMovie(_root.currMovie+".swf");
_root.home.gotoAndStop(2)
[Code]....
As you can see are the button names: home, about, service and contact. This are also the names of the external swf's. But now I have chanced my button names in: btn_home, btn_about, etc. Now is it a little stange to name my external swf's btn_home etc, so how can I substract the prefix btn_ from the buttons so that the externa swf's can keep their normal names? I know it has something to do with substr but I don't know how and where to implement it.
View 3 Replies
Apr 24, 2006
the idea is that the site keeps tracks of whatever page is current and passes this variable to the alpha function which will target that movie instance to fade when moving to another page - then that page's name will be assigned to current.this is the code that i have now..
#include "alpha.as"
evolution.onRelease = function() {
this[current].gotoAndPlay(2);
[code].....
View 5 Replies
Apr 24, 2006
k the idea is that this movie keeps tracks of whatever page it's on using the variable current. when the button evolution is clicked it should jump to frame 2 of the movie whose instance name is contained in the variable current and also pass this variable to a function called alpha which fade that movie's instance when moving to another page - then that page's name will be assigned to current.
this is the code that i have now..
#include "alpha.as"
evolution.onRelease = function() {
this[current].gotoAndPlay(2);
this[current].alpha(5, 0);
};
all these buttons and movie instances are contained in the same movie clip and the variable current is declared in it too.
View 1 Replies
Aug 12, 2008
Got 9 MCs which I want a rollover effect for. I made 1, copied it and it's instance name 9 times. And made this script:
[Code]...
But it only works for one of the buttons. The one I made the copies from. I figured you could do this since it's the same MC? I could be wrong though. If that is the case, is there some way I can make the same action for every button without having to make a bunch of calls for each one? for example:
[Code]...
View 7 Replies
Apr 27, 2009
When I try to use this code to call a function for every instance of a certain class I get an error saying that there is a "call to a possibly undefined method removeInstance through a reference with static type flash.displayObject".
Code:
for (var i:int=0; i<=numInstances; i++) {
if (numInstances!=0&&getChildByName("b"+i)!=null) {
getChildByName("b"+i).removeInstance();
}
}
View 2 Replies
Aug 1, 2004
I have the following code from a tutorial on Kirupa:
Code:
_root.currMovie = "home";
container.loadMovie(_root.currMovie+".swf");
[code]....
View 3 Replies
Mar 26, 2010
I am trying to add a simple navigation to an instance of a button on my stage through AS3. my code is below... I have used the same code in AS2, but i must be leaving something out in AS3..
btn_arrow_TL.onRelease = function() { gotoAndPlay("flyout_default"); }
Compiler Errors: 1120: Access of undefined property click.
View 6 Replies
May 29, 2010
I have a set of thumbnails in a "gallery" class calling a "feature" class that's presents/displays the associated content.
I'm stuck with a runtime problem where I have a thumbnail button calling a "feature" class. This "feature" class contains a function with an instance of a button listener. So everytime I call this function it creates a duplicate instance of this listener. - BAD
I would like to move this addListener instance out of the function in the "feature" class so it doens't multiply instances every time it's called by the thumbnail.
However, when I take the listener instance and it's function included out of the function in the "feature" class being called it can't access other functions in the "feature" class.
Is there a simple way around this so I can have button listeners in a class but not added every time the containing class is being called? Should I have these buttons in a separate class that just extends from the "feature" class?
View 5 Replies
Feb 20, 2012
I'm trying to define this function so I can pass the CardButtons sprite to the Add Cards function. It "works" but there's one problem: the CardButtons sprite used in the function is determined by the value of i at the time of the function call (or in other words, the value of i when I click the sprite).
I want the sprite passed to be literally the value of CardButtons[i] at the point when the function was defined.
CardButtons[i].addEventListener(MouseEvent.CLICK, CardFunctions[i]= function(){ AddCards(CardButtons[i],PlayerHand[player-1][PlayerHand[player-1].len gth-1]);});
Is there a way I can do this, or is there a better way to do what I'm trying to do?
I guess for further example:
I want CardFunction[0] to store the AddCards function with the value of CardButtons[0] passed, it should NOT be dependent on the value of i.
View 3 Replies
Jun 19, 2011
I'm getting into actionscript3 and was wondering if there was a way to make an 'onclick' type function that returns an id or an instance name. For example in jQuery you can do the following, which is great for then passing the id into an array or whatever you choose.
$('.menuButton').click(function(){
var collectedID = $(this).attr('id');
Is there an equivalent to this in AS3? I'm assuming grabbing the instance name would be the goal? I haven't run across ids in Flash yet.
View 2 Replies
Aug 16, 2010
I'm so getting confused with this,So i'm making a card game, and i'm just on the beginning of it. I've already added the objects on the stage and stored them on an array.now i made a function that when it executes the .x and .y properties of these cards would change. this is what i did, but nothing seems to happen.the array MyCards contain movieclip objects not strings and also, the function executes when an instance in the movieclip is clicked
ActionScript Code:
distCards(MyCards);
function distCards(cards:Array):void {
for (var i:int=0;i<cards.length ;i++) {
[Code]...
View 1 Replies
Feb 8, 2009
How can I get the instance of the class to call the dispatchEvent for the postTrace function.
1180: Call to a possibly undefined method dispatchEvent.
Code:
package {
import flash.display.*;
import flash.events.*;
[Code].....
View 1 Replies
Mar 4, 2009
Basically looking for a way to get the instance created when I use this function I've made, it seems to me "libItem" will be a new instance and I would like to re-assign that back to the item passed into the function so I can access the instance later.
Here is the function I created to create library on the stage...
Code:
function objectPlacer( libItem, instance:Class ):void {
libItem = new instance( );
addChild( libItem );
}
So here is how I call the function
Code:
// Function( var name, library item class name, pos x, pos y )
objectPlacer( i_ranks, txt_Ranking );
My problem is, I try to access "i_ranks" later with the following code...
Code:
i_ranks.x = 100;
And I get the error:
TypeError: Error #1010: A term is undefined and has no properties.
"i_ranks" is defined as a class member.
Also, if you know - what should types should I be assigning the parameters instance and libItem in the function?
View 2 Replies
Feb 24, 2010
I made this function,that is supposed to create a bunch of slides based on a parameter. That parameter should be the instance name:
Code:
function createSlide(instName:Object){
trace(instName);
this.createEmptyMovieClip(instName, this.getNextHighestDepth());[code]....
In the script I call the function with
Code:
createSlide("mySlide");
After execution, this error message appears: Error: A 'with' action failed because the specified object did not exist.The trace statement returns the instance name -"mySlide"- When I replace instName with a stringtype name like "mySlide", it works fine.But I don't want that 'cause in that case I have to write a specific function for each slide.
View 2 Replies
Jul 14, 2004
I create a new MovieClip, call it Somehow, and link it to the name "MyClip", for example.[code]...
They must be MovieClips, because the functions not only response with hello, like in the example.
So I want to create the Clip copies and call the functions in one step. This example is also not working when i put it inside of a onLoad, or onEnterFrame and so on.
View 5 Replies
Sep 27, 2009
I would like that the user couldn't move the MC anymore on frame 2, is that possible?Because when I am in frame 2, I can still move the MC and it goes back to frame 1 again [code]...
View 4 Replies
Dec 12, 2006
In my main flash page I'm trying to have other swf files load into it. When I test the movie in flash, everything works as it should. But when I upload it to a server, it only allows one swf movie to load. Anyone know why this is? Does it have to do with security?
View 4 Replies
Jun 20, 2011
Did you notice that, at least inside Firefox 4, Flash cannot go above 50% CPU? Of course there are valid reasons for that, but it's not the topic.
About a week or so ago I stumbled upon a SWF that managed to use 75% of my CPU. (It was doing 3D stuff) I would like to know if you guys know if there is a way to reproduce this; maybe Adobe put some option somewhere in the API? Or maybe it's specific to what that SWF was doing.
That would be great for games or web applications on which users are entirely focused and can therefore afford to dedicate more resources.
Unfortunately I can't find the URL anymore, I think it was some Alternativa3D demo or something. Not sure.
View 4 Replies