Hey,
Let me explain the situation that has been driving me crazy the last couple of hours. I have 2 different swf files with their own separate document classes. My first SWF file is main.swf and it’s document class is called Main.as (its the main container that loads in external swfs). The file being loaded into main.swf is called step1.swf and it’s document class is called Step1.as. I have a next button in step1.swf that when clicked needs to tell the document class controlling my main.swf (ie Main.as) to load in the next external swf. However I don’t know how to call a function in one document class to from another document class. And I don’t know if that fact the swf calling the function being loaded into the other makes this situation more complicated. I’ve looked around but I cant seem to find the answer anywhere. Basically I need these two separate document classes to communicate between one another.
Here is the code for Main.as (the doc class for the container SWF):
package
{
import flash.display.*;
import flash.events.*;
import flash.net.*;
import PreLoader;
public class Main extends MovieClip
{
public var swfIndex:int;
private var _preloader:PreLoader;
public function Main()
{
swfIndex = 1;
swfNavigation(swfIndex);
}
public function swfNavigation(index:*):void
{
switch(swfIndex) {
case 1:
trace('step 1');
_preloader = new PreLoader("step1.swf");
addChild(_preloader);
break;
case 2:
trace('step 2');
_preloader = new PreLoader("step2.swf");
addChild(_preloader);
break;
case 3:
trace('step 3');
break;
case 4:
trace('step 4');
break;
case 5:
trace('step 5');
break;
}
}
}
}
And the code for Step1.as (needs to call swfNavigation function in Main.as):
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class Step1 extends MovieClip {
public function Step1() {
nextBtn_mc.buttonMode = true;
nextBtn_mc.removeEventListener(MouseEvent.CLICK, nextQuest);
}
private function nextQuest(event:MouseEvent):void
{
swfNavigation(2); //Trying run function in other class
}
}
if someone can show me how to get swfNavigation() to run from the other class I’d greatly appreciate it or if you can explain to me a better way to do what I am trying to achieve that would work too. Thanks in advance guys.