?
Solved

calling a function on Hosting Flex App from loaded AS3 SWF

Posted on 2007-10-15
8
Medium Priority
?
2,072 Views
Last Modified: 2012-05-05
I have a flex application that uses SWFLoader to load an Actionscript3 SWF.
I want to have access from the loaded SWF to a global variable in the Flex application.
I expected to be able to do something like root.parent.root['variablename']  but it does not work.
Any ideas on how can I do this ?
alternativly can I call a global function on the hosting flex App and get an object as a result?

Thanks,
SnowFlake
0
Comment
Question by:SnowFlake
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Expert Comment

by:elsabartley
ID: 20079452
http://www.flexdeveloper.eu/forums/index.php/topic,173.0.html

This might help if not then try posting a question on there, the response rate is pretty good and they focus on just Flex.
0
 
LVL 10

Accepted Solution

by:
Savong earned 2000 total points
ID: 20079756
You might try referencing parentApplication, or Application.application.  Depending on context these may or may not work as you're expecting, but they should give you access to any public variables in the main Application MXML.
0
 
LVL 15

Author Comment

by:SnowFlake
ID: 20091395
elsabartley:
sorrt, i could not find it there.
if I won't find an answer here I might try posting there as well.

Savong:
What you say is interesting but being a beginer in FLEX I am not exactly sure how to us it.
I understand that you say that from the loaded swf I should get a handle to the application object of the hosting (parent) application and then use it to get to the public variabels but what would be the syntax  ?specifically of the second part - would it be something like handleToParentApp['varName']  ??

SnowFlake
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Expert Comment

by:Savong
ID: 20094489
Application.application is somewhat similar to _root in AS2.  The call might look like:
Application.application.varName

Though depending on the exact implementation other methods might be needed.
0
 
LVL 15

Author Comment

by:SnowFlake
ID: 20097861
took some trail and error but finally I got
root.parent.parent['parentApplication']['MyVariableName']
root.parent is the Flex SWFLoader
root.parent.parent is an mx.core systemManager
which had the parentApplication attibute which in turn has attributes for the global variables

Thanks for pointing me to the parentApplication Property.

for those reading this not understanding why I use ['parentApplication'] and not .parentApplication
its becuase otherwise the flash compiler complains about it. using the first syntax prevents the complaint.

SnowFlake.
0
 
LVL 19

Expert Comment

by:Gary Benade
ID: 20230750
0
 
LVL 15

Author Comment

by:SnowFlake
ID: 20318724
thanks for you additional input,
however:
1) as I indicated above I already have what I needed working
2) I am also aware of local connections but it is more complex.  I can not just ask the "host" to add a function and be able to call it. It also has the disadvantage (for my current needs) of beeing async.
3) the second link is for the other wa around ( host to hosted communications).

SnowFlake.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
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…
The goal of the tutorial is to teach the user how to how to record live broadcast.
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.
Suggested Courses

840 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