We Recommend

Essential ActionScript 3.0 Essential ActionScript 3.0
The book focuses on the core language and object-oriented programming, but also adds a deep look at the centerpiece of Flash Player's new API: display programming. Enjoy hundreds of brand new pages covering exciting new language features, such as the DOM-based event architecture, E4X, and namespaces--all brimming with real-world sample code.


Posted By

chrisaiv on 09/20/08


Tagged

as3 swfobject2


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

Winkyboy
vvarp


AS3: Pass variables using SWFObject2 and AS3


Published in: ActionScript 3 


For almost every Flash project I present on the web, I use SWFObject and with version 2 out, it's easier than ever to pass variables. This is how I collect variables using Flash CS3

  1. /*************************************
  2. This is how the SWF Object would look
  3. *************************************/
  4. <script type="text/javascript" src="js/swfobject.js"></script>
  5. <script type="text/javascript">
  6. var flashVars = { key: "AAA555XXXYYYZZZ", title: "This is my Title" };
  7. var flashParams = { menu: "false"};
  8. var flashID = { id : "swfContent" };
  9. swfobject.embedSWF("main.swf", "swfContent", "550", "400", "9.0.0", "expressInstall.swf", flashVars, flashParams, flashID);
  10. </script>
  11.  
  12. /*************************************
  13. Place this code in the Actions window of Flash CS3
  14. *************************************/
  15.  
  16. var APP_ID:String = getFlashVars().key;
  17. var title:String = getFlashVars().title;
  18.  
  19. function getFlashVars():Object
  20. {
  21. return Object( LoaderInfo( this.loaderInfo ).parameters );
  22. }

Report this snippet 

You need to login to post a comment.