ActionScript 2.0 :: Importing Class Into Custom Class?
Apr 4, 2007
I'm not allowed to import classes into other classes but I am not sure how to achieve what I want. I want 2 custom classes to pass data one from another directly. I have 2 custom classes I want to use: one extends the XMLSocket Class:
class Game extends XMLSocket {
import XMLParser //not allowed to do this I know!
var parser:XMLParser = new XMLParser();[code]....
As I say I realise I am not allowed to import the parsing class into my Game class (or any class for that matter) but I don't know how to pass data directly between these two classes without referencing them in the main FLA.
View 6 Replies
Similar Posts:
May 7, 2010
I am having problem with importaing package/public customClass via a code snipit Scripting. Here are the details I created a customClass.as ActionScrip3.0 script saved it as customClass.as inside an unnamed package then I creeates a blank customClass.fla file (notice the the name customClass.fla and customClass.as must be identical for this to work)and in the properties section simply put customClass.as and then I run customClass.fla test movie and it works fine.. The problem is how do I call customcClass.as again in myFlash.fla that does not have the name customClass.fla file using a code snipet
View 19 Replies
Sep 3, 2011
A very weird problem is happening in my AS3 code.I made a custom class called test, and in the main document class I imported it using "import test". Also, I set the class path correctly so it should work fine. Now, the problem is, when I instantiate this class to an object, it works fine as long as it is outside the document class constructor, it i try to use it inside the constructor method, it doesnt work!
[Code]...
View 1 Replies
Jul 31, 2010
I have a Flash document containing several subclasses. I want to access a custom cursor class I wrote from another subclass called 'mapmenu'. The thing is, it's not working properly. I can import it from my Main class, but not from any subclass. Some bells should be ringing..This is the custom cursor class (located at C:/Flashproject/com/own/Cursor/Cursor.as):
Actionscript Code:
package com.own.Cursor{ import flash.display.*; import flash.events.*; import flash.geom.Point; import flash.ui.Mouse; public class Cursor extends MovieClip private var stageRef:Stage;public function
[code]....
I let all the other script out, it's a bunch and it's not needed for the cursor to function.In the .FLA I have a MovieClip called Cursor containing a cursor. It's exported on frame 1.The problem is: the cursor class won't be called. No errors, no cursor, no trace (see cursor class).
EDIT:FYI: I would put this in the main class:
Actionscript Code:
cursor = new Cursor(stage);stage.addChild(cursor);
But I can't address stage from a subclass can I..?
View 2 Replies
Jun 25, 2011
I'm trying to create an external file for mouse movement sensing so I don't have to rewrite it everytime I want to use it, which is what .as files are for, I understand.I think the package is working (kind of) but I'm not sure how to get it to run as every tutorial I have come accross applies to graphic use.This is my package (I don't know why the coding is unalligned):
ActionScript Code:
package {[code]....
I've tried 2 ways to get it to work: 1.) Assign a class to the stage in the properties panel. When I did this I had no errors but the ENTER_FRAME function did not work, which entirely defeated the purpose of the coding.
2.)
ActionScript Code:
var test:mouseVisibility = new mouseVisibility();
addChild(test)[code].....
View 9 Replies
Jun 25, 2007
I'm having some problems importing a class, the message that Flash gives me is this; The class being compiled, 'ImageLoader', does not match the class that was imported, '[URL]'. The only line of code in my flash movie is this: import com.martijndevisser.*; And yes, the class is in that folder The class is from here: [URL] I've used the class before and it works fine, I just dont know what to do?
View 4 Replies
Jun 16, 2011
I have a custom class being constructed from my main class. In the custom class it has another custom class that is passed in as a parameter. I would like to strictly type the parameter variable but when I do, 'the type is not a compile type constant etc'.This, I understand, is because the custom class used as a parameter has not yet been constructed.It all works when I use the variable type ( * ) to type the parameter.I suspect this is a design flaw, in that I am using an incorrect design pattern.It is actually hand-me-down code, having received a large project from someone else who is not entirely familiar with oop concepts and design patterns.
I have considered using a dummy constructor for the parametered class in my main class but the passed in class also takes a custom class (itself with a parametered constructor). I am considering using ... (rest) so that the custom classes' parameters are optional.Is there any other way to control the order of construction of classes? Would the rest variables work?edit)in main.as within the constructor or another function
var parameter1:customclass2;
customclass1(parameter1);
in customclass1 constructor:
[code].....
View 1 Replies
Jan 23, 2010
I am new to AS3, as well as Flash in general, so forgive me if this seems highly elementary. All I am trying to do is create a custom class that extends the MovieClip class and contains a custom property of "marker". I want to be able to use and change the value of this custom property on the timeline for an instance of this class and have it behave just like any other (Ex: this.x ==> this.marker).
[Code].....
View 13 Replies
Dec 2, 2011
This is my first time working with a class attached to a movieclip that is nested inside a class attached to a movie clip.I've tested all the properties and methods of PTListItem.as and they work properly but when I try to call them on the list item through PTListTop.as it returns undefined.The end goal is to dynamically load a checklist via a txt file.
View 1 Replies
Aug 16, 2011
If I have a Document class that extends MovieClip, and I want to use it as the basis for another Document class, is it possible to create a subclass that extends the main document class and use that for a different FLA?
For example,
fla1.fla has a document class of MyMainClass:
public class MyMainClass extends MovieClip
fla2.fla has a document class of MySubClass:
public class MySubClass extends MyMainClass
I've tried, but now I'm getting errors that all of my variables that reference stage instances aren't being found.
View 1 Replies
Apr 20, 2011
I have a custom class created by a main document class, and I want the custom class to run a function in document class after some time.
How can I sent the instruction from custom class back to the document class?[code]...
View 6 Replies
Mar 5, 2007
get a bunch of objects in my library to inherit from (or even be) one class that i have made, but without having to make .as files for every single one is this possible, or is there any other way to give objects another classes functionality in an auto-generated class?
View 3 Replies
Dec 7, 2009
Is there a way I can reference a Movie clip I have on the main stage from a custom class of a document class?[code]
View 1 Replies
Oct 14, 2011
I need to use stage.width/height in my CustomClass so I found some topics about it.
if (stage)
{
init(ar,firma,kontakt,oferta,naglowek,tekst,dane);
[code]......
View 1 Replies
Dec 28, 2009
I'm trying to create a class which will create a tween for several different instances of an object. I am creating the instances in the Document Class. The trick is, I would like to specify how long each tween will take.
Here's what I have so far:
DOCUMENT CLASS
ActionScript Code:
package {
import flash.display.MovieClip;
import mcCloud;
[Code].....
As you can see, I have a variable "myTime" which syncs the timer and the tween. This causes to tween to repeat and the clouds to continually scroll across the stage. How can I determine the var myTime at the time I create each instance of the Movie Clip mcCloud?
View 6 Replies
Feb 24, 2009
I keep getting an "undefined property" error when I try to call an external function from within the Doc class. I added the error message to the Doc Class below so you can see where it occurs.
If I take the code from the Tooltip.as below and place it on the FLA's main timeline I can get things working fine, but I would like to move all script to classes. The document class structure looks like this:
Drag_and_Drop.as
Code:
package {
import Tooltip;// Import custom class
public class Drag_and_Drop extends MovieClip {
[Code]....
I realize that I could just combine all the code in the Doc class to get it working, but it would be nice to separate out this particular code which has only one use.
View 4 Replies
Jun 2, 2009
the website I'm work on has the document class Main. Within this website I have a movieclip on the stage which I built a custom class for its functionality and I linked this movieclip to this class to make it work. There is no reference to this movieclip or class in Main.
Now, I need to communicate between these two classes. Can I do this? Can I dispatch an event from the custom class linked to the movieclip and have the document class listen for an event? How?
View 2 Replies
Sep 12, 2009
I am facing a technical proble when I am importing a "FlashVarsParam.as" class file in my main class " VideoPlayer.as" and when I am using "FlashVarsParam.as" in my FLA doucument class "VideoPlayer.fla" then it is workining fine. "FlashVarsParam.as" file given below so I am accessing in my main class and then it gives me error
[Code]...
View 1 Replies
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
Jan 4, 2012
I understand it's probably best practice to name your custom classes differently than the built-in AS3.0 classes; however, what kind of problems could I run into if I don't?Specifically, I have a class which, ideally I want to name DataProvider. But, as you know, there is already a DataProvider class on the Flash platform (used for list-based components and such).Now, I don't think I'll ever use BOTH of those classes, so I'm assuming as long as I reference the correct DataProvider class in my import statements I should be ok?What if I DO need to use both, is that even possible?
View 2 Replies
Apr 20, 2011
I want to dispatch a custom event from the Country() sto the MenuButton();[code]When a country is hovered a custom event is dispatched which I want the MenuButton to listen and if the parameter passed is the same as its name to get highlighted. The Country Class is the Base Class for my countries movieclips I have on stage and the MenuButton the Base Class for the menu button.
View 1 Replies
Feb 18, 2009
In a nutshell I have a custom event that I am dispatching from one class that is not getting picked up by the other class even though i have added the appropriate addEventListener calls on its constructor.Here's how the classes are laid out:
application(class/parent)
- network(class/child)
- loginscreen(class/child)
The constructor of the Application class creates and stores references to the network and loginscreen classes:
ActionScript Code:
import com.fg.managers.NetworkManager;
import com.fg.screens.LoginScreen;[code].....
The NetworkManager class extends the MovieClip class as does the LoginScreen and Application classes as well.Now within the oLoginScreen class I dispatch the ValidateCredentialsEvent by calling it this way:
ActionScript Code:
dispatchEvent (new ValidateCredentialsEvent(ValidateCredentialsEvent.VALIDATE_CREDENTIALS, oLoginData, true, false));
Then when I debug the code, I can step through and see that the ValidateCredentialsEvent is being generated but it is never picked up by the oNetworkManager class whatsoever.Is this occuring because the NetworkManager and LoginScreen classes are children of the Application class and because of this can't capture events raised by one another without using the Application class as the intermediary to redispatch these events? My whole idea here was to create a generic network managing object that could be called from anywhere within the application, by any object, using custom events.
View 9 Replies
Oct 3, 2009
Im trying to use an AS3 modification of gskinner's collision detection class, but this being the first custom class i've ever tried to implement, i dont what i'm doing.How do i implement it into my flash? Do I just put it in the same folder as my .fla and .as?Do i have to initiate it in the main class?From what i understand it creates a rectangle, what would i need to turn it into a simple true/false?
View 2 Replies
Sep 27, 2011
If I can create dynamic variables on a MovieClip.. why would I not be able to create dynamic variables on a class that extends MovieClip?
[Code]...
I created from a mc symbol in the library. it works fine, except for adding the custom variable.. .. which I need to be able to do.
View 7 Replies
Aug 29, 2007
I've been playing around with custom classes. My objective was to create a custom class (Testing) that would create a box when an instance of the class is created. I've tried three different approaches, however only (3) seems to be showing up. I'm just curious why (1) or (2) doesn't work?
Also is there a better approach than (3)? Since at the moment it's been created on _root. I hope the box can only be accessible through the instance. Since I'd like to incorporate the whole idea of public, private, encapsulation, etc.
[Code]...
View 3 Replies
Nov 4, 2011
I have the following situation:I have an event handler, that displays small messages in my application's statusbar.These messages get passes through by dispatching events from custom components.A simple message could be like "HTTP Error" or so.Now, the main event listener, in the main application file, listens to the event dispatched by any custom component,but seems to refuse listening to events dispatched by custom AS classes.Here is my code for the custom event:
package main.events
{
import flash.events.Event;[code]..
So to sum it all up:
- The event listener listens to the custom event dispatched by any custom component.
- The event listener does not listen to the custom event duspatched by an AS class.
Those who wonder, the event really gets dispatched, that's why I added a trace call.
View 2 Replies
Jan 25, 2010
I couldn't work it out yet...
package components {
public class templateSelection extends VBox {
static public var tempSelectionBag:Dictionary;
[Code]....
I want to have a custom class tempSelection with a Dictionary as a public accessable property of that class. If I use this code, the compiler tells me:
1046: Typ wurde nicht gefunden oder war keine Kompilierungszeit- onstante:Dictionary
Which translates to:
Type was not found or was not a compile-time constant: Dictionary
View 1 Replies
Dec 3, 2008
I have a scroll file, taken from a tutorial, which is linkedto a class. After having customized my file I did try it and itworks fine. The problem is starting when I try to import this fileto an empty MCL in my website. When I have imported all theelements they do not respond and act like single pieces (es. thescroll bar is detached from the scroller). What can I do?
View 2 Replies
Apr 15, 2012
I am using external AS files for a new project of mine, which involved creating a place to draw so i used the following tutorial to get a basic idea of what is need. I got the hope application working and running smoothly until i decided i wanted to add in a preloading & Menu - putting the drawing part of the app on the third frame - which got me this error:
TypeError: Error #1009: Cannot access a property or method of a null
object reference.
- at Main/convertToBMD()
- at Main()
So I thought instead of adding the Main.as to the Class under properties i would import the file on the frame instead. Using:
var main:Main = new Main();
addChild(main);
This worked apart from it loses all connections to the instance names.
Line 64 1120: Access of undefined property pencil.
Line 65 1120: Access of undefined property eraser.
Line 65 1120: Access of undefined property txt.
Line 82 1120: Access of undefined property board.
Line 83 1120: Access of undefined property board.
Etc.....
So what i would like to know, is there a better way of doing this and getting it working on any frame?By changing something in the external script or another way of importing onto frame?
View 1 Replies
Sep 17, 2009
I downloaded a sample flash that contains a class file.When try to run the file get the "1172: Definition be.nascom.flash.graphics:Rippler could not be found." error. Rippler is the name of the file and I think be.nascom.flash.graphics is the authors directory structure. I think the error is because the file is not in the right location that Flash is expecting it to be in to find it.
View 7 Replies