Solved

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

Posted on 2011-02-22
7
511 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

860 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