ActionScript 2.0 :: Adding Method To Existing Class?
Jul 5, 2009
I'm trying to make a new method for the XMLNode class and I want to use this method in other classes of mines that manipulate XMLNodes. Here's what I did :
1. I wrote an Ext class which you can read here :
[Code].....
It didn't work (saying that myMethod doesn't exist), so I added this line "static var e : Ext = new Ext();" before "function Testing () {}" Then my method worked. I don't understand why but great.
3. The problem is that I want to use the method not only in the main function but also in other classes of the application. However, when another class tries to call the custom method, it says that it is not defined. I don't know how to solve that.
Additional infos: I'm using the Eclipse IDE rather than the traditional Flash IDE so I don't have such a thing as "the first frame". My app only has the main function.
-MTASC which compiles my code doesn't support #include
View 1 Replies
Similar Posts:
Jul 3, 2006
how I might go about adding a method to flash.display.Graphics so that I can call it just like I would drawRect()
for example, graphics.drawDottedRect()
I tried extending Graphics with a new class called Graphics and adding my function but this does not work. I'm sure that the display object is making its graphics instance from the real flash.display.Graphics class and not my extended class.
View 2 Replies
Mar 28, 2011
I'm totally new to Adobe Flex Builder 3. I've been assigned a fully functional project but when I want to add the simplest function to any class, I always got the same error :
Call to a possibly undefined method through a reference with static type
For example, in some random class there is a function defined like this :
public function GetID() : String { return m_strID; }
If I try to define a new one like below :
public function GetIDFoo() :String { return m_strID; }
And then I try to call both of them like this:
trace ("This line is ok : " + oPhysicalScreen.GetID());
trace ("This line gives me an error : " + oPhysicalScreen.GetIDFoo());
[Code] .....
View 2 Replies
Jul 16, 2009
Basically I want to create my own drawRect() for as2.normally, I would just prototype it:
Code:
MovieClip.prototype.drawRect = function(x,y,w,h){ //etc.. }
and then I would be able to use it like:
Code:
mymc.drawRect(a,b,c,d);
Is there a way to make that function a class so that I can still call it from a movieclip directly? I read in another post somewhere about calling super.drawRect() in an extended class, but I'm not 100% on how to actually do this.So far I have what is below. I don't think I'm supposed to be declaring the mc var, but I can't think of another way to do it.
Code:
class drawRect extends MovieClip{
private var mc:MovieClip;
function drawRect(x,y,w,h){
[code]....
View 0 Replies
Jun 15, 2010
I have been trying to add a movieclip to my .fla file from a class.my main fla file: main.flaactionscript file: script.asthey stay in the same directory.script.as file as follows:
package {
import flash.display.*
public class MyClass extends MovieClip
[code]......
View 1 Replies
Apr 23, 2009
how i can add text to an existing file instead of overwriting it... ive got this far... string filePath = "C:\tex1.txt"; StreamWriter foo; if (File.Exists(filePath)) { // File exists // Don't do anything.} else {// File does not exist foo = new StreamWriter(filePath); foo.Write("Blarg. Zorb. Zeeb. Foo."); foo.Close();}
View 1 Replies
Oct 22, 2009
I am a newbie and been developing this menu that is XML driven and uses an External AS file for the script, so there is no AS on the timeline, it is all external. The Preloader. I found this preloader from here: [URL] which I have been trying to build into my movie, but with no joy! I don't understand how to add a preloader when you have external script, there is going to image directly on the stage, which is what the preloader would be loading.
Basically all I would like to do is add a simple percentage count for the preloader, a loading bar also would be great, but if not ,thats ok. The problem I have is when I put the preloader script into my existing menu all hell breaks loose. Below is a link to my menu files and also attached the AS script file, if that is better? Link to menu files: [URL]
Attachments: Main.zip (1.5 K)
View 1 Replies
Aug 30, 2010
If I already have an existing movie, what is the best way to add a preloader to this movie?I have 1 frame with a few layers right now. Then, I have some movie clips on frame 1 Should I just move everything to frame 2? Does that throw anything out of sync? I am using labels in the movie clips that that I can use gotoAndPlay("label");
View 5 Replies
Apr 30, 2009
Trying to write text to the end of an existing .txt file... I can only overwrite the file each time.
View 1 Replies
Aug 21, 2009
I'm still a newbie in terms of as3, but have built a code-simple flash site (using CS3 & Dreamweaver). I've only just discovered SWFAddress / SWFobject / swffit and have been combing through my flash pages to implement these oh-so helpful tools. Troubled process, as it is...
I have literally spent days (not merely hours) trying to adapt various code, watching and following tutorial and trying to adapt what I find for my existing site (which is, unto itself, still in development)
I'm trying to avoid avoid using external packages and script instead on the timeline, in keeping with how the site was originally built (with hopes this would save me from having to rebuild and reorganise the structure of the timeline - there are several gallery pages and files and buttons and cross-linking). But I'll attach here just one fla ("archives.fla") that anyone whom has experience with SWFAddress might understand what I'm contending with. I've borrowed code from so many sources at this point that the script code is sure to be bungled (one top layer of the fla file, for deep linking).
I would be ever so grateful for assistance in this regard; cannot afford to pass another day trying to figure it out (I am on a deadline)...
file to big to attach; i don't believe looking at the code will be of any use without seeing the set up and references on the timeline... but i'll insert it anyway (below). is there a way to send the file to someone directly?
[Code].....
View 3 Replies
Dec 5, 2011
I'm trying to redo my App and have everything added dynamicly, so updating will be a lot easier. I have 3 movieClips in my library. 1 is the holder of the other two. This is done because the holder has a class attached to it, and the 2 other movieClips are where the content is being added.
So basicly what I have now is via XMLList and a for loop the content is placed and displayed on the stage. They are added like this:
PHP Code:
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("Avalist.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
[Code]....
Now what I'm trying to do is add the same amount of content, but different images to the flipHolders that already exist right now but then the sideB in stead of sideA.
View 1 Replies
Jan 15, 2009
add files to a stream on the server so that a clientof the stream just sees a continuos stream fo data?
View 2 Replies
Feb 15, 2010
The index file is .php. Now I've got this little Flash animation that we want to run first, then when it's done go to his website. When I try to add it to the top of the index page all that happens is the site loads like in normally did but with the Flash movie at the top instead of being another page. What do we need to do to have it load on it's own first?
View 1 Replies
Mar 31, 2007
Ok so I found this nice code over at Prototype. Its a function for Aligning to stage on Resize. [URL] It works really nice on its own but I was hoping to add some tweened easing as an additional optional parameter. (I posted there twice asking for help to no avail =( So I am asking here at Kirupa. What I wish to add is - implementing and adding an "easing" function as part of the current function. Something generalized to be called only if desired and the ability to set the ease type, duration, maybe prop etc.. (or whatever needed to make it work)
I have tried all kinds of things and below is as close as I can come (at least the only thing I can do to get the thing to move, although as you will see it works backwards and I can only get it to work using stage.width, stage.height, however I have tried newX oldX and all kinds of other things and cant seem to get things to move.
[Code]...
View 15 Replies
Jul 18, 2011
My company recently contracted an outside web developer to create our new website. I have some experience with Flash, but not beyond basic timeline controls. I've been given the task to update the flash element that has a horizontal carousel. Inside, there's three series, each with 6 buttons. The controls are a left and right arrow button on either side. I added a new button into the series and moved each of the series so they no longer ovrlapped.The carousel should just rotate through continuously, but it returns to the start after 6 clicks. Please let me know if there is any other materials I need to provide. Did adding in another button change the positions in the code? If so, what do I need to do to fix it?
[Code]...
View 1 Replies
Sep 26, 2009
We're trying to add a simple link to an existing Flash file. There looks to be at least 7 separate .as files and a separate swf that loads the main swf which all seems overly complex for what is essentially a page with six buttons on it.However, we need to add a URL to some of the text. So we converted the text to a button, added an instance name of <ssbpurchasetickets_btn> then added the following Actionscript into the actions layer on the frame the text/button appears:
ssbpurchasetickets_btn.addEventListener(MouseEvent.CLICK, ssbButtonPurchase);
function ssbButtonPurchase(event:MouseEvent):void
{[code]......
When we publish the file we get the following error which seems to cascade into a whole bunch more errors:Description: 1046: Type was not found or was not a compile-time constant: MouseEvent.Source: function ssbButtonPurchase(event:MouseEvent):void
We added "ssb" onto the button and functions to ensure there were no conflicts but the same thing occurred. If we copy the button into a new file everything works so it must be conflicting with something in the main files.
View 23 Replies
Jan 22, 2010
I have a base class which is being created via remote_object [RemoteClass alias] from the server.I have other specialized classes that are derived from this baseclass, but serialization with the server always happens with the base class.The base class has meta data that defines what the derived class is, for example
[RemoteClass (alias="com.myco...')]
public Class Base
{
[code]....
View 2 Replies
Aug 6, 2009
how to addChild() a new Object to an existing movieClip on stage from an external class....
for better understanding:
This is my external Class:
ActionScript Code:
package joueur
{
public class CreeJoueur
[Code]....
Then i have the main .fla file with a movieClip on frame1 called 'terrain'.
When i try my code, the external class does'nt reach the terrain MovieClip :
ActionScript Code:
Error 1120: Access of undefined property terrain
View 4 Replies
Dec 20, 2010
I have an Existing FLA file (It is my Project file) and I have downloaded one good example Class file with Fla. But there is no code at all on the stage just it is retrieving instructions from the Class. How can I use this class file in my existing fla file.
View 3 Replies
Sep 17, 2010
I have an J2EE Enterprise Application Project in which I would like to add a few Flex screens. How do I go about adding Flex capabilities.
I have build Flex/J2EE applications from scratch but can't think of the best way to do this.
I am currently using Flex Builder Plugin for IBM Rational Application Developer 7.5.
View 1 Replies
Aug 16, 2010
I have two classes. The Main class calls a function, which is defined in a Second class.I'm getting the following error:Error 1120: Access of undefined property myFunctionBasically, I am creating buttons in the Main class that will add a corresponding Child to an Object in the Second class (if you click one button, child x1 will be added, if you click another button, child x2 will be added, and so forth).Here's the relevant code for the Main.as file:
package
{
import flash.display.MovieClip;
[code].....
View 3 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
Jul 5, 2010
I have a rather silly question but as3's document class always gets me confused.I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).
View 6 Replies
Feb 19, 2009
I'm trying to add CSS for an XML file. The functionality of this is you see an xml image and dynamic text, when you hit a button you get the next image with new text and so on and so forth. The problem is when I add a stylesheet object it makes the text do funky things
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
[code].....
View 0 Replies
Mar 23, 2009
I have two classes:
1. DocumentClass
2. GameClass
I would like to be able to call a public method of DocumentClass from GameClass. I don't know how to do that, I tried instantiating an object of DocumentClass within GameClass which simply throws me into an endless loop and after a short while application crashes.
View 2 Replies
Nov 4, 2010
I have a class, my document class, called SilkRoadTweeter. as I also have a class called User.as In my User class I need to call a method called nonce() I have tried this, trace(SilkRoadTweeter(root).nonce()); But I get the error, TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 4 Replies
Jul 6, 2010
I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).
I have tried everything and nothing seems to work. How do I do this?
View 8 Replies
Dec 28, 2005
I have a class called Unit. When I use this class in a .fla file, I create it by saying:
var unit00:Unit = new Unit(...);
So then it creates a gfx representation of the screen for me. I would like to have a method like this:
PHP Code:
[code]....
So how do I get this to work? I know that delete this will not work when defined inside the class. How do I target the .fla's instance name when I don't know what it will be called?
View 10 Replies
Jun 9, 2011
They are located in the same package and are both importing each other. I am trying to call a function from Class2 within Class1, but I don't know the syntax. I tried: Class2.godoThisThingNow(); But it gave me an error 1061, call to an undefined method. What's the proper syntax for this, and is it even possible in AS3?
View 3 Replies
Oct 12, 2009
From my LoadXML class I am trying to call a method, named onBackgrLoad, which sits inside the Main class. I made the method onBackgrLoad public. Inside the LoadXML class in the method ParseData I added an event listener. This is supposed to call onBackgrLoad but it doesnt work
[Code]...
View 3 Replies