anniengodis
asked on
FlashVars in HTML not being recognized in AS2
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!! :)
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);
}
could you try _level0.myvariable instead of _root?
ASKER
Thanks for the quick response!
But that didn't do it...
But that didn't do it...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That didn't do it either :(
But I will check out swfobject - thanks! :)
But I will check out swfobject - thanks! :)
ASKER
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!!!! :)
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!!!! :)
ASKER
swfobject worked perfectly for passing parameters to my flash object, exactly what I needed!!
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
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>