Document Class vs Timeline code differences...

I'm trying to hunt down some kind of class conflict I seem to be having when using TweeLite easing and found out the same code that errors in a document class works fine if I place it in the timeline.
Example - this works in frame one of the timeline:
import com.greensock.TweenLite;
import com.greensock.easing.*;
TweenLite.to(obj, 1, { x:200, ease:Bounce.easeOut } );
If however I make a very simple document class like so:
package
      import com.greensock.TweenLite;
      import com.greensock.easing.*;
      import flash.display.MovieClip;
      public class Main extends MovieClip
           public function Main()
                TweenLite.to(obj, 1, { x:200, ease:Bounce.easeOut } );
I get an error when compiling:
1119: Access of possibly undefined property easeOut through a reference with static type Class.
So what's the differences between using a document class and timeline code?

Odd... seems to have been a caching issue. I renamed the class, rebooted, and deleted ASO files and now it's working. Funny thing is that I never need to delete ASO files before... any thoughts on why this would stay cached?
And, after rebooting I can make changes and don't need to delete ASO files either.
Thanks!

Similar Messages

  • Problem accessing function within my Document Class

    Hi there,
    I have a Document Class which dynamically adds a MovieClip to
    my FLA. The MovieClip is in the FLA library and has "Export for
    ActionScript" setup for it and this is how I'm accessing the
    MovieClip from my Document Class.
    The problem is that when the MovieClip is finished (it has a
    timeline animation and a stop() method applied to the last frame of
    the animation) I want it to call a function that is placed within
    my Document Class, but simply calling the function (e.g.
    displayEnterButton();) is displaying an error of....
    1180: Call to a possibly undefined method
    displayEnterButton.
    Can anyone help here, I'm sure it's a simple issue to
    resolve.
    Many thanks!
    Kind regards,
    M.

    Hi,
    I've managed a work around to this.
    Basically, in my Document Class after the code that adds the
    MovieClip to the Display List, I then setup a Timer that called a
    function every 100 milliseconds. This function would then check the
    current frame of the loaded MovieClip. If the current frame of the
    MovieClip was equal to the last frame of the MovieClip then I would
    know the animation had finished and would call the next function I
    needed.
    I've pasted the code below in case anyone was interested....

  • 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();

  • 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?
    Thanks

    The 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.

  • 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 Developer

    the 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.

  • Execute functions in document class when main timeline reaches a frame

    Hi,
    I have 3 functions in my main document class that I want to execute when the main timeline reaches a particular frame number.
    how do I do that?
    see the code and comments
    public function mainClass()
    //stage declaraction
    stage.align = StageAlign.TOP_LEFT;
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.addEventListener(Event.RESIZE, stageResized);
    //wrap these next 3 lines in an if statement that says if maintimeline currentframe = x
    position();
    loadXml();
    initArrowButtons();
    slideTimer = new Timer(timer_delay);
    slideTimer.addEventListener(TimerEvent.TIMER, nextSlide);

    It's still undocumented, but something like this would do it:
    package
        import flash.display.MovieClip;
        public class FrameScript extends MovieClip
            public function FrameScript()
                addFrameScript( 3, frameFour );
            private function frameFour():void
                trace( "you have reached Frame 4" );
    You can test this as a documentclass.

  • 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.

  • 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.

  • 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

  • Document Class Error

    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;

  • 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.

  • 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.

  • Organising document class?

    Hi team,
    I am using a document class for a project to keep the code off the main timeline - only problem is now my document class is running to almost 2000 lines of code and becoming unwieldy to scroll through and find stuff.  Is there any way I can better organise this? Or should I be building in some other way?
    I am really not very sure on how classes actually work.  I have got this document class working but that is about as good as it gets. Any help would be greatly appreciated.
    cheers
    Sub

    When you are getting into thousands of lines of code, there is not alot you can do to avoid having to scroll thru it to find things, though you can do things to reduce the amount of scrolling needed. 
    What you could do is go thru the code and organize it into functional sections.  To aid in the need to scroll to find things, you can make use of keywords as comments in combination with the Find tool (the magnifying glass in the toolbar), and use it to jump to sections.
    You could probably break it all down into separate class files, but then it might be even moreso unwieldy for you to have to remember which file you need to look at for different things.  Still, for major functional divisions this can be useful.

  • Document Class with Flash Lite 4.0

    I'm developing for Flash Lite (4.0) for the first time and I see that in the properties panel the Document Class section is grayed out. Does this mean that Flash Lite doesn't utilize a Document Class? If so, am I unable to use any external classes? I'm not going to have to code on the timeline am I? (shudder)
    I've noticed that I can set a Document Class in the Actionscript Advanced Settings, will that work? Why is it not available through the properties panel?
    Thanks for any help.

    im wondering the same thing.
    my first thought is to include a .as class through a timeline include statement, kind of like as2 practices

  • Document class Error #2136

    Hi, in Flash CS3 I've this DocumentClass:
    package {
        import flash.display.MovieClip;
        public class DocumentClass extends MovieClip {
            public function DocumentClass() {
                trace("document class created");
    This actually works, but I want to have the possibility to re-instance the DocumentClass (because I want to restart a game and the Main class is the DocumentClass).
    In the first frame I have:
    import flash.events.MouseEvent;
    btn.addEventListener(MouseEvent.MOUSE_DOWN, restart);
    function restart(evt:MouseEvent){
        var d = new DocumentClass();
    But this code (I simplified my situation, but the result is the same) throws an error:
    Error: Error #2136: The SWF file  file:///E|/Documents%20and%20Settings/Pepper/My%20Documents/FlashDevelopment/PepperGame.s wf  contains invalid data at DocumentClass/restart()/frame1()
    What can I do to restart my game by calling the DocumentClass point of entry? Is this possibile?
    Regards and thanks to everybody.

    When you apply a DocumentClass to an FLA, the code becomes a part of that document (just like putting the code on the first frame of the timeline).  You aren't able to say "new DocumentClass()" in your code because it's essentially telling your application to create itself.  Instead, you have two options.  Firstly, add a function in your DocumentClass called "reset".  Add in this function all the things that need to be reset (score, lives, position of objects).  When you want to start the game over, you can just call the reset() function.
    If you really want to "refresh" the whole SWF, you'll want to build a second SWF (a "shell") that acts as a container for your game.  It would basically just load in the game SWF (and maybe save any global information).  When you want to restart the game, just reload the SWF.

Maybe you are looking for

  • Envy 100 D410a HP Am I being difficult?

    So approximately a month ago I purchased an Envy 100 d410a from the HP home store in the US.  Upon receiving it, I found it to work great except for the front cover door refused to go down when the printer went into standby.  I went to these forums a

  • Failover Cluster networking issue

    Normally when configuring a SQL cluster you put the communication to the shared storage (usually a SAN) on a separate network, and so your config looks something like this (long live ms paint!): So in this example the 192.168.100.0/28 subnet is used

  • Why sxi_cache has disabled cache update button?

    I have checked 2 ECC6.0(ABAP+JAVA). On sxi_cache I see the the message" cache content is obsolete". However, when trying to update the cache, I find that button called "refrsh cache delta/complete" disable for both ECC6. Why? Thanks and points.

  • Adobe Reader XI "not responding" Windows 7.

    Everytime I try to open a document with Adobe it freezes and gives me the "not responding" message.

  • Nokia Lumia 800 Strange Behavior

    Hi all, I do have problem, often my lumia it seems on and fully working but it is impossible to receive call, it is enough to touch a button and all come back to work normally. This is really annoying, Any idea what will be the reason? Phone is updat