Solved

AS3 Communication between contents of 2 swf (one is charged in UIloader component)

Posted on 2011-02-22
7
509 Views
Last Modified: 2012-05-11
Hello,
(sorry for bad english and just lurning as3)

In my first swf,
I charge a second swf in UILoader,
this second swf contains a button,
myUILoader name is : BOITE_menu4
This is ok

///// CODE /////
loadDOC2("secondswf.swf");
BOITE_menu4.scaleContent = false;
function loadDOC2(DOC2):void
{
var UrlDOC2:URLRequest = new URLRequest(DOC2);
BOITE_menu4.load(UrlDOC2);
}
////////////////////

In my second swf,
there is my button, (his name is "btn_menu4")
I would like this button command something in my first swf ex : gotoAndStop ("blabla"),
But it doesn't fonction :

///// CODE /////
stop();
btn_menu4.addEventListener(MouseEvent.MOUSE_UP, vbr_btnMenu4);
function vbr_btnMenu4(evt:MouseEvent):void
{
gotoAndStop("myreperonswf1");  //-> of course myreperonswf1 is not found only reper in swf2 can be find
trace ("blabla");  //-> yes it's ok
trace(this.stage); //-> yes it's ok gives "Stage"
trace(this);  //-> yes it's ok gives "MainTimeline"
}
///////////////////

Help...
I think I have a probleme with the path... I tryed "MovieClip(this).gotoAndStop("CLEFmenu4");"

I Need your informations. How fonction pathes in as3 in this case...
0
Comment
Question by:missouris
  • 4
  • 2
7 Comments
 

Author Comment

by:missouris
ID: 34955772
Thank your far your welcome :-) ...
0
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 500 total points
ID: 34959517
Well the easiest way would be not to use gotoAndStop(...) on secondswf.swf, but to use parent.gotoAndStop(...) to gotoAndStop in the parent. As I don't have the code of your project, you might need to repeat "parent." a few times. I'd suggest using the debugger to find out how many "parent." you need (something like this "parent.parent.parent.gotoAndStop(...)").

If you want to do it the really nice way from an architectual view, I'd suggest to throw an Event with "bubbling" turned on. In this approach you would load the second swf in your main swf and as soon as it's loaded you would "addEventListener("myStopEvent", onStopEvent);" and inside the onStopEvent function you would do "gotoAndStop".

If you need any more assistance with any of these approaches, feel free to ask.
0
 
LVL 14

Expert Comment

by:tomaugerdotcom
ID: 34962111
this.root.parent.root.gotoAndStop();
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:missouris
ID: 34973236
ChristoferDutz, tomaugerdotcom,

I thank you for your answers, "this.root.parent.root.gotoAndStop();" doesn't fonctionned,
you are all right : to be sure to catch the path I'm going to try to throw an addEventListener...
as soon as possible I give you the answer back
hope the solution will help other persons just lurning the new code as3.
0
 
LVL 14

Expert Comment

by:tomaugerdotcom
ID: 34973454
desole - je n'avais pas teste ma suggestion. (les accents ne fonctinnent pas sur mon clavier lol!)

A+
0
 

Author Closing Comment

by:missouris
ID: 35004650
The answer is clear, with new idea for me.
As I'm lurning this code AS3, just begining, I need time to try new ideas, maybe i'll come back to  ChristoferDutz for following questions/help.
-Missouris-
0
 

Author Comment

by:missouris
ID: 35004689
Merci tomaugerdotcom pour l'idée ! Tout est bon à prendre/essayer décortiquer quand on débute comme moi dans un nouveau code :-). J'ai l'impression d'être un nouveau né devant l'as3 après l'as2, pour l'heure c'est très limitant.
Donc mon accent français se repère à l'écrit... hum. Plus les fautes des textes rapidement tapés le soir.
Peut-être que je reviens vers tous les deux si mes bricolages numériques n'aboutissent pas. Bonne journée.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to how to record live broadcast.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now