as3 externally loaded swf from network to control

2019-01-20 18:49发布

I have had several posts like this but I have not gotten down to the final answer so I put this image together to try and explain what I am trying to do. I AM SO CLOSE. if you can help me THANK YOU SOOOO MUCH. Worked days on this so far.

HOW DO I CONTROL CHILDREN INSIDE AN EXTERNALLY LOADED SWF FROM CODE IN ANOTHER EXTERNALLY LOADED SWF?

EDIT: Below is THEE code located in "ONE.swf" that I need help with. Just one or two lines I know but I JUST CANT get it.

function FunctionInOne()
{
var parentObj:Object = this.parent.parent as Object; //// GIVES ACCESS TO "Content.swf"
var TheStage:Object = this.parent.parent.parent as Object; //// GIVES ACCESS TO STAGE
trace(TheStage.stage.stageWidth);
trace(parentObj);  ///    [object MainTimeline]
trace(parentObj.ONE); /// [object Loader]
trace(parentObj.TWO); ///  [object Loader]

parentObj.alpha = .3; /// NOW I CONTROL THE ALPHA OF "Content.swf" from ONE.swf
var ControlTWO:Loader = parentObj.TWO; // GIVES ACCES TO LOADER TWO

ControlTWO.alpha = .3; // NOW I CONTROL THE ALPHA OF TWO.swf from ONE.swf


BUT HOW DO I GET ACCESS TO CONTROL THE CHILDREN IN "TWO.swf" from "ONE.swf"


var TWOchildren:MovieClip = MovieClip(TWO.content); // DOES NOT WORK
TWOchildren.ChildInTWO.alpha = .3;


var TWOchildren = TWO.content as MovieClip; // DOES NOT WORK
TWOchildren.ChildInTWO.alpha = .3;  // DOES NOT WORK

TWOchidren.FunctionInTWO(); /// DOES NOT WORK

}

EDIT: March 16th, 2012

I am able to access the swf TWO.swf from ONE.swf and control it's alpha with this line:

trace(MovieClip(parent.parent).ONE); 

But I need to control a child in that so I thought this following code would work but it doesn't:

MovieClip(parent.parent).ONE.TheChild.alpha = .3;

END EDIT---------------

I PUT THIS GRAPHIC TOGETHER TO HELP SHOW WHAT I AM TRYING TO DO. Here is another link to it if you can see it: http://mycontactcorner.com/sandbox/testing/ChildTwo.jpg

3条回答
SAY GOODBYE
2楼-- · 2019-01-20 19:07

MovieClip(parent.parent).function(); vise versa reference the movieclip.OtherChildmoviename.function();

this structure you can call a function from where ever or anymovie for better explanation check actionscript 2 as it uses the _root, this may make the above clearer

let us no how you go;

查看更多
狗以群分
3楼-- · 2019-01-20 19:18

Ok I found it!

var InsideConent:Object = this.parent.parent as Object; //// GIVES ACCESS TO "Content.swf"
var ItWorksNow:Sprite = MovieClip(InsideConent.TWO.content).ChildInTWO;  /// 

ItWorksNow.x = 333;  /// I can control property x
ItWorksNow.alpha = .3;  /// I can control the ALPHA! :)
查看更多
萌系小妹纸
4楼-- · 2019-01-20 19:20

Is see hard style of programming :]

to Your loaders add this , it should help:

import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
var loader:Loader = new Loader ( urlRequest , new LoaderContext(false, ApplicationDomain.currentDomain));

Second thing :

You should try access to content if You make sure that its loaded . So put start loading of second SWF to loading complete function of first SWF and You should trace(TWO.content) and see is there anything already loaded.

查看更多
登录 后发表回答