Jump to content
Search Community

Var doesn't work if I load external swf via SWFLoader

ngrinchenko test
Moderator Tag

Recommended Posts

What properties of SWF loader do I have to use to target loaded content?

Here is the block of code which used to work on the main timeline:

howTo_mainInfo.JTVs.JTV_SatelliteCenterpiece_btn.addEventListener(Mous eEvent.CLICK, JTV_SatelliteCenterpiece_PlayVideoPopUp);

function JTV_SatelliteCenterpiece_PlayVideoPopUp(event:MouseEvent): void {
sourceVar="howto_popups/jtvs18w07_LG30.flv";
gotoAndPlay("flv_pb");
}

 

Then I moved everything to an external SWF file and the var doesn't work anymore.

Ideally I would like to keep the code in the external SWF file but can't figure out how to make it to access the var on the main time line.

 

Here is my issue in a bit more details:

 

 

I have a set up with two pages or labeled sections on the main timeline. I brake the code corresponding to actions happening in each page/labeled section. On first page there is a var specified for each button

var sourceVar:String;

Then each button uses this var to load a video into FLV player (player itself is constructed in the second page/labeled section).

function JTV_SatelliteCenterpiece_PlayVideoPopUp(event:MouseEvent): void {
sourceVar="howto_popups/jtvs18w12_LG30.flv";
gotoAndPlay("flv_pb");
}

 

where "flv_pb" is the label for the second page/labeled section. On this second page/labeled section there is an FLVPlayback component named "SWF_flv2" which uses this var

SWF_flv2.source = sourceVar;

 

All above works. My problem is that I decided to load externally all the items (image buttons) into the first section. So I saved them as an external SWF file, with all the code in that external swf file.

Then I link the buttons to section "flv_pb" this way:

function JTV_SatelliteCenterpiece_PlayVideoPopUp(event:MouseEvent): void {
MovieClip(parent.parent.parent).sourceVar="howto_popups/jtvs18w07_LG3 0.flv";
MovieClip(parent.parent.parent).gotoAndPlay("flv_pb");
}

 

The link to the "flv_pb" section works, which tells me that the set up with "MovieClip(parent.parent.parent)." is appropriate.

However the code as before with the set up of (still being in the external swf file):

sourceVar="howto_popups/jtvs18w12_LG30.flv";
gotoAndPlay("flv_pb");

 

works as well, I am not sure why?

 

The problem seems to be in the var

I have an error message 1120: Access of undefined property sourceVar

It is referencing the code in the second page/labeled section "flv_pb"

SWF_flv2.source = sourceVar;

 

What are my actions? I kept the code in the external swf file. Should I move it to the main timeline if it is possible? Should I only reference the var in the main time line?

Should all the code be kept in the beginning of the time line, rather be sectioned into the sections?

Link to comment
Share on other sites

Sorry, but I can't really follow this explanation.

 

It appears the following code

 

 

function JTV_SatelliteCenterpiece_PlayVideoPopUp(event:MouseEvent): void {
   MovieClip(parent.parent.parent).sourceVar="howto_popups/jtvs18w07_LG3 0.flv";
   MovieClip(parent.parent.parent).gotoAndPlay("flv_pb");
}

 

works to target a var on the main timeline of the parent swf from the child (loaded) swf.

 

 

it sounds to me like the problem happens when you try to target a var in another frame of the parent swf. I would suggest you put all code on frame 1 of the parent swf. If a var is declared on frame 2, assets that are loaded on frame 1 aren't going to know what it is.

Link to comment
Share on other sites

Hi,

Thanks for answering my post. I know I get lost in the explanation. I assembled a simple sample file with all the code. I am not able to provide a video due to the size restrictions. I trust you would have some sample FLV file which you cam place instead.

 

I believe the problem is with the var specification

var sourceVar:String;

in the child swf file

and the var in the second labeled section of the parent swf file.

SWF_flv2.source = sourceVar;

please let me know how my code can be corrected?

Link to comment
Share on other sites

Hmm, I thought you were using a SWFLoader? I looked at your file and I see an FLVPlayback component and no mention of any LoaderMax-related code.

 

We really have to focus our attention on support related to the GreenSock tools. It is very difficult to assess how these files are working that load movies that set variables in different swfs and jump back and forth between frames.

 

If you think your sourceVar isn't being set properly I would start by putting

 

trace(sourceVar)

in the code on the frame labeled "flv_pb"

 

Should all the code be kept in the beginning of the time line, rather be sectioned into the sections?

 

Yes, this will help alleviate problems now and in the future.

 

---

 

I wish we could be of more help, but again we have to really focus on helping folks with the GreenSock code and we can't do a lot with trying to troubleshoot the architecture of complex projects :(

Link to comment
Share on other sites

Thanks for your help. I used LoaderMax almost everywhere in my project, It skipped my attention that it was an FLV play back feature. I automatically assumed that it was LoaderMax as well. Sorry that you had to look at the issue unrelated to greensock and thanks for the general suggestion on the code arrangement.

Thanks for your help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...