Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to set swfobject parameters in AS 3.0?

Community Beginner ,
Aug 28, 2009 Aug 28, 2009

Hello All,

I have a flashGallery.swf file that I am loading into my flash site. I need to set the parameters for the xml, content, and php script paths as well as set the width and height for the swf. The parameters were originally set in the HTML file like so:

<script language="javascript" type="text/javascript">
var so = new SWFObject("flashgallery.swf", "gallery", "425", "320", "8"); // Location of swf file. You can change gallery width and height here (using pixels or percents).
so.addParam("quality", "high");
so.addParam("allowFullScreen", "true");
so.addVariable("content_path","http://www.flickr.com/photos/thestoryboxallstar/"); // Location of a folder with JPG and PNG files (relative to php script) or a link to Flickr photostream (for example "http://www.flickr.com/photos/username/" or "http://www.flickr.com/photos/username/sets/setid/").
so.addVariable("color_path","default.xml"); // Location of xml file with settings.
so.addVariable("script_path","flashgallery.php"); // Location of php script (not requred if you work with Flickr).
so.write("gallery");
</script>

How do I set these in AS 3.0?

Thanks, Smart People

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 28, 2009 Aug 28, 2009

That is JavaScript, not ActionScript... Do you mean how do you access the passed in FlashVars in AS3? If so then you use loaderInfo.parameters like so:

var contentPath:String =  loaderInfo.parameters.content_path;

etc...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 28, 2009 Aug 28, 2009

@dmennenoh thanks for your response.

i think i see what you mean about a flashvar, but i am loading a flashgallery.swf, into a histroyPage.swf, into a content.swf, in a flashsite.swf onto on HTML page. can i pass flashVars via html for that embedded swf in the one HTML doc that contains my master file??? i thought that if i loaded the swf that works on it's own it would work fine embeded but i guess somewhere, somehow i need to tell the swf where to find the xml, php, and images for the slideshow and that's what the javascript is doing. but since it doesn't have it's own HTML page and it's living 3 swfs deep on a central HTML page... can i even send flashVars data to it?? or can i send the flashVars data via the AS... directing it to the .xml, .php. and www.images.com spots where the code to populate that flashgallery.swf is???

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 28, 2009 Aug 28, 2009

The incoming FlashVars, passed in from SWFObject will be available in the main swf, the one embedded by SWFObject itself. There are various ways to then make those variables available to other loaded swf's. Personally, I would probably use a singleton class - I use them alot for exactly these kinds of things. If you're unfamiliar a good reference is: http://www.gskinner.com/blog/archives/2006/07/as3_singletons.html - I like the second method outlined there - using a class outside the named package as a key. Essentially, you use the singleton as a simple data store - instantiate it in the main movie and set data in it using the info from the incoming flashvars. Then have your other movies also instantiate it - because it is a singleton it will be the same object - and they can then call some methods within it to get at that data. It's really a lot simpler than it sounds, and is a good method to use when you want some 'global' data to be available.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 28, 2009 Aug 28, 2009
LATEST

@dmennenoh  Thanks again.. and honestly, this Singleton package business is way over my head . But I can try it! Over all, it kind of makes sense... BUT I am not using any packages on my page. I haven't got into using packages yet . Can I just add it to my code right after the imports or should i make an .as file for it and link that class to my masterfile?

Once I write this code and link it properly. How do I set it up in the HTML? AND how do I instantiate it in the 3 deep flashgallery.swf? And do I need to also instanitate it in the 3 swfs before it for it to work properly?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines