• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2078
  • Last Modified:

calling a function on Hosting Flex App from loaded AS3 SWF

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
SnowFlake
Asked:
SnowFlake
  • 3
  • 2
  • 2
  • +1
1 Solution
 
elsabartleyCommented:
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
 
SavongCommented:
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
 
SnowFlakeAuthor Commented:
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
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.

 
SavongCommented:
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
 
SnowFlakeAuthor Commented:
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
 
Gary BenadeCommented:
0
 
SnowFlakeAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now