AS 3.0 :: Flash - Reference Parent Class Function?
Mar 23, 2010
I am trying to run a function of the main class, but even with casting it does not work. I get this error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at rpflash.communication::RPXMLReader/updateplaylist()
at rpflash.communication::RPXMLReader/dataHandler()
[Code].....
View 2 Replies
Similar Posts:
Sep 19, 2011
So I am trying to access a variable that is defined within my parent code from a class which has been called from my parent code. I am using this:Code:TileCode(parent).game_quests.add_quest(0);to try to access the game_quests variable (which is defined within TileCode). However, for some reason it is not picking that up. It is working for other variables which I have called and ran in a similar fashion
View 7 Replies
Mar 21, 2008
I have a site class with different properties. The site class creates a Background class. I want the background class to use the Site class' stylesheet object. How can this be done?At first I thought about passing the site object to the Background class' constructor, but maybe there is a way to reference to the calling class?
View 8 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 27, 2012
I have an AS3 class on my Flex project[code]...
View 2 Replies
Jan 5, 2012
This is my code in Flash/AS3, in a frame's action:
import flash.events.Event;
stop();
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void{
[Code]....
This is because I believe it is referring the splashTimer1 function by "this".
How can I refer to parent frame there, so that I can remove its event listener.
View 2 Replies
Nov 25, 2010
Lets say I have a Main Document Class called Main. I also have a child class called childClass that call a function from the Main class and is also imported in the Main class. How should I call the function? I tried this , but when calling the function, it's getting me error.
Main class :
Code:
package {
import flash.display.Sprite;
import com.childClass;
[Code].....
View 6 Replies
Nov 17, 2011
I have a .fla file with some code in the actions panel.A bit of code calls a function in a class from the actions panel .The function in the class is run, but I want to be able to call a function in the main actions panel code from the function in that class .The class doesn't extend anything so (parent as MovieClip).function() does not work.
View 7 Replies
Jan 23, 2009
how I reference vars/instances from a parent class by using a static function and I wonder if there is a better way to do it.
I have a main document class Main.as with a public static function called mainFunction().
ActionScript Code:
public static function mainFunction( _mc:MovieClip, _nVar:Number ):void
{
// do something
[Code]......
This can be tricky if the static function has many variables from its own class.
View 4 Replies
Feb 21, 2009
I have 2 class. Main class and a subclass (being an image loader).When the subclass has finished loading I want it to access a timer function in the mainclass.Code: Select all1)mainclass |> subClass.loadMe();2) When subclass load finished.3)Subclass |> mainclass.startTimer();This i dont know how to do.
View 2 Replies
Aug 27, 2009
How can I make a call to a function in the parent class of the class I'm in.
example:
main class
Code:
package {
import flash.display.Sprite;
public class mainClass extends Sprite
{
[Code].....
I realise that there is some stuff that is missing in the "full" code here, but that's just because I'm to lazy to write it all...
How do I get the "someButton" in the "child_class" to call the "theImportantFunction" in the main class? I know that it is possible to make a "dispatchEvent" in the "mouseClick" function, and then add a eventlistener in the main class.. But is there another way to just call the function directly?
View 4 Replies
Jun 2, 2011
I have been using:
yourbutton.addEventListener(MouseEvent.CLICK,f);
function f(e:Event):void{
Loader(this.parent).load(new URLRequest("newswf.swf"));
}
which was suggested to me in a different post to target the parent loader class, however i now no longer can reference my preloader in the parent swf (extract from the parent swf):
[Code]...
View 5 Replies
Feb 10, 2010
Ok, I have a class like this:
public class Foo extends Sprite {
public function Foo(x:Number, y:Number):void {
this.x = x;
[Code]......
I'm getting this error from the compiler: "Error: Illegal assignment to function bar". How can I change the public function bar on the fly?
View 2 Replies
Feb 4, 2011
How would one get a reference of String global function (not class). According to language reference this function does exist (and I'm ready to believe it does), but, say and you have a:
Code:
function foo(bar:Function):void { ... }
How then would you pass that String to it?
View 9 Replies
Mar 16, 2010
I cannot use the following in my ActionScript due to conflicts with the host application:
_level0
_root
_parent references
On a pop-up box I have a close button with an absolute reference: closeBtn.onRelease = function{ unloadMovie("_level0.Page_1.holderBox");} Is there another way to make this work without using _level0 or _parent? I've read that it is possible to use a global variable on the main timeline and ref that, but cannot get that to work.
View 7 Replies
Jan 11, 2010
I've basically got an MC (menu_mc) that is on the first frame of the main timeline. I want menu_mc to call functions on the main timeline depending on its status. When the function is successfully called, I want to move menu_mc, however I get a null object reference despite the object menu_mc being visible on the stage.
here is the menu.as code
Code:
package {
import flash.display.MovieClip;
import com.greensock.*;
import com.greensock.easing.*;
[code]...
As you can see from the commented out lines, I've tried doing the same thing with eventDispatcher, but have been unable to listen to the event from the main timeline.It seems as if the function is being called before menu_mc is placed on the stage, despite the ADDED_TO_STAGE eventListener.
View 9 Replies
Mar 25, 2010
I want to create a MovieClip, pass this MovieClip to a function in another class where it will be modified.The problem is, when I pass the MovieClip as a parameter to a function and start making changes, the changes are only made locally. The "copy" of the MovieClip inside the function gets changed, but the "real" MovieClip back in my main game class remains unchanged. Here's the code from my Main class:
Code:
var resourceLoader:ExternalResourceLoader = new ExternalResourceLoader();
var myMovieClip:MovieClip;[code].....
View 4 Replies
Apr 20, 2009
I have a child class that is loaded into the parent class when the swf begins, like so: var myvar = 'hello'; public function Parent() { this.child = new Child(); }; How can I retrieve the variable 'myvar' from within child?
View 1 Replies
Jan 4, 2005
I'm having bit of a headache with 1119 error and I can't figure out why.What I'm trying to do is:
1. Add Display Object "imagesGallery" to mainWin
2. Add MovieClip "imagesPreloader" to "imagesGallery"
3. Fire the "load" function from "imagesListLoader" which should fireup the function imagesLoaded in "imagesGallery"
Here's the code:
mystage/MainWin.as:
Code:
package mystage {
import flash.display.MovieClip;
import flash.events.Event;
[code]....
View 2 Replies
Jul 31, 2011
I'm having bit of a headache with 1119 error and I can't figure out why.The problematic line is in red.
What I'm trying to do is:
1. Add Display Object "imagesGallery" to mainWin
2. Add MovieClip "imagesPreloader" to "imagesGallery"
3. Fire the "load" function from "imagesListLoader" which should fireup the function imagesLoaded in "imagesGallery"
[Code]...
View 5 Replies
Jul 28, 2011
Using Flash CS5 Professional I have created a symbol, dragged it onto the stage, and given it an instance name of GreenLight1. If I want to make this visible from the document class, I can simply do the GreenLight1.visible=true; and poof it's good to go when I test the file. As long as I stay in the document class I am good to go, but now I'm trying to move to another class and hitting ALL kinds of trouble just trying to get Flash to allow me to access this simple object. All I am looking to do is have this GreenLight1 go invisible (visible=false) when a certain condition occurs in this new class and Flash just won't let me access GreenLight1 at all. Things I've tried thus far:
stage is passed to the class and is referenced by _stage and is working just fine when I do _stage.addchild or anything like that. So I have tried "_stage.GreenLight1.visible=false;" and I get "ReferenceError: Error #1069: Property GreenLight1 not found on flash.display.Stage and there is no default value." My document class extends Sprite, so I figured I'd try the root function. So I tried "Sprite(root).GreenLight1.visible=false;" and I get "1119: Access of possibly undefined property GreenLight1 through a reference with static type flash.display:Sprite." I tried to create the Resource class as described therein. To which I came across the same problem that I started with in that it doesn't know what GreenLight1 is to begin with so I got "1120: Access of undefined property GreenLight1." Here is my code for Resource.as (am I supposed to pass something to this class from the document class?)
[Code]...
View 2 Replies
Jul 21, 2011
I am doing a looping background with 2 identical BG movieClip (B1 and B2). Those 2 are "new" by the same class.
var B1:MovieClip = new BG();
var B2:MovieClip = new BG();
But because this BG class picture is loader from the internet and the picture is rather big. When I addressed its loading by using progressEvent. The picture is really loaded 2 times. Is there anyway I create B2 based on B1 without using new BG() again? Since it definitely makes a new BG with Loader code inside.
[Code]....
View 2 Replies
Oct 21, 2010
i have classA and classB like bellow
class ClassA{
public var myVar:String="test";
public function ClassA()
[code].....
View 2 Replies
Jun 8, 2009
I'm creating a bunch of movieclips, associating a sound object with them, and then updating them with a progress bar, like so:
var theClip:MovieClip = new MovieClip;
theClip.track = new Sound;
[load sound from URL pseudocode here]
theClip.track.addEventListener (ProgressEvent.PROGRESS, onLoadProgress);
function onLoadProgress (erogressEvent):void {
How do I reference the movieClip the sound is a child of? e.target refers to the sound object; e.target.parent returns an error. And you can't assign properties to sound objects.
View 1 Replies
May 1, 2011
Can I access a static variable of a subClass' subClass? I don't want to instantiate it, just looking to get the variable because it has already been initialized by the subClass.example:
package
{
public class A extends MovieClip {
private var classB:B = new B();
[code]....
View 3 Replies
Aug 17, 2011
I am writing some codes inside a movieclip but I want to activate a mouse over event from a parent object since there is a removeEventListener method that delete the the event!Is there a way to do it in actionscript 3.0?
View 11 Replies
Jul 16, 2009
I'm trying to create a timer object within a movieclip, which, due to the dynamic nature of the movieclips, works well. However, when a timed function is kicked off I'm having trouble referencing the 'parent' movieclip.I'm trying the code below but the'Evt.currentTarget.parent' line throws an error. Anyone know how to make that reference work?
var mc:MovieClip = new MovieClip();
mc.transitionTimer = new Timer(30, 0);
mc.transitionTimer.addEventListener("timer", stepTransition);
[code]......
View 2 Replies
Oct 20, 2010
I got this document class Main and a navbutton class. How can I connect a function from one AS3 document to another like this:
navbutton.as
removeObjects();
Main.as
function removeObjects(){
//code
}
I get this error: call to a possibly undefined method removeObjects.
View 5 Replies
Oct 22, 2010
Well I've been searching the web and knocking my head against the wall long enough to justify an inquiry.
Anybody know an elegant way to get a usable reference to a class in a loaded swf?
I find that this approach, from Big Spaceship, produces an error, when compiler is forced to try to convert type "Ball" to type "MovieClip." Sheesh.
Code:
var loader:Loader = new Loader();
var nuSquare:MovieClip;
var nuBall:MovieClip;
[Code].....
View 2 Replies
Jun 11, 2010
I have this movieClip "Container" and within it on two different frames I have two movieClip/buttons, "pause_btn" and "play_btn", respectively. I would like to call a function on the main timeline on frame two of "Container" where "play_btn" is located.
I think I'm getting close but really have no idea. I know about the visible property and have been considering that, but isn't there a way to call a parent function from within a child movie clip? The code looks like this.
[Code]...
View 3 Replies