Solved

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

Posted on 2011-02-22
7
514 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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.

726 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