Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Results 1 to 4 of 4

Thread: fileLoaded Method

  1. #1
    Junior Member Settled In olicorse is on a distinguished road
    Join Date
    Feb 2009
    Posts
    3
    Rep Power
    0

    fileLoaded Method

    amazing Flash templates
    Hi guys,

    I've tried creating a preloader for an external swf that I've made.

    So far I've used the code:

    ar req: URLRequest = new URLRequest("Whole_movie.swf");
    var loader:Loader = new Loader();

    function fileLoaded(event:Event):void
    {
    addChild(loader);
    }

    function preload(event:ProgressEvent):void
    {
    var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
    preload_txt.text = String(percent) + "%";
    }

    loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, fileLoaded);

    loader.contentLoaderInfo.addEventListener(Progress Event.PROGRESS, preload);

    loader.load(req);

    However, the video starts playing in the background before it is fully loaded so when the view actually starts watching it, it is already a significant amount of the way through. I have been advised to put a stop(); at the beginning of the swf, which I have done and then overide this with MovieClip(loader.content).play(); in the method 'fileLoaded' just before the addChild(loader);

    I know virtually nothing about Actionscript 3 though and so I don't know where to insert this. I've tried in numerous places and keep getting the following output: "TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@2aa33481 to flash.display.MovieClip.
    at Preloader_fla::MainTimeline/fileLoaded()"

    Can someone copy and paste the existing code and show me exactly where to insert MovieClip(loader.content).play(); please?

    Thanks in advance!

    Oli

  2. #2
    Moderator Moving My Stuff To The FlepStudio tem is on a distinguished road tem's Avatar
    Join Date
    Jan 1970
    Posts
    640
    Rep Power
    41

    Re: fileLoaded Method

    Hi!
    it should work even without writing stop() in the loaded swf in this way:
    Code:
    function fileLoaded(event:Event):void
    {
          var movie:*=loader.content;
          var clip:MovieClip=movie;
          clip.gotoAndStop(1);
          addChild(clip);
          clip.play();
    }

  3. #3
    Junior Member Settled In olicorse is on a distinguished road
    Join Date
    Feb 2009
    Posts
    3
    Rep Power
    0

    Re: fileLoaded Method

    Hi,

    Thanks for your response. Unfortunately it didn't work, it just outputted this message:

    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@28506781 to flash.display.MovieClip.
    at Preloader_fla::MainTimeline/fileLoaded()

    A guy in another forum said this was because I was trying to load an Actionscript 2 swf into an Actionscript 3 file. He also said it was really hard to get around this and probably more trouble than it's worth.

    Any ideas on how to do this simply?

    Cheers!

  4. #4
    Junior Member Settled In fakecopper is on a distinguished road
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Re: fileLoaded Method

    The reason for your problem is that your movie starts playing already when it is loading.

    2 things you need to do.

    1. convert your loader content into a movieclip//MovieClip(loader.content)
    2. then make it start from frame 1 when loading is completed //gotoAndPlay(1)

    just add the new line to your fileLoaded function:

    function fileLoaded(event:Event):void
    {
    addChild(loader);
    MovieClip(loader.content).gotoAndPlay(1);//add this new line
    }

    I had the same problem a few days ago, that's how I solved it. Hope it works for you too.

+ Reply to Thread

Similar Threads

  1. curveTo Method with Actionscript 3.0
    By Flep in forum Tutorials
    Replies: 1
    Last Post: 23-01-10, 17:18
  2. mailTo method
    By Flep in forum Tutorials
    Replies: 11
    Last Post: 06-01-10, 19:16
  3. New HitTest method of Actionscript 3.0
    By Flep in forum Tutorials
    Replies: 5
    Last Post: 25-08-09, 16:13
  4. Actionscript 3.0 perlinNoise method
    By Flep in forum Tutorials
    Replies: 6
    Last Post: 05-12-08, 10:05
  5. getBounds method
    By Flep in forum Tutorials
    Replies: 0
    Last Post: 20-12-07, 06:38

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Optimization by vBSEO