A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: [RESOLVED] Using a swc movieclip to get a timeline

  1. #1
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312

    resolved [RESOLVED] Using a swc movieclip to get a timeline

    Hey FK,

    I am working on a project where the document class needs a timeline with at least 2 frames. This isn't that hard right? Create a fla, give it the frames I need and set the document class.

    But I can't/won't/don't-want to do that. (I'm using FlashDevelop and ANT. Screw the IDE... le sigh)

    I was hoping that I could create a swc that contained a MovieClip asset with the correct number of frames in it.

    Then I could have my main class extend that swc asset, and thus acquire the frames it had.

    But this isn't working

    Does anyone have any idea how I can use a swc asset to gain its timeline for the document class of a swf?


    Things I have tried:

    Actionscript Code:
    //SWC:
    TwoFrameMovieClip extends MovieClip // (has 2 frames in it)

    package {
        class Main extends TwoFrameMovieClip {
            public function Main () {
                trace(totalFrames) // says 1!!!
            }
        }
    }


    I also tried:

    Actionscript Code:
    //SWC:
    Main extends MovieClip // (has 2 frames in it)

    package {
        class Main extends MovieClip {
            public function Main () {
                trace(totalFrames) // says 1!!!
            }
        }
    }


    Neither work. However, I can get the trace statement from the first frame to display.
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Why not use composition instead of inheritance?

    Actionscript Code:
    package{
      public class Main extends Sprite{
        private var _timeline:MovieClip;
        public function Main(){
            _timeline = new TwoFrameMovieClip();
            addChild(_timeline);
        }
      }
    }

  3. #3
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    Thanks for the response!
    I can't use composition because then the document class does not have the frames.

    It's funny, there are two aspects:

    The first is that 'they' determine the length of my movie by the fps * totalFrames (of the main timeline)

    The second, being that 'they' know when to stop showing my swf when the main timeline hits the last frame or is stopped.


    So I literally need my pure AS3 project's document class to have a multi frame timeline without compiling with the IDE. (although I can create assets in the IDE)
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  4. #4
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    I'm sure anything you're trying to accomplish can be done with an instance of your 2-frame clip rather than extending it.

    If you're worried about knowing when a frame is hit, use addFrameScript()

  5. #5
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    Another issue with using composition, is that the main timeline still only has 1 frame.

    It is possible to inspect a swf (metadata...?) and find out how many frames it has. If I use composition, then the totalFrames is 1, and not however many frames are in my composited multi-frame movieclip.

    Also, addFrameScript() will not 'create' keyframes for me. So using that doesn't help either.


    Maybe (since i don't really think I can find a solution the way I want), I should focus on how I can modify a fla with ANT...
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  6. #6
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    Well here is another though concerning the automation aspect of my problem

    What if I use ant to open the fla, then tell it to run a JSFL script that correctly modifies the timeline in the way that I hope, save, compile, and keep moving? Could something like that be done?
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  7. #7
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    What is it you're trying to do?

  8. #8
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    Ha, well I think I made have found the answer with JSFL


    Like I said before, I need a swf that has a mutli frame timeline.
    This was a challenge because my project is pure AS3 (built in flashDevelop)
    One of the requirements for the client is to be able to give a swf with the right number of frames depending on the 'length' they expect. (this changes)
    One of the requirements I have for the project is to be able to use ANT to automate my builds.
    I didn't want to have to open a fla, change the number of frames and recompile.

    So I thought: JSFL can do some cool stuff, lets take a look at it.

    I setup my fla the way I needed it (setting the document class to the main class of my as3 project), and created a JSFL script that would remove all frames in the main timeline, create the correct number of frames I need and place a 'stop();' in the last frame and then publish.

    Using JSFL, I can have ANT automate this process, modifying the JSFL to have the correct fps and frames without me having to touch the IDE.

    It still seems strange to me that neither of my first expirements provided the result I was looking for, but I've found the solution (I hope ) that will work for me.


    Thanks for your replies. It helped me talk it out.
    Last edited by Baby Minion; 08-10-2011 at 03:56 PM. Reason: forgot to mention...
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  9. #9
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    I understand what you're trying to do, my question is how do you intend to use it. What is the purpose of these frames at runtime? Describe the problem that these multi-frame clips solve. If all you need are clips with varying numbers of empty frames, I highly suspect there are easier ways but I can't specify until I know what you're actually doing with them.

  10. #10
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    My client runs my swf in some bizarre environment. I believe they run swf after swf after video after swf (in no particular order). Their software determines when it is time to move to the next piece of content by listening for the main timeline to hit the last frame. Thus, if my swf has one frame, it can't calculate a length. But if I can get the main timeline to have the correct number of frames, my pure as3 project can be run in their software.

    I've gotten confirmation that they are expecting some kind of 'complete' event from their software which is 'watching' the main timeline. (the complete event is not something I code)

    Does that make sense?
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  11. #11
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Aaaahhh ok that makes sense. Ideally they'd have provided you with an event to call or you could override the currentFrame and totalFrame getters but I guess theirs Application Domain issues to consider.

    You've got my curiosity now which means I have to try it for myself but it seems either way you'd want an ANT/jsfl setup in there somewhere. I'd be interested to hear if you any success with that.

  12. #12
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    Overriding the getters for currentFrame and totalFrame won't work.

    I believe they look at the metadata about the swf for that value. I'm not even sure if they are loading my swf into another swf, or if they are loading my swf into some other wrapper software.

    I bet if I could get more detail from a technical person on their end I could find a way to fake it for them (without this stupid timeline thing).

    Maybe finding the crucial bit of how a wrapper software can track the timeline will get me to figure out how to fake it better... researching this has been difficult for me though.

    I'll keep plugging away. When I hit a solution I will post
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center