Solved

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

Posted on 2011-02-22
7
508 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
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.

744 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

14 Experts available now in Live!

Get 1:1 Help Now