ActionScript 3.0 :: Listener Functions Applying To All MovieClips Using Class

Jan 14, 2009

I am currently having a mc in my library use a class. The mc is duplicated and put on the stage. Inside the class the mc gets a rollover state. Problem is that, although the rollover listener and function 'works', any action that is given is applied to all objects linked to that class.

Code:
Select allpublic class cities extends MovieClip {
private var theStage:*;
public function cities(cityid:int, cityname:String, mymc, ref:*) {
theStage=ref;
this.alpha=.85;
this.buttonMode=true;
[Code] .....

So pretty much on rollover on one of the mc's makes them all alpha = 1 and rollout makes them all alpha = .85 instead of the one being rolled over. It does make sense I guess because they are all calling that same function I think. I also tried referring to the specific mc (mymc) instead of the parent and this.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Applying The Same Listener And Function To Buttons

Mar 26, 2010

Well i have spent a long time getting the code i have so far from tutorials and the listener and function commands seem to work well for one button, but i need to know how to apply the existing code to the other buttons. This is the code i have:

[Code]....

View 13 Replies

ActionScript 2.0 :: Applying Functions To External SWFs?

Apr 13, 2007

I'm a graphic designer trying to muddle through enough AS to create a bilingual site.I start it off by setting a variable, "currentlang" upon clicking either the "english" or "french" button. Like so:

on (release) {
_global.currentlang = 1; //english
_parent.gotoAndStop(3); //action begins on the 3rd frame of main movie

[code]....

This works fine for the clips on the main movie, but what happens when I load in external SWF's. How could I make my function "toggleLanguage" talk to newly loaded clips? On the external clip I'm loading in, I have the following code on the timeline:

if (_global.currentlang == 1) {
this.header.gotoAndPlay(1);
} else if (_global.currentlang == 0) {
this.header.gotoAndPlay(2);
}

This works fine when the new movie loads in, meaning that if my "_global.currentlang" on the container movie is set to French, the loaded SWF will display "Bienvenue" rather than "welcome", and vice versa. The problem arises when I try to toggle the language. It only toggles the language of the clips on the main timeline and not the newly loaded ones.

View 2 Replies

ActionScript 2.0 :: Applying Wave Pattern To Multiple MovieClips

Apr 4, 2011

I made an mc which on being hovered makes a wave. The problem is that I can't think how to apply the code on about 15 mc's. I used the main timeline for coding purpose. Now I want to apply the same waving pattern to the other 14 mc's. I tried the for loop but couldn't get it to work because of the variables involved.

Here's my code-
k = 100;
t = 0;
ascend = true;
waver = false;
waving = false;
[Code] .....

View 2 Replies

ActionScript 3.0 :: Applying A Class To An Instance?

Nov 5, 2009

Is there a way in AS3 to apply a class to an instance on the stage?  Or is the only way to do it through the linkage menu in the library?  The reason I ask is, I have a button class that I'd like to apply to only the button instances on the stage that meet certain criteria

View 1 Replies

ActionScript 2.0 :: Applying Class To An Instance On The Fly?

Sep 21, 2009

Applying class to an instance on the fly?

View 2 Replies

Flash - Listener Functions Not Acting As Closures?

Jun 8, 2011

Reference objects on stage/frame from document class. AddFrameScript seems to do what I need it to, except for one thing. In the function I'm passing to be added as a frame script, I want to dynamically create some event listeners for buttons, but variables I want closed over the listener functions aren't behaving as expected -- they all end up having the last assigned value of the variable rather than the value it had when the function was defined, as if different scope rules are in effect than normal:

addFrameScript(node_frame - 1,
function() {
stop();
question_txt.text = node_question;
answers_xml = node_xml.answer;
[Code] .....

But then afterward, if I click any of the three buttons, they all trace:
3A
Do frame scripts observe different (dynamic rather than lexical?) scoping or something?

View 1 Replies

ActionScript 3.0 :: Can't Set Vars For Functions Of Event Listener

Feb 9, 2010

why can't we set vars for functions of a Event Listener. To be more specific, this is my code:

Code:
package
{
import flash.display.MovieClip;

[Code].....

View 2 Replies

ActionScript 3.0 :: Calling Functions Attached To A Listener?

Mar 24, 2009

Basically what I want to do is call a function attached to an event listener, without the event actually happening - for example:I have a function that is attached to Event.RESIZE.I would like to call that function from time to time, but this function of course requires an Event argument, so attempting to just call the function throws an error that it expects 1 argument and got none.

View 2 Replies

ActionScript 3.0 :: Applying Two Class Files From A Package

Oct 28, 2008

I have a photo gallery, with a thumbnail panel (a photo viewer page) that I made, coding the AS3 from the key frame. It just so happens that I saw some class files online that have some good stuff in the tutorial.I've never really worked with .as files and I am intimidated by them.Would it be easier to modify my photo gallery, with a thumbnail panel, from key frame to .as AS3 code or to go from .as to key frame code? I personally feel more comfortable with key frame AS3, but I am not scared to dabble.How can I practice adding a couple of class files to my key frame AS3 code- I'm using regular variables, but the interesting idea I saw uses private variables and public functions, and it imports some stuff?

View 1 Replies

ActionScript 3.0 :: Call Two Functions From One Button Event Listener?

Dec 27, 2008

isit possible to call two functions from one button event listener?

or is it even possible to write two seperate listeners for one button that listen for the same thing an example is shown in the code;

also, i have string variable, that i want to use to call a certain funtion depending on the variable, for example the vairables name is phase_no can i do next_btn.addEventListener(MouseEvent.CLICK,nextPhase,beginSubmit+phas e_no)??

View 4 Replies

ActionScript 2.0 :: Adding Listener To MC With Picture Management Functions?

Oct 5, 2010

I have what I think is a scoping issue with a listener. I have a movie clip which contains several picture management functions. I want to add a listener to it so that the next image loads before it is processed. Where do I put the listener - In the MC or in the root? At the moment, I have it in the MC but it does not run the function. I created a test function in the root which runs the listener no problem.

View 2 Replies

ActionScript 3.0 :: Flash Namespaces For Event Listener Functions?

Jun 26, 2011

Code:
trace("Hello!");

I'm up late coding and I've come to a halt here's why:

I'm looking (desperately) for something that will explain why my "public class marquePage" is not working properly. I don't have access to the actual file right now - on a friend's computer - but i'll try and make this clear, here it goes :

Code:
// example : (having declared the namespaces at package level and embedded the pictures in separate classes "photosMP", etc)
public var ceNom:Namespace;
public var cetteListe:Array = [photos, dessins, livres, maous];

[Code].....

Somehow, the event listener doesn't want to know about namespaces... in fact, everything comes up ok except that when you click on any of the bookmarks (cetMP), nothing happens at all

View 5 Replies

ActionScript 1/2 :: Increase The Radius Of The Circle By Applying Tween Class?

Aug 18, 2009

I am created a circle using the following script,

[CODE]...

Now what i want to know is that can I increase the radius of the circle by applying tween class?

View 5 Replies

ActionScript 2.0 :: Eating A Global Listener On The Class And Receive Dispatched Event For Any Instance Of The Class?

May 11, 2006

I've done a class to be able to listen to the event for a CLASS not on an instance.

Code:
class net.webbymx.events.XClassEventListener {[code]....

why did I do this.It cames with my rugby game.I have player in two teams. When a player throw the ball I want the other teammate to act like "wait for ball" and the opponent like "seek for ball". Plus I'm lazy (and I don't want to register the listener for each instance of the player I'm creating). So this class is made to be able to handle as many instance of a class I want without adding a listener on each of them. I'm just creating a global listener on the class and then I will be able to receive dispatched event for any instance of this class .so in my team I can do

Code:
XClassListener.initialize(this);
this.addEventListener("throw", "net.webbymx.game.Player", "wait");

and in my opponent team I can do

Code:
XClassListener.initialize(this);
this.addEventListener("throw", "net.webbymx.game.Player", "seek");

View 4 Replies

Flash - Listener In Main Document Class For Custom Dispatch Event From Another Class Does Not Respond Or Call Function?

Apr 1, 2011

I have a document class called Main.as In the class constructor I have the following listener:

enter code here
var listeningFORModeChangeToStudent:Sprite = new Sprite;
listeningFORModeChangeToStudent.addEventListener(TellAllModeChangeToStudent.STUDENT,exp);
addChild(listeningFORModeChangeToStudent);

[code]....

In a third class I make a call to the despatcher in the previous class:

enter code here
var ThisTellAllModeChangeToStudent:TellAllModeChangeToStudent = new TellAllModeChangeToStudent;
ThisTellAllModeChangeToStudent.tellAllModeChangeToStudent();

I have trace statements in eveything and from this I know the despatcher in TellAllModeChangeToStudent is being called.The problem is that the listener in the main.as is not calling the function exp.I cant see why and I dont know how to check if the listener is actually seeing the dispatch event?

View 1 Replies

ActionScript 3.0 :: Add Event Listener To Multiple Movieclips

Mar 19, 2009

How can i add an event listener to multiple movieclips using a for loop in AS3 so that when i click on a movieclip, flash traces the name of the clip i clicked. This would be it's equivalent in AS2:

View 3 Replies

Actionscript 3 :: Big Performance Difference Between Using Class With Static Functions Vs Instantiated Class?

Mar 22, 2012

I'm wondering if anyone has experience with if there is a big difference in performance in ActionScript 3 between keeping a class with only public static functions, and utilizing those functions often (as in a frame event at 30fps), and in turning the class into a "normal" class of which I instead make an instance and call the functions via the instance instead.

View 1 Replies

ActionScript 3.0 :: Accessing A Class's Static Functions From A Variable Of Type Class?

Feb 19, 2010

I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it

Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function

[code].....

View 6 Replies

ActionScript 3.0 :: Call Document Class Functions From Outside Class?

Sep 25, 2011

Main is my doccument class . how can i call Main.Caller
 
package { import flash.display.Sprite; import flash.events.Event;
public class Main extends Sprite {
public function Main():void   {   if (stage) init();   else

[Code]....

View 2 Replies

Binding Functions To MovieClips (AddChild Name)

Jan 8, 2011

I'm trying to make a td game for fun and I need to make function to build towers and if I want to build the second tower it changes the first one... But I thought if i could change the name of the first tower's name when it builds to other var and it should be fine, but the problem is that those 2 towers will shoot together or something, so is there a way to bind functions to movieclips that are created with actionscript (addChild(Name))?

View 1 Replies

ActionScript 3.0 :: Use Modular Functions With Movieclips?

Mar 30, 2011

I was looking a tutorial that shows how to make modular functions, the user only used numbers, i was wandering if there is a way to use this with movieclips or childs.[code]...

View 3 Replies

ActionScript 2.0 :: Calling Functions In MovieClips?

Jun 16, 2007

I have this REALLY wierd problem. I have a MovieClip that is attached onto the stage. In this MovieClip I have the init() function. When I try and call this function, after the MovieClip has been attached on stage it doesn't work! I can't belive it!

MovieClip Frame 1
function init(){
trace("bleh");

[code].....

View 2 Replies

ActionScript 3.0 :: Resize Listener Where Change Movieclips Dimensions And Positions

Dec 11, 2010

I've got a resize listener where I change my movieclips' dimensions and positions.[code]But how I set the minimum allowed resize of the stage?I don't want the stage to be smaller than 1024x600 for example.

View 3 Replies

ActionScript 2.0 :: Invoking Functions In Loaded Movieclips?

Jan 26, 2009

I've not touched AS2 since AS3 appeared, but circumstances brought me back to using AS2,Is there way to invoke the functions/methods in a loaded movieclip? I know you can do that in AS3 by invoking the Loader object's content's function, but I haven't been able to do that successfully in AS2. I'm currently using the AS2 MovieClipLoader object, like so (snippet):[code]as set up, I intended the target movieclip's function 'invokeInternal Function' to run, but it doesn't seem to be doing it although the SWF itself loads successfully.

View 2 Replies

ActionScript 3.0 :: Can't Access MovieClips And Functions In Loaded SWF

Sep 28, 2011

I'm trying to simply access anything inside this loaded SWF and all I get is 'null'.
 
I have code in the parent SWF that needs to tell the child SWF movieclip what to do but nothing works. This was a piee of cake in AS2 and I can't seem to get anything to crossover in AS3.
 
Here's my code: 
 
import com.greensock.TweenMax;
import flash.display.MovieClip;
var myLoader:Loader = new Loader();

[Code]......
 
panel2 traces null and all the clips loaded within pull up undefined property errors.

View 1 Replies

Assign Functions To Dynamic Movieclips In A Loop?

Dec 8, 2009

I have done this same thing in ActionScript 3, but am not familiar with ActionScript 2, which I am forced to use for this project. I am loading products into a SWF via XML and attempting to add a click event to each dynamically-created movieclip. Simply tracing the text from a node in XML will do for now. I'd like to assign a property called "desc" or "description" to each movieclip and have it trace that property's value when clicked. Here is the relevant portion of my code as it stands[code]...

View 1 Replies

ActionScript 2.0 :: Creating MovieClips Through Functions With Arguments?

Sep 17, 2009

I have the following code, which should display some square clickable clips over a map. This is done by calling a function (shown below) with arguments. However, when I call this function, only the last box is shown... The clips are drawn on the same level (9000) but that should not be a problem as they wont overlay...functions calls....

ActionScript Code:
clipsideD=150;
city="Rome"
cityText=romeText

[code]....

View 1 Replies

ActionScript 2.0 :: Functions In Duplicate Movieclips - Position Is Not Right

Apr 9, 2008

I will have 5 type of buttons. Each type I will duplicate (+1) at some condition. Each button is sharing a same functions, just some difference in value and positions. Button type's name:bug1, bug5, bug10, bug20, bug50

[Code]...

View 4 Replies

ActionScript 2.0 :: Animate Multiple Movieclips Without Using Lot Of Functions And SetInterval?

Nov 3, 2005

Is there an easy way to animate multiple movieclips without using a lot of functions and setInterval??I want an animation to start and before it's finished another one starts, right now I'm using a ton of functions and setInterval but I'm sure there's a cleaner more efficient way to achieve this.

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved