lundi 29 juin 2015

Flash Programming ActionScript3, double import swf to the main Stage from another class

Let me explain my situation: We have a file named Main.fla which links to the class MAIN( it's included in the MAIN.as file). I also have a secondary User.as file with a User class.

I managed to import a classic swf button to my stage from the User.as class but i'm finding trouble on adding the pop up window, when the button is clicked. Here are the codes:

MAIN.as

import flash.display.*;
import flash.net.*;
import flash.events.*;

import User;                          //Importing our User class

public class MAIN extends MovieClip
{


    public function MAIN() 
    {
            var k = new User();   
            k.logocons(this);      //This function is made on User class and 
                                   //it takes a stage:Object as definition
    }
}

User.as

import flash.display.*;
import flash.net.*;
import flash.events.*;

public class User extends MovieClip                                             
{

    var myLoader:Loader = new Loader();                                         


    public function User()
    {
      var url:URLRequest = new URLRequest("C:/Project/Button.swf");
      myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
      myLoader.load(url);
    }

    function swfLoaded(event:Event):void 
    {
        myLoader.x = 50;                                       
        myLoader.y = 50;                                        
    }

    public function logocons(stage:Object)                                  
    {                                                                           
        stage.stop();
        stage.addChild(myLoader);
    }
}

This works normally so far When i test the file the Button works perfectly

What i want now is when the button is clicked to show at my MAIN.Stage a pop up window which is also in the same folder named PopUp.swf.

I tried really many things but i couldn't find how i can access the MAIN.stage from another class.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire