ActionScript 3.0 :: Removing EventListener From Imported Class
Jan 30, 2011
I have an on enter frame listener defined in a function:
Code:
function sideClicked(e:MouseEvent):void {
removeEventListener(Event.ENTER_FRAME, loop);
var targetName=e.target.name;
var a:Array=[];[Code] .....
The looptoposition() function simple calls a function from a custom class repetitively to move an object until it reaches its position. This is the function it calls from the included custom class:
Code:
public function rotateToPos(a:Number,b:Number,c:Number):void {
if(!cubeReady){return;}
if(cube.rotationY<b){
cube.rotationY+=3;
[Code] .....
This gets the desired result visually - the cube rotates until the chosen point and then stops - however the listener continues. I have two problems:
1) I would like to remove the listener but can't seem to do so from the imported class - I'm having trouble referencing my functions in the root flash file.
2) I also need to declare that the function has completed - but the equalities mean that b is either greater or less than but never equal to? Whats a better way of getting the cube to rotate to a set position on each frame? The reason for the equalities are the cube can turn two different directions. So rotation could be negative.
View 7 Replies
Similar Posts:
Dec 9, 2009
i have a problem with trying to remove animated clouds i have created when i enter a new 'scene' or frame.Here is an example of what im trying to say:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
[code]....
Basically i want to get rid of those clouds when i enter a new scene!
View 4 Replies
Jan 18, 2010
in my main I have a system that allowed certain classes to be loaded and unloaded. When I load Game.as, it contains a trace statement when you press the left arrow key. When I remove the game instance from the stage, and set it to null, I can still press left arrow key, and the trace will come up. If I then make a new instance of game, it traces twice with only 1 click. When I close/load another time it traces three times.
I very specifically set:
Code:
mainContent.removeChild(game);
game = null;
Even trace statements confirmed that the game was being nullified, and the trace still continued.
View 10 Replies
Nov 20, 2010
I got this function with an eventlistener like this:
Code:
public function onScroll(denne:MovieClip)
{
Main.instance.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelEvent);
[Code]....
View 7 Replies
Feb 2, 2011
I have an event listener on my main timeline and I have an mc with some AS which sits on the main timeline. I was just wondering if the following code is correct if I wanted to remove the event listener on the maintimeline from the AS written in the mc.
MovieClip(parent).removeEventListener(Event.REMOVE D_FROM_STAGE,
MovieClip(parent).removedFromStageHandler);
View 8 Replies
Jan 27, 2009
I've been sorting through the XML docs and i've bumped my head into a bit of a question. So, to preface, I have been able to load the XML successfully, but I want to be able to use my own XML loader class to load the XML and then be able to reference it from the document class. Also, I'd like to be able to send a file path to the loader class when I call it.
The document class:
ActionScript Code:
package rg.sites{
// flash classes
[code]....
View 8 Replies
Jul 15, 2011
I have the following parent class that I'm working with:
Code:
package {
import com.poptent.SubClassOne;
import com.poptent.SubClassTwo;
[Code].....
I am trying to set it up so that a parent method called by subClassOneInstance can affect subClassTwoInstance.
View 4 Replies
Aug 17, 2010
I'm just now learning the new object oriented way of scripting. It's been a wild ride, but I've finally learned how to keep script off my frames (very hard coming from as2).Here's my problem:
I have a TextField on the stage in my main .fla file named loadPercent.
I'm loading a jpg with preLoad.as and displaying the bytes loaded in loadPercent.
I can access my loadPercent TextField from my MainClass
but I can't access it from preLoad.as
the document class is MainClass.as
Code:
package
{
import flash.display.MovieClip;[code]....
I get three '#1120 access of undefined propery' errors for each time i try to access loadPercent.
a few basic questions: 1. all my files are in a folder in my documents, not in the flash directory, is this bad? I've seen people using com.whatever etc.
2. my main .fla file does not share the same name as my MainClass.as (it's not named MainClass.fla) Is that a problem?
I'm assuming these are inconsequential because my code seems to work up to a certain point.
View 7 Replies
Oct 23, 2009
My following document class is working fine. But, when I want to import it instead of using as a document class, it reports an error "1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.". My class code is here:
package{ import flash.display.Sprite; import flash.display.Shape; import flash.text.TextField; import flash.events.MouseEvent; public class Shapes extends Sprite { var square: Sprite = new Sprite(); var txt: TextField = new TextField(); public
[code].......
View 2 Replies
Aug 6, 2009
this is motion tween in timeline and then converted to as3 in cs4.how can i addeventlistener to it to find out motion is finished
import fl.motion.AnimatorFactory;
import fl.motion.MotionBase;
import fl.motion.MotionEvent;[code]......
View 4 Replies
Mar 12, 2009
If I dispatch a CustomEvent in the parent class, and I add an EventListener in the child class, is the event listened ?
View 2 Replies
Nov 8, 2009
I have question regarding removing instantiated objects. Let's say i have a main class in which i instantiate a custom video player (or whatever) class:
Code:
...
var videoPlayer = new VideoPlayer(...);
addChild(videoPlayer);
...
And inside VideoPlayer class i have of course dozens of objects (movie clips, sprites representing different parts of VideoPlayer) and dozens of event listeners attached to them. My question is, if i want to remove this VideoPlayer class from my main class is it enough to just do:
[Code]...
View 2 Replies
Jan 7, 2011
I have class ShowCase that inherite from my class ContentMC (that inherite from MovieClip). In the class ShowCase I have an EventListner that calls a function in the parent class ContentMC. But I get an error that says "Access of undefined property restoreMenuItem".
This is my eventlistner in ShowCase.as.
showcaseItem.addEventListener("CONTENTMCCLOSED", restoreMenuItem);
Here I get the error, it doesn't find the function restoreMenuItem.
The function restoreMenuItem is in ContenMC and looks like this.
public function restoreMenuItem(evt:Event):void
{
}
How do I call this function that's in the parent?
View 1 Replies
Feb 29, 2012
I am trying to add evenListeners to movieClips that are created by a method in one of my Classes. Creating an instance of my class from the main timeline and then adding that instance to the stage.:
//MY CLASS
var createSlide:AddItems = new AddItems();
var scrollClip:Sprite = new Sprite();
addChild(scrollClip);
//ADDIMAGES CREATES 4 MOVIECLIPS
createSlide.addImages(BG,image1,image2,image3,image4);
//ADD TO STAGE
scrollClip.addChild(createSlide);
So how do I add event listeners to the movieClips created by createSlide?
View 3 Replies
Jan 26, 2010
why my variable does not get updated when I try to modify it from an event listener function? for example in the code below _resultXmlList will be null if I try to get it from getXml I think there is no access to member variables from an event listener.
Here is the code:
Code:
package
{
import flash.events.Event;
import flash.net.URLLoader;
[Code].....
View 4 Replies
Apr 21, 2011
Im creating a game in Flash and I have a class that have some text fields that I need to populate in this case a highScore. I get this error.TypeError: Error #1009: Cannot access a property or method of a null object reference.Meaning that the object doesn´t exist , for some reason.
if (highscore.data.hard != null){
highscore_txt.text= String( highscore.data.hard);.
}
[code].....
View 4 Replies
Dec 26, 2011
Reading a book i stumbled on this example:
Here is the class:
package com.learningactionscript3.loading {
import flash.display.Loader;
import flash.display.LoaderInfo;
[Code]....
What I deduce from this example is that the swfLoader.contentLoaderInfo and _ldrInfo = this.contentLoaderInfo refer to the same object in the same memory location. So you may think: "well the last added event will overwrite the first one (the internally one added). But it doesn't. The two event listeners will respond sequentially. First the internal listener and then the external listener.
View 1 Replies
Dec 28, 2011
mainClass.as
package {
import mfClass.CarSelector;
import flash.display.MovieClip;
import flash.events.Event;
public class MainClass extends MovieClip {
[Code] .....
Now, when I run this in flash. I get this message.. in output.
TypeError: Error #1006: sel_Fun is not a function.
at MainClass/show_selector()
at MainClass()
View 1 Replies
Sep 14, 2011
I have imported a SWC into my actionscript project. It includes many different movieclips that I can access in my project. My question is this: How can I create a custom AS3 class that I can use to add functions and properties to my movieclips?
For example I have a movieclip with a linkage name of LevelButton. I tried creating a class that was the same name but they didn't seem to go together.
View 2 Replies
Nov 29, 2009
My project imports a custom class with a function called at runtime that creates a textField.
I want to be able to change the x and y coordinates of this textField [tf.x and tf.y in the class] from within the parent movie (not the class itself) but am having trouble.[code]...
View 5 Replies
Mar 29, 2007
I stumbled upon this while trying to customize the tree component following the example on the LiveDocs, see [URL].. To see the problem, do the following:
PART 1:
1) create an empty test.fla file
2) put a tree component on the stage
3) convert it to a symbol named TreeNavMenu, export for
Actionscript as TreeNavMenu
[Code]...
View 1 Replies
May 22, 2009
This is probably ueber basic, but I don't know how to do it. I am importing tweenlite on the root timeline like this: import gs.TweenLite;
I now want animate things in other MCs. I tried something like this, but it did not seem to work.parent.TweenLite.to(text1, 3, {_alpha:100, overwrite:0});
View 5 Replies
Jun 8, 2010
I'm trying to make methods available like so:
ActionScript Code:
MyClass.myFunc();
Instead of
ActionScript Code:
var myVar:MyClass = new MyClass();
myVar.myFunc();
I know that to do so I need to declare the functions/variables/constants as static:
ActionScript Code:
package MyPackage {
public class MyClass extends Object {
public static function myFunc():void {
} public function MyClass() {
[Code] .....
When I try to access the static function through the full reference (i.e trace(MyPackage.MyClass.myFunc);), it works, while trace(MyClass.myFunc); returns undefined. This contradicts what I've read in tutorials and posts on the Internet. They all use the short syntax, not the full path.
View 9 Replies
Aug 11, 2009
I tried to search for this but the search wasn't working. I have a loder class where i load in some xml. This is the function that's called after the xml is loaded[code]...
The xml traces out fine. My question is how do I define var xml so that I can access it from outside of the class in another class or from the timeline?
View 1 Replies
Aug 30, 2008
I have tried to add a button a .fla and code it with a packaged class (Main.as).is it possible to use a button from the GUI and code it with a external imported packaged class?
View 3 Replies
May 31, 2010
I am getting a 1009 error using tweenlite. I have placed the COM folder of tweenlite in the same directory as the FLA. On the main stage I have imported the tweenlite class using:
Code:
import com.greensock.*;
import com.greensock.easing.*;
On the main stage I have a MC called mainholdermc. When I click a button called mentions but on the main stage it basically tells mainholdermc to play. This works well. I have another movieclip called vosdes. At the same time that mainholdermc plays I want to use tweenlite to make the aplha of vosdes lower. If I put this actionscript on the main page it works fine:
Code:
mentionsbut.addEventListener(MouseEvent.CLICK, mainholder);
function mainholder(event:MouseEvent):void {
mainholdermc.gotoAndPlay(2);
TweenLite.to(vosdes, 0.4, {alpha:0.1});
}
The problem is that I want to move the tweenlite command to within the the vosdes movieclip. So within the vosdes movieclip I have this written in the actionscript:
Code:
import com.greensock.*;
import com.greensock.easing.*
TweenLite.to(this.vosdes, 0.4, {alpha:0.1});
I found that by using
Code:
this.MC_NAME
it is the equivalent of the _root in AS2.
However this is not working. When I compile the FLA no errors occur until I click on the mentionsbut and I get the following error:
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock::TweenLite/init()
at com.greensock::TweenLite/renderTime()
at com.greensock.core::SimpleTimeline/renderTime()
at com.greensock::TweenLite$/updateAll()
[Code] .....
View 2 Replies
May 21, 2009
Is there a way to remove a class linked to a movieclip? For instance, I've got a ball (e.g. ball0_mc) that's placed in a target. The way the ball is dragged and dropped into a target is by using a class called Ball. What I would like to do is remove the Ball class from ball0_mc once it's been placed in a target so that it can't be dragged or dropped anymore.
View 2 Replies
Oct 5, 2009
I got a Homepage set up and I have a Contact Form on Frame 55 of my main movie clip.The form is created on runtime using AS with the following code:
ActionScript Code:
import com.warmforestflash.ContactForm;
var contactForm:ContactForm = new ContactForm();
[code].....
View 1 Replies
Nov 2, 2011
I have a class, called fCont (I know, I should use capital letters for class names... oh well), and I need to remove all instances of it from my MovieClip.I'm making a Facebook browser for a uni assignment. When you go to the Friends page, it loads 15 friends, and that's fine. The code below is called on the "Next Page" button press.
Code:
function nextFriendsPage(e:Event){
var friendFace:Object = stage.getChildAt(0);
[code].....
View 5 Replies
Mar 3, 2010
I know using the UI loader when I needed to remove from the stage I used
MovieClip(loaderVideoGallery.content).flvPlayer.stop()
this time I need to remove a loader class event loader from the stage[URL]... The scenerio is I have 5 externally loaded .swfs that load on different frames on the timeline. When one is playing and another button event listener is clicked the previous video remains on stage. This happens when I go anywhere else in the timeline so I would think I need (removeChild)
Wouldn't this have to go in every button listener? If I went from a frame that loads an swf to the the frame that displays the homepage where text is in the place of where the swf was I would need to always have the remove Child event in all other button event listeners am I correct?
View 26 Replies