Document class question
just trying to understand the concept here.
I have a flash animation '.fla' file with it's corresponding
document class that provides the code to control it.
I want to instantiate an instance of that document class in
another class.
Do I simply put the document class and it's
corresponding'.fla' file together inside the package folder ?
Once I declare the document class as a new object within my
new class, how does the document class link to the it's
corresponding .fla animation ?
To summarize, what I am trying to do, is create a reusable
class or component from this .fla file with its document class. I
just dont know how to proceed.
more than one swf can use the same document class. but
"animation" or other timeline assets will not be shared.
Similar Messages
-
Preloader and Document Class BIG question (yeap please help)
Hy,
I know that this its a question posted many, many times, but
after searching the net, reading a lot of books and searching this
forum too, I cant get out with a solution. If I'd say for sure
there is no possibility to create something like this, I just go
back to old methods but is not the scope of Adobe with AS3 to
encourage the use of OOP principle or not?
The problem:
I have a single fla file (AS3) with a single frame on
timeline, frame that its there when you will create the file with
flash. In the library I have different symbols, that for simplicity
are only jpg image, (BitmapData) checked for export for
ActionScript and exported on frame one. An external .as file called
DocumentClass its off course my Document Class
This its all that I want to do with the fla, the goal its to
create, animate etc. only with AS3 in external classes, no timeline
script. I don't want to load external files, XML, or else in this
movie. I just want a single swf after compilation, no additional
files.
Ok, how do I create a preloader that will take care of
starting the logic after the whole swf its loaded and in the same
time shows the user a percentage or a load bar or something that
its not the blank screen when the swf its downloading. I want to do
this without another swf that load this swf, or timeline scripts,
or place all the content on second frame and then gotoAndStop to
the third frame. All this are not solution but cheap tricks, that
are against all this OOP principle that I just continue to read in
books and here from guru programmers.
The big question is:
It is possible to create a preloader, when use a document
class with your fla? And if yes, how?
I know that the Document Class its not instantiated if its
not fully loaded, if that's true when the document class will be
fully loaded? maybe after the whole movie its loaded? And, if its
true, it will never show a percentage bar "while" the movie its
loaded. And if that's true WHY use a document class anyway?
Thank you for reading this and I really wait to get some
answer.I am pretty sure you cannot do self preloader with one frame
and all the objects in the library. I guess the key here is
one-frame design. Screen refreshes (renders) only when all the
scripts in the frame are executed - this is a very important thing
to understand about how Flash works. Yes, you can force screen
refresh with updateAfterEvent() method but it is attached to a
handful of events only (MouseEvent and TimerEvent) but, again, all
this functionality is available only after first frame scripts are
executed. Thus, it seems like the only way to create preloader from
within SWF is to use multiple frames and set library objects to
load in later (not first) frame.
quote:
And if that's true WHY use a document class anyway?
Well, preloader is the last thing that would be on my mind in
terms of using AS3 ability to link DocumentClass to the top movie.
This feature allows for very sophisticated architectural
approaches. It has no connection to preloader as to any other
features developer wants to implement. Neither it depends on or
negates timeline. As a matter of fact, although I love one-frame
applications, I find on numerous occasions that my application
would be more efficient if I used several (at least two) frames.
gotoAndStop is not deprecated. It is a valid MovieClip class'
method. After all, having only one frame doesn't mean not having
frames at all - there is one already. Frames are fundament of
Flash. AS3 did introduce frameless entities like Sprite, etc. but
it doesn't mean that frames are going anywhere.
I would agree that timeline code is inferior to
classed/packaged (read: better organized) code but, still, how is
it not OOP? Frame is an Object, right? Why using timeline is cheap
and not a solution?
On a side note, I see too many times how some authors (and
managers) are pushing their agenda (or close mindedness) onto their
audience with no real substantiation. Claiming that timeline in
Flash is not valid architectural decision from OOP standpoint is
totally wrong. As wrong as strict adherence to design patterns. I
don't think there is sharply defined "right" or "wrong" in
programming. One finds the best optimal solution. The goal is to
create something that works fine. Unless, of course, the process is
the goal - but very few of us can afford focusing on the process. -
Document Class x / y Properties Question
Hey guys.
I've been working on a project in Flash CS3 for a while. To follow an object on the screen and keep it centered, I'd adjust the Document Class' x and y properties.
Yesterday I bought/installed Flash CS5 and thus Flash Player 10 was also installed. Now when I go play my SWF it seems everything is all buggy, as if the code that modifies the Document Class' x and y properties isn't exactly working properly...
I've since reopened the CS3 FLA in CS5 and converted it to a CS5 format and I can't seem to get it working the way it used to.
Did something change regarding the Document Class and how to modify the x / y properties of it in the Flash Player 10 version? I really don't know what's going on at this point.
Thanks for any help.Sorry, but I'm starting to pull my hair out here. Here is the bit of code in question. This code is in a loop in an instance of the HUD class. The "parent" of the HUD class is the Document Class:
if (player.x < -600)
parent.x = 1000;
texture.x = -600;
else if (player.x > 1400)
parent.x = -1000;
texture.x = 1400;
else
parent.x = (player.x-stage.stageWidth/2)*-1;
texture.x = player.x;
if (player.y < -950)
parent.y = 1175;
texture.y = -950;
else if (player.y > 1400)
parent.y = -1175;
texture.y = 1400;
else
parent.y = (player.y-stage.stageHeight/2)*-1;
texture.y = player.y;
For some reason, it's not working like it used to. It's hard to explain other than things are buggy. Player hitting invisible walls, hittests not working when player actually hitting real walls, etc... I've had this same problem before and I fixed it so I know this is the code that's doing it. Just, I don't know what's causing the issue here other than Flash Player 10 not liking it...
Is that even possible? Between Flash Player 9/10 a selection of code is "interpreted" differently? -
Document Classes and other Questions
Basically, i am working on an application that will eventually be deployed to the desktop as an AIR application.
I am wanting to create an Analogue clock and Digital clock with a button that toggles the display between either one when pressed. As well as this, i will be wanting to display the Date below, i am having a number of issues however.
I have the code sorted for three of the four components, i have not attempted to figure out the button thus far as i would be more than happy to have the digital clock, analogue clock and date all being displayed on a drag and drop desktop application first. When i say i have it sorted, i have a fully working analogue clock which i have managed to display on the desktop through air on its lonesome, however, i did not include the drag and drop function. For the digital clock and date components i am not sure how to configure them into document classes. The main issue i am having is i do not know if you can reference a dynamic text box within a movie clip to a document class.
This is the code to show the date
[code]{
var currentTime:Date = new Date();
var month:Array = new Array("January","February","March","April","May","June","July","August","September","Octo ber","November","December");
var dayOfWeek:Array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
date_text.text = dayOfWeek[currentTime.getDay()] + " " + currentTime.getDate() + " " + month[currentTime.getMonth()] + " " + currentTime.getFullYear();
[/code]
I have put the actionscript frame inside the movie clip file, and i have given both the movie clip, and the dynamic text box within the movie clip the instance name "date_text".
Basically, i am just struggling in how to put this code into a working document class, since the digital clock and date functions are both, some what similar, i feel the solution to one will more than likely lead to me discovering the solution for the other.
The other problem i am having, i do not know how i will display all of the components on one air application. I am assuming, that you create one other document class file which links the other four together? i have tried to do this by just linking a new FLA file with the analogue clock, but it does not work. The code for that is below.
[code]package
import flash.events.Event;
import flash.display.MovieClip;
public class time1 extends MovieClip
public var now:Date;
public function time1()
// Update screen every frame
addEventListener(Event.ENTER_FRAME,enterFrameHandler);
// Event Handling:
function enterFrameHandler(event:Event):void
now = new Date();
// Rotate clock hands
hourHand_mc.rotation = now.getHours()*30+(now.getMinutes()/2);
minuteHand_mc.rotation = now.getMinutes()*6+(now.getSeconds()/10);
secondHand_mc.rotation = now.getSeconds()*6;
[/code]
That is the original clock document class (3 Movie clips for the moving hands, and the clock face is a graphic, which i may have to reference somehow below)?
[code]package
import flash.display.MovieClip;
public class main extends MovieClip
public var hourHand_mc:time1;
public var minuteHand_mc:time1;
public var secondHand_mc:time1;
public function main()
hourHand_mc = new SecondHand();
addChild(mySecondHand);
hourHand_mc.x = 75;
hourHand_mc.y = 75;
minuteHand_mc = new SecondHand();
addChild(mySecondHand);
minuteHand_mc.x = 75;
minuteHand_mc.y = 75;
secondHand_mc = new SecondHand();
addChild(mySecondHand);
secondHand.x = 75;
secondHand.y = 75;
}[/code]
This is my attempt at creating the main document class in a seperate FLA file to attempt to load the analogue clock, and later on the Digital Clock, Date Function and Toggle Display button in the same AIR application.
Any help on this is much appreciated, i have been reading up a lot on it through tutorials and the like, but i can't seem to fully grasp it.why do you have code in a movieclip?
if you want to follow best practice and use a document class you should remove almost all code from timelines. the only timeline code that might be reasonably used would be a stop() on the first frame of multiframe movieclips.
so, you should have a document class. that could contain all your code but it would be better to just have your document class create your 2 clocks and date objects and possibly manage toggling between the two clocks. you could have a separate class the tracks the time and date and that class is used by your two clock classes and your date class. -
TREX does not index all documents fro document class SOLARGNSRC
Hi all,
I've setup a connection between a TREX server (which is also used by a portal system) and Solution Manager. I've gone through the settings in SAP Note 750623 and I was able to create a index, the queue and even bypass the basic authentication in the preprocessing for document class SOLARGNSRC
According to everything I've read, this should be enough to be able to index all documents in Solution Manager and find them with Full Tex Search. But this doesn't work. From the 50.000 documents in de class (35.000 English and 15.000 German) only 6300 documents are passed to TREX. Most of them are German HTML links to help.sap.com. I can see in the trace files that the URL's to some documents in the content server are passed to TREX. I can open dthe document using the links but I cannot find the documents using the full text search which I think means that nothing was really indexed.
Questions:
1. Has anyone been able to succesfully index Solution Manager documents for full text search purposes?
2. Why are only 10% of the documents passed to TREX? Is there a specific setting for this?
3. Why does TREX use the Content Server HTTP links to index the documents and not the RFC connection?
Cheers
Marcel RabeYep, all lights green
SSR maintained. DRFUZZY as Search Engine (I have not tried Verity)
Return Code? Interesting, I don't get an return code when I trigger the Index/Deindex. I just see the hourglass for about 5 minutes (when I run it in the foreground) and after that its back to the way it was. No messages. Nothing appears in the application logs as far as I can see.
The program RSTIRIDX is scheduled in the background and runs every hour minutes for about 10 seconds without an error.
TREX Version 7.00.39.00
Five languages actived, including German and English. In SKPR07 under Indexed documents I can see that 300 German and 6000 English documents have status indexed.
No proxy server. Systems sit within the same network segment
Thnx for your help. I posted a message with SAP as well as this seems strange to me.
Marcel -
I am working with Windows Vista Business if that makes a
difference in this question.
I am testing a class file for NoScale called NoScale.as
I have created the class file attached.
I have saved the class file in the same location as the fla
file.
I put in the document.class box: NoScale
Whenever I publish, I receive the following error:
5008: The name of definition 'Main' does not reflect the
location of this file. Please change the definition's name inside
this file, or rename the file.
C:\Users\%UserName%\Desktop\Website\Reference Flas\NoScale.as
(Note: I have replaced my username with %UserName%)
I have attempted to put
C:\Users\%UserName%\Desktop\Website\Reference Flas\NoScale.as into
the document class box and I receive an error telling me that the
\'s are incorrect and are not allowed.I know that the classes are code that is prewritten so you
can use the functions within.
The answer to your question is No, I don't know what the
classes are doing because I am just beginning with AS3 and Flash 9.
However, my question is Why does my code work with no
problems without importing any of those classes into the code when
I don't put anything into the Document class: [ box ].
As soon as I wanted to give my flash header the ability to
resize itself, I found out that I had to create a .as or class file
with the above code in it to give it that capability. Once I did
that I found out that I had to use the document class box in order
to link that class file to the SWF. Once I created a proper .as
file named NoScale and typed NoScale into the document class box,
all of a sudden a ton of errors happen wanting me to include the
flash.blah.blah files. If I remove the NoScale from the document
class box and do nothing else, the project works just fine.
That is what I don't understand.
Wayne
Adding the following did fix the errors. Thanks.
import flash.display.LoaderInfo;
import flash.display.InterpolationMethod; -
Children swf timeline code vs document class.
Hey all,
I am loading a swf into another and had a question that I can't seem to find an answer to.
I am trying to find out why when I place trace(parent); in the timeline of my child swf I get [object Loader]
but if i place trace(parent); in the constructor of the child swf's document lcass I get null.
Why is this and how would I access the parent swf from the child document class if it shows as null?
ThanksThe constructor is running before the swf has been added to the stage of the parent. Use the Event.ADDED_TO_STAGE event in the document class of the swf being loaded, and once it fires trace parent.
-
Timeline code to document class code - best practices
I'm starting to put all of my code in the document class instead of on the main timeline, and I have a few questions. When I was using the timeline, everything was linear. It was easy to know when things would start and end because of how the playhead moves. With the document class, I noticed for the first time that functions are executed simultaneously if you call them one after the other. What would be the best way to make them execute in sequence? Let's say I have functions f1, f2, and f3. I suppose at the end of f1 I could call f2, and at the end of f2 call f3, or use event listeners, but is that the right way to do it? By the time you get to f3, aren't f1 and f2 still "open" because they haven't terminated?
do you want some appreciable time to transpire between executing f1,f2 and f3?
if yes, use a timer or timers. if no, then just call them sequentially. with few exceptions (mainly when loading some external (to flash) file executes code synchronously:
f1();
f2();
f3(); -
Class has be instantiated in document class but having issue..HELP
Guys,
I am making my way with AS3 in little steps and have hit a
road block. This is what I have:
I have a document class called "Document Class"
I have a custom class called "Game"
I have instantiated an object of "Game" class and I am able
to trace a class method which return a simple "HELLO".
within my Game class, I have a variable(type Array) called
"questions" as instance variable.
I would like to add questions to "questions" array by using
"Mutator" method, or count the current elements with the questions
array and return the total number of questions. I am unable to add
or access elements to the questions array.
Any help would highly be appreciated, please.First thing: you need to set the functions you're calling to
public, so that you have access to them outside of your class.
Second: you are initializing 'questions' to null. I made some
changes and it seems to work for me:
//////////////Game
Class///////////////////////////////////////////////
public function Game()
//this.questions = null;
this.correctAnswers = null;
this.userAnswers = null;
// SETQUESTION FUNCTION CAN ADD QUESTIONS TO THE QUESTION
ARRAY;
public function myArr():void
trace(questions.length);
public function AddQuestions(val:String)
this.questions.push(val);
trace(val);
} -
Accessing document class function within timeline
Hi have a very simple question,
(Bear with me I'm still quite new to as3 and some of my terminology may not be solid)
I want to access a function that is within my document class when a movie clip on the timeline has played to a specific point (being the end).
I have already been able to call another function from the document class at the top/root level (it is called to initialize all clips and buttons when you click on the "enter" button on the splash screen.
Problem is that I cannot call another function (in the document class) from a movie clip within a movie clip on the timeline. Is there an easy way to do this? I have considered writing a separate class for the movie clip and then adding it onto the movie clip (using the property panel). I don't really want to do it this way because I am already using a base class on that movie clip and 3 others that use a set of generic functions.>>I want to access a function that is within my document class when a movie clip on the timeline has played to a specific point (being the end).
Your document class should add a listener to the clip and the clip should dispatch an event when it's complete. You could dispatch your own event or use one of Flash's like Event.COMPLETE. Something like:
in clip
dispatchEvent(new Event(Event.COMPLETE));
and in your doc class
clipOnTimeline.addEventListener(Event.COMPLETE, classMethod);
>>I have already been able to call another function from the document class at the top/root level (it is called to initialize all clips and buttons when you click on the "enter" button on the splash screen.
You really should avoid mixing timeline and document class code. Better would be for your doc class to add a listener to the button and call a method within the class when it's clicked. -
NEED TO KNOW HOW CONVERT GIF FILE TO SYMBOL FROM DOCUMENT CLASS
ROBERT LEAHONG
COMPUTER PROGRAMMER / ASP Web Devloper
Hello,
I need to convert a GIF file (PICTURE) to a symbol (Button) From within The Document Class using ActionScript 3.0 .
Thanks in advance for your help.So you imported a .gif into the library and need to get to it from the document class? If that's the case you need to right-click the image in the library, select properties, select the ActionScript tab and then set it to export for ActionScript. Give it a class name - I'll use myGif for example. You'll see it will have a base class of BitmapData...
Then in your document class you can just instantiate it like:
var myImageData:BitmapData = new myGif();
You can turn it into a useable image that you can place on stage by putting it into a Bitmap object:
var myImage:Bitmap = new Bitmap(myImageData);
If you want to make a button out of it, ie make it clickable - stick it into a Sprite:
var mySprite:Sprite = new Sprite():
mySprite.addChild(myImage);
addChild(mySprite);
mySprite.addEventListener(MouseEvent.CLICK, clicked);
function clicked(e:MouseEvent):void
trace("clicked");
HTH -
ArchiveLink - creating a new document class - how?
Hello,
I want to store csv files on our archive via archive link.
But the file type that I need is not available in R/3.
Ok, I think here is where my solution could be found:
-> archive link -> basic customzing -> edit document classes
Document class: I add "CSV"
But what´s behind the MIME type of a web object.
What do I have to do to fill this field with something useful.
What is to implement behind?
Any help is appreciated!
Best regards
Dirkif you go throught there archive link creation in the archiveing process ...
FTWP is the comfiguration tcode for archive of DART extract ....
there Comtemporary Repository has to be created with document area-> here dropdown is there for for archieve link , for MIME ,, BFT ...etc ..
this will decide the file format .....
i am working in DART Exctraction project .....we use to create the archive link for that ......
normally in archiving processs all the files stored in csv only
Girish -
What is the difference between document class and normal class
Hi,
Please let me know what is the difference between document class and normal class.
And I have no idea which class should call as document class or call as an object.
Thanks
-Actionscript Developerthe document class is invoked immediately when your swf opens. the document class must subclass the sprite or movieclip class.
all other classes are invoked explicitly with code and need not subclass any other class. -
Archivelink - Document Class * - All docs stored with text/x-docType mime
Hi,
I have configured an archivelink document type (OAC2) to use document class *, ie it can accept any file and not restricted to a particular type. Document is being stored on archive server with a mime type of text/x-docType and therefore when you try retrieve it, SAP GUI isnt able to determine the mime type and only offers the 'Save As' dialog box, ie doesnt open in the SAP Viewer.
I have previously used this * configuration on another clients system and it works correctly, the file is stored with the correct mime type and therefore is retrieved correctly.
Any ideas why using the * config is forcing the mime type to text/x-docType?
Thanks,
MarkHi Mark
Transaction SPRO - SAP Reference IMG - SAP Netweaver - Application Server - Basis Services - ArchiveLink - Basic Customizing - Edit Document Classes
The very first entry will be * and the MIME type is by default text/x-docType. -
Document Class not work when I shift my MovieClip to 2nd Frame.
Hello,
All my content is at 1st frame of my FLA file...and I'm using Document Class... When I try to shift my content to 2nd frame, so I can use 1st frame for preloader.. but its not working...
This is my document class... Basically at 1st frame I'm loading external jpg image to a MovieClip..
Is it possible, I can **** my MovieClip and other content to 2nd frame of the timeline... ??? and Document Class work???
Thanks...
package com.ahmad.bg
//import all classes
import caurina.transitions.Tweener;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
public class MainClass extends MovieClip
//create variables
private var loader:Loader;
private static const IMAGE_PATH:String = "bgs/bg.jpg";
public function MainClass() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, stageResize);
//load external image
loader = new Loader();
loader.load(new URLRequest(IMAGE_PATH));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
pic.addChild(loader);
private function showImage(e:Event):void
try {
e.target.content.alpha = 1;
Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );
e.target.content.smoothing = true;
} catch (e:Error) { };
stageResize();
private function stageResize(e:Event=null):void
pic.x = 0;
pic.y = 0;
pic.scaleX = pic.scaleY = 1;
if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
pic.width = stage.stageWidth;
pic.scaleY = pic.scaleX;
} else {
pic.height = stage.stageHeight;
pic.scaleX = pic.scaleY;
pic.x = stage.stageWidth / 2 - pic.width / 2;
pic.y = stage.stageHeight / 2 - pic.height / 2;
bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);If you have code in your main class that references specific movieclips on the stage, they have to be on every frame you plan on using.
If you have a movieclip named "pic" on frame 2, but you are referencing it right away in the main class, which starts on frame 1, then it is looking for a movieclip that does not exist until you move it to frame 2
Maybe you are looking for
-
Dreamweaver CC impossible to use on MacBook Pro 13" ?
Hi, I have a 13" MacBook Pro 2012 (classic, not retina). I installed Dreamweaver CC yesterday to continue working on a site I'm developing (I had it on my Mac desktop but needed to work while away from home). I found the workspace layout of Dreamweav
-
What printers are compatible with Mac Book Pro's?
Hi All, Just looking to buy a printer for my Mac Book Pro but I don't know which ones are compatiable... Any suggestions or do you know where I can find a list of compatible printers?? Thanks
-
Re installing Final Cut Studio on my NEW Mac pro?
I originally purchased Final Cut Studio (on a G5 Power PC), Then installed the universal crossgrade, then installed Final Cut Studio 2. Now I have a New Mac Pro (Intel Chips) How do I go about reinstalling FCS? do I need the original serial key from
-
Moving Multiple Audio Transitions
This is a big one for me. I'm trying to apply and modify audio transitions to multiple tracks at the same time. First off it appears that I cannot move more than one transition at a time. Is this true? If it is it will slow me down a ton. I'm used t
-
Leopard clients on Panther Server - locked files/folders
Since I migrated my client systems to 10.5.2 I have a very annoying problem. I am running 10.3.9 server. Every Time I create a folder on the server I am locked out as a client. Can't even change the rights as a client! Have to go to the server and se