cross scripting in as3
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: cross scripting in as3

Hybrid View

  1. #1
    Senior Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    885

    cross scripting in as3

    cross scripting is when you load an swf as a child and the child swf can use parent swf functions during runtime and also the parent can call child swf functions on runtime, im going to leave this here because it's useful when making 3d games, when you have a 3d swf you might want to load it up in another swf container to have more perspective and control over the 3d window.

    swf 1 name: swf.swf

    PHP Code:
    var my_var:String 'hello world';
    var 
    myBytes:ByteArray;
    var 
    new_player:Loader = new Loader();
    var 
    mp_package_ready:Boolean false;
    function 
    load_init_player(){
    new_player.contentLoaderInfo.addEventListener(Event.COMPLETEinit_player_loaded);
    new_player.load(new URLRequest("var_reader.swf"));
    }
    function 
    init_player_loaded(e:Event):void{
    var 
    myBytes=e.target.bytes;
    mp_package_ready=true;
    loader.loadBytes(myBytesloaderInfoStuff);
    new_player.contentLoaderInfo.removeEventListener(Event.COMPLETEinit_player_loaded);
    }
    load_init_player();

    var 
    loader:Loader = new Loader();
    var 
    loaderInfoStuff:LoaderContext = new LoaderContext(falseApplicationDomain.currentDomainnull);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETEcached_mp_loaded);
    loaderInfoStuff.allowLoadBytesCodeExecution true
    loaderInfoStuff.allowCodeImport true;

    function 
    cached_mp_loaded(e:Event):void{
    var 
    loaded_mc e.target.content as MovieClip
    addChild(loaded_mc);
    loaded_mc.callit();
    loaded_mc.readParent();

    swf 2 name must be: var_reader.swf
    PHP Code:
    trace('hey');
    function 
    callit(){
    trace('hey from callit');
    }
    function 
    readParent(){
    trace(MovieClip(root.parent).my_var);


  2. #2
    Senior Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    885
    addEventListener(MouseEvent.MOUSE_MOVE, showLD2);
    function showLD2 (e:MouseEvent):void {
    MovieClip(root).LD2nd.alpha=(MovieClip(root).mouse Y-MovieClip(root).LD2nd.y)/MovieClip(root).LD2nd.height
    }

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