Solved

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

Posted on 2011-02-22
7
513 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adobe Presenter not Publishing Slide Theme 17 136
camtasia alternative that can record 3 hours video plus audio 24 145
Running Mp4 or Flash Video 1 148
Play RTMP without Flash 3 885
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. …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

732 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