[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

FlashVars in HTML not being recognized in AS2

Posted on 2009-04-24
7
Medium Priority
?
862 Views
Last Modified: 2013-11-11
Hello,

In short, I added this to my html file:
    <param name="FlashVars" value="myvariable=photos" />

and this to my AS2 .fla file:
     var fname:String = _root.myvariable;

and fname is "undefined" (I display it with _root.myText_txt.text). Can you see what I'm doing wrong?

Thanks!! :)

<!-- HTML generated by Dreamweaver CS3:-->
 
<script language="javascript">
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			'width', '800',
			'height', '600',
			'src', 'SlideShowGood',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', 'SlideShowGood',
			'bgcolor', '#ffffff',
			'name', 'SlideShowGood',
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'SlideShowGood',
			'salign', ''
			); //end AC code
	}
</script>
<noscript>
	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="600" id="SlideShowGood" align="middle">
	<param name="allowScriptAccess" value="sameDomain" />
	<param name="allowFullScreen" value="false" />
    <param name="FlashVars" value="myvariable=photos" />
	<param name="movie" value="SlideShowGood.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed src="SlideShowGood.swf" quality="high" bgcolor="#ffffff" width="800" height="600" name="SlideShowGood" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
	</object>
</noscript>
 
//
//Actionscript 2.0 in Flash CS3:
import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
var fname:String = _root.myvariable;
 
 
fname = fname+".xml";
 
myShowXML.load("photos.xml");
 
 
 
myShowXML.onLoad = function() {
	_root.myWidth = myShowXML.firstChild.attributes.width;
	_root.myHeight = myShowXML.firstChild.attributes.height;
	_root.mySpeed = myShowXML.firstChild.attributes.speed;
 
	_root.myImages = myShowXML.firstChild.childNodes;
	_root.myImagesNo = myImages.length;
 
	createContainer();
 
	callImages();
};
 
 
function createContainer() {
	_root.createEmptyMovieClip("myContainer_mc",1);
 
	myContainer_mc.lineStyle(0,0x000000,100); // 1st parm is width of border
	myContainer_mc.lineTo(_root.myWidth,0);
	myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
	myContainer_mc.lineTo(0,_root.myHeight);
	myContainer_mc.lineTo(0,0);
 
	myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
	myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;
 
}
 
function callImages() {
 
	_root.myMCL = new MovieClipLoader();
	_root.myPreloader = new Object();
	_root.myMCL.addListener(_root.myPreloader);
 
	_root.myClips_array = [];
 
	_root.myPreloader.onLoadStart = function(target) {
 
//		_root.createTextField("myText_txt",_root.getNextHighestDepth(),0,0,100,20);
		_root.createTextField("myText_txt",_root.getNextHighestDepth(),750,60,100,20);
		_root.myText_txt._x = (Stage.width-_root.myText_txt._width)/2;
		_root.myText_txt._y = (Stage.height-_root.myText_txt._height)/2;
		_root.myText_txt.autoSize = "center";
 
		_root.myText_txt.text = fname; // keep for debugging
	};
 
	_root.myPreloader.onLoadProgress = function(target) {
 
//		_root.myText_txt.text = "Loading.. "+_root.myClips_array.length+"/"+_root.myImagesNo+" Completed";
 
	};
 
 
	_root.myPreloader.onLoadComplete = function(target) {
 
		_root.myClips_array.push(target);
		target._alpha = 0;
 
		if (_root.myClips_array.length == _root.myImagesNo) {
			_root.myText_txt._y = myContainer_mc._y + myContainer_mc._height;
			_root.target_mc = -1;
			moveSlide();
			myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);
		}
 
	};
 
	for (i=0; i<_root.myImagesNo; i++) {
 
		temp_url = _root.myImages[i].attributes.url;
		temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());
 
		_root.myMCL.loadClip(temp_url,temp_mc);
	}
}
 
 
function moveSlide() {
 
	current_mc = _root.myClips_array[_root.target_mc];
	new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);
 
	_root.target_mc++;
 
	if (_root.target_mc>=_root.myImagesNo) {
		_root.target_mc = 0;
	}
	
//	_root.myText_txt.text = _root.myImages[target_mc].attributes.title;
	next_mc = _root.myClips_array[_root.target_mc];
	new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
 
}

Open in new window

0
Comment
Question by:anniengodis
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:Dreammonkey
ID: 24230189
could you try _level0.myvariable instead of _root?
0
 

Author Comment

by:anniengodis
ID: 24230230
Thanks for the quick response!

But that didn't do it...

0
 
LVL 8

Accepted Solution

by:
Dreammonkey earned 2000 total points
ID: 24230258
Then this should do it

You need to repeat the thing in the embed tag.

May I suggest you take a look at SWFObject ?
It's really best practice, believe me !

http://code.google.com/p/swfobject/

regards,
DM
<noscript>
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="600" id="SlideShowGood" align="middle">
        <param name="allowScriptAccess" value="sameDomain" />
        <param name="allowFullScreen" value="false" />
    <param name="FlashVars" value="myvariable=photos" />
        <param name="movie" value="SlideShowGood.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />   
<embed src="SlideShowGood.swf" FlashVars="myvariable=photos" quality="high" bgcolor="#ffffff" width="800" height="600" name="SlideShowGood" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
        </object>
</noscript>

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:anniengodis
ID: 24230280
That didn't do it either :(

But I will check out swfobject - thanks! :)
0
 

Author Comment

by:anniengodis
ID: 24230330
BINGO!

That is kew-elle!

I was kind of bummed to have to "learn" a new tool, but once you figure it out, it's extremely simple and creates the html code for you. The flashvars were right there in the "more" part of SWF definition.

Thanks Dreammonkey!!!! :)
0
 

Author Closing Comment

by:anniengodis
ID: 31574439
swfobject worked perfectly for passing parameters to my flash object, exactly what I needed!!
0
 
LVL 8

Expert Comment

by:Dreammonkey
ID: 24230348
Ok final touch :

add it in the AC content javascript code :

Try all three fixes I suggested.

Make it work, then go for SWFObject !!

DM


<script language="javascript">
        if (AC_FL_RunContent == 0) {
                alert("This page requires AC_RunActiveContent.js.");
        } else {
                AC_FL_RunContent(
                        'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
                        'width', '800',
                        'height', '600',
                        'src', 'SlideShowGood',
                        'quality', 'high',
                        'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
                        'align', 'middle',
                        'play', 'true',
                        'loop', 'true',
                        'scale', 'showall',
                        'wmode', 'window',
                        'devicefont', 'false',
                        'id', 'SlideShowGood',
                        'bgcolor', '#ffffff',
                        'name', 'SlideShowGood',
                        'menu', 'true',
                        'allowFullScreen', 'false',
                        'allowScriptAccess','sameDomain',
                        'movie', 'SlideShowGood',
                        'salign', '',
                        'FlashVars', 'myvariable=photos'
                        ); //end AC code
        }
</script>

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

829 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