ActionScript 3.0 :: Using Document Class Vs Importing .as File?
Apr 25, 2010I'm just wondering about the difference between using an external .as file as a Document Class vs importing it via some timeline code like:
[Code]...
I'm just wondering about the difference between using an external .as file as a Document Class vs importing it via some timeline code like:
[Code]...
I have a FLA file that has a AS file linked via the document class.
How do I remove the link from the documnet class and the place an import on the timeline to do the same thing ?
I have 2 as3 files, which are the classes used . I have to use it with the main flash movie.. How will I include those as3 files without using document class..
View 4 RepliesI have a main.swf with a loader that loads an external.swf file. That file is an xml photogallery. The gallery has two other folders lets call them folder1 (contains xml file, image files) folder2 (which has sub folders that contain.as files for the tweens) I need to import these files to the main.swf or is it export these files from the gallery to the main.swf?
View 1 RepliesI have drawn buttons on my stage. They all set to export for as3. I then made a class for buttons
package{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.system.fscommand;
public class Buttons extends MovieClip{
public function Buttons(){
[Code] .....
And then I put in my document class ; import Buttons; nothing happens and no errors...
I found myself loading a new XML file every day and so decided to create a small class that will load the xml file and return it.The class is loading the file but when i try to return it to a new xml object in the document class it doesnt load it.I think that it's something to with the return being in a nested function but i tried a few ways and non seems to work.
[DOCUMENT CLASS]
loadXML:LoadXML = new LoadXML();
myXML:XML = new XML(loadXML.loadXMLFile("gallery.xml"));[code].....
Is there a way to link to a class file from the timeline rather than using the Document Class? (I tried using the document class but it messed up because of the nested movie clips and stuff like that... so I need another way)
View 3 RepliesI 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 RepliesI am dispatching an event from one document class and listening for it via another document class.My code in class A.
Code:
this.dispatchEvent(new MYEvent(MyEvent.APERTURE_DONE));
trace("Dispatching APERTURE_DONE");
my code in class B.
Code:
addEventListener(MyEvent.APERTURE_DONE, onDoorsOpen,true);
trace("Lisetning for APERTURE_DONE");
[code]....
My listener is registering before the event is dispatched, based on my output window, however I never get the "Open Doors" trace statement to fire.
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]...
I have a FLA (say Main.FLA) document class with a child MovieClip on the stage: into the child MovieClip I load other swf files: each of the files contains its own Document Class (every swf is a somewhat independent application, say quizzes and so on).For some reason I must use the Main document class to store data (scores or so) from the child swfs loaded into the Main swf. HOW do I reference the Main class? I can't find a way.[code]and dispatch an Event this way from the loaded swf document class to the Main class:[code]Now, first of all I don't know if this could even work. Secondly, I tried to make it work by adding an event listener to my Main class but id did not work.
View 9 RepliesI'm just getting into flash and i would like to know how you run more than one as3 file from the main .fla file?
Is it possible to use more than one document class file?
It seems simple, but it doesn't seem to be working I have 2 as3 files as classes "mainclass.as3 (this is the document class)" and GamePlay.as3
the GamePlay class works flawlessly on it's own, but when i try to create the var to access it ... var gp:GamePlay=new GamePlay(); ... i get the following error.
I have looked at tutorial etc, but i cant get it to work i am currently getting the following error.[code]...
I can't do many simple things in AS3 that take 1 second to do in AS2,
All I want to do is attach a movieclip to the stage via a .as file that ISNT the document class.
So for examples sake lets say I have Main.swf - Main swf file with a movieclip called "PreloaderGUI". Main.as - The document class, this loads Preloader.as. Preloader.as - This preloads the movie and attaches PreloaderGUI.
So I had a working .fla, with a document class package in the same directory. Everything was fine, until moving both to a new directory, now the fla cannot find the document class. WTF?
View 2 RepliesI want to know how you access a variable within the fla file from the Document class?I want an int inside the fla or swf file to be accessed from the class that is being used to run the file?
View 5 RepliesI heard about jsfl (Flash IDE API) so I guess it is possible but I can't find any concrete example ?
View 1 RepliesIs there any way to use multiple document class inside same fla file,or change document class name dynamically i have 4-5 actionscript 3.0 file,these 4-5 files have codes of a game say level 1, level 2 ,level 3 , level 4 & 5 entirely different from each other.What i need is that when one level finishes, another level document class should be called?
View 3 RepliesInstead of posting my entire files and such, I'll make a brief example of my situation and my desired outcome.My files consist of my document class entitled Engine.as and another class Abilities.as all within the same folder.On my stage I have a MovieClip with the instance name of item1_mc. On its personal timeline I have 2 frames, one entitled "inactive" and the other "active". Here's a sample of very similar code....
Code:
package
{
import flash.display.MovieClip;
[code]....
How do I access item1_mc? In reality I have 6 different clips and I desire to access much more than frame changes...what's the overall best way to be able to interact with an item placed on the stage via an external .as file that is not the document class?
I have 2 flash files, one with an intro and the second that just has a document class file that plays out a snake game. How could i import that document flash file and make it play out on like frame 100 off my other flash file.
View 1 RepliesWhat I'm working on is a navigation bar populated by an XML document. I'm working from an existing navigation bar while I learn, and the existing bar has a menu, and when clicked each button has a sub menu. I'm trying to remove the submenu so that when you click the navigation bar button, you go to the address defined in the XML. So far I've got everything working so that there is no sub menu drop down, and when you click a button, you are taken to a URL defined in the actual flash AS file.
I can't seem to get the AS file to call on the XML file to the get a URL from it though. How do I tell the AS file to call a variable from the XML document? I know I have the correct Node path because it works in a second AS file.
I am trying to use the CSVLib from [URL].. However; when trying to use one of the examples I get an "1180: Call to a possibly undefined method addFrameScript."This is what I did.Extracted the files, then moved all FLA, AS and CSV files in the root (where also the COM folder resides). Then added the import statement to the Applicaiton file and defined document class.
View 2 RepliesI'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 RepliesI'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.
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]...
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.
while working with a server side script (php or aspx) which returns some data(from the database) can we call it in a sub-class or do we have to make the calls in the document class itself?
View 2 RepliesSay i need to send some data from AS 3.0 to a server-side script for it to do some actions. Can I do this in a sub-class called some where in a document class or should we always do it in a document class?
View 1 RepliesOk, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.
I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().
I hate to be defiant, but what if I don't want to?
Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?
It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.
That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.
HERE ARE THE STEPS I'M TRYING:
- Create new flash document
- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage
- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()
- Set a name for that box using box.name = "test" let's say
- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great
- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";
That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?
i have a movie clip which is exported for ActionScript , i want to get a variable from the document class into the movie clip class i tried this but there was an error !!
ActionScript Code:
var main:Main=new Main();
main.txtScore.text="hello";