Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

controlling external swf file timeline

New Here ,
Jun 28, 2016 Jun 28, 2016

Hi everybody

I have a simple question but I can't solve that my self and appreciate any help.

I have two frames:

1: two buttons to load different swf files in the second frame

2: the second frame in which the swf files are loaded. and of course there is a button to go back frame 1; and some buttons to control swf timeline;

so they're loaded in the second frame very well, and using the back button I can go back frame 1 as well,  but in the second frame I have some buttons to control the loaded swf, and have certain functions for them, but the buttons don't work

here is my code in frame 1:

1.JPG

import flash.events.MouseEvent;

import flash.display.Loader;

import flash.net.URLRequest;

stop();

var myLoader: Loader = new Loader();

load_btn.addEventListener(MouseEvent.CLICK, myLoad);

function myLoad(evt: MouseEvent): void

{

                gotoAndStop("loadingPage");

                myLoader.load(new URLRequest("test-movie.swf"));

                loader.addChild(myLoader);

}

load_btn2.addEventListener(MouseEvent.CLICK, myLoad2);

function myLoad2(evt: MouseEvent): void

{

                gotoAndStop("loadingPage");

                myLoader.load(new URLRequest("test-movie2.swf"));

                loader.addChild(myLoader);

}

and here is my code in frame 2:

2.JPG

import flash.events.MouseEvent;

import flash.events.Event;

addEventListener(Event.ENTER_FRAME, swfLoaded);

var currentSWF:MovieClip = MovieClip(loader.content);

function swfLoaded(evt:Event):void

{

               

function button_forward(e:Event):void{

                 currentSWF.nextFrame();

                  }

function button_rewind(e:Event):void{

                 currentSWF.prevFrame();

                  }

function button_pause(e:Event):void{

                 currentSWF.stop();

                  }

function button_play(e:Event):void{

                 currentSWF.play();

                  }

  }

back_btn.addEventListener(MouseEvent.CLICK, goHome);

function goHome(evt:MouseEvent):void

{

                removeChild(loader);

                gotoAndStop("home");

}

 

and there is no errors or warnings, etc. it just doesn't work

I can't find  out where my problem is.

Thanks for your help

TOPICS
ActionScript
294
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 28, 2016 Jun 28, 2016
LATEST

What is the object you target with the name "loader" ?

Which buttons are not working?  I see only three in your code, load_btn, load_btn2, and back_btn.

Whatever you are trying to do with that ENTER_FRAME listener is not likely going to do anything.  Do you realize what an ENTER_FRAME event listener does?  What it does is it continuously executes at the frame rate you set for the file.  Even then, all you have it doing is constantly declaring functions... nothing is executing in the event handler for that ENTER_FRAME function (Also, you should never nest named functions within functions).

If your intention is to wait until the external swf's are loaded then assign a listener to the loader and do not use an ENTER_FRAME event.  Then, assign listeners and functions to your control buttons the same way you do for the other three buttons.  The event handler functions do not need to be buried inside any other function.  You can assign the listeners for those buttons thru the event handler you will create for the Loader.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines