AS3/ ASP: need to pass a variable from asp to flash for dynamic text field....

How do I pass an asp variable from an asp page to flash cs3 dynamic text field using as3.  I have posted my code below:
As I am not extremely familiar with classic asp any help is greatly appreciated, so thanks...

"reminder" is the dynamic text field within the mc "important_mc"


//AS3
 
var reminder = root.loaderInfo.parameters.reminder;
 
root.loaderInfo.addEventListener(Event.COMPLETE, onLoaderInfoComplete);
 
function onLoaderInfoComplete(e:Event):void {
	reminder = root.loaderInfo.parameters.reminder;
	trace(root.loaderInfo.parameters.reminder);
	var allFlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
}
 
<!--ASP-->
 
<% Set rs = conn.execute("Select * from insertfiles where id=52")
				reminder = rs("insertfilehtml")
				rs.Close
				'response.write inserthtml
				
			 %>
 
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
 
<h1><a href="index.asp">Apartment association GREATER DALLAS</a></h1>
<%if reminder<>"" AND reminder<>"&nbsp;" AND reminder<>" " then%>
<div class="important-info">
  <script type="text/javascript" src="js/swfobject.js"></script>
  <div id="flashcontent"> This text is replaced by the Flash movie. </div>
  <script type="text/javascript">
   	var so = new SWFObject("flash/important.swf", "important", "575", "30", "9", "#ffffff");
	so.addVariable("reminder", "<%= linkName %>");
	so.addParam("wmode", "transparent");
   	so.write("flashcontent");
</script>
</div>
<% end if %>

Open in new window

cubical38Asked:
Who is Participating?
 
rascalpantsCommented:
okay, I am not sure what is happening on your end, but here is what I did...  

- created new AS 3 document
- posted the below code into frame one
- created a movieclip named important_mc with a text box named reminder in it
- published the Flash and HTML
- added an additional parameter to the AC_FL_RunContent code  (  'FlashVars', 'reminder=This is your reminder',  )


and it all runs fine when i open the html file.


FYI... you will get an error in the Flash IDE when you run it there, because I did not implement a conditional on if the loaderInfo was null or not...


try that and see what happens...


rp / ZA
 
import flash.display.LoaderInfo;
 
 
loaderInfo.addEventListener(Event.COMPLETE, onLoaderInfoComplete);
 
function onLoaderInfoComplete(e:Event):void
{
        var allFlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
        important_mc.reminder.text = allFlashVars.reminder;
        trace( allFlashVars.reminder );
}
 
stop();

Open in new window

0
 
rascalpantsCommented:

from what i can see, the way you are using ASP is correct...   the problem might be in your


try using the below code.


what do you get when you trace that out?


you can also try to use FlashVars...   so.addParam("FlashVars", "reminder=<%= reminder%>&");


rp / ZA

function onLoaderInfoComplete(e:Event):void
{
        var allFlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
        trace( allFlashVars.reminder );
}

Open in new window

0
 
cubical38Author Commented:
Well the trace returns undefined but thats mainly because you cant trace asp within the flash ide, so it is unrecognized.  One question before I plug this in...  Where in the AS3 is it directed to the mc "important_mc" ?   Should it not be important_mc.reminder somewhere, since the dynamic text field is within the mc important_mc...
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
rascalpantsCommented:
yes...  i assumed that code was already written....

so you could just use...

var allFlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;

important_mc.textFieldNameHere.text = allFlashVars.reminder;  // use htmlText instead of text if you need these traits


rp / ZA

0
 
cubical38Author Commented:
This is the code I am using, yet I still have no connection between the flash and the asp page...  Any further suggestions?

Thanks again for all the input...


ASP
 
<% Set rs = conn.execute("Select * from insertfiles where id=52")
				reminder = rs("insertfilehtml")
				rs.Close
				'response.write inserthtml
				
			 %>
 
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
 
<h1><a href="index.asp">Apartment association GREATER DALLAS</a></h1>
<%if reminder<>"" AND reminder<>"&nbsp;" AND reminder<>" " then%>
<div class="important-info">
  <script type="text/javascript" src="js/swfobject.js"></script>
  <div id="flashcontent"> This text is replaced by the Flash movie. </div>
  <script type="text/javascript">
   	var so = new SWFObject("flash/important.swf", "important", "575", "30", "9", "#ffffff");
	//so.addVariable("reminder", "<%= linkName %>");
	so.addParam("FlashVars", "reminder=<%= reminder%>&");
	so.addParam("wmode", "transparent");
   	so.write("flashcontent");
</script>
</div>
<% end if %>
 
 
AS3
 
//root.loaderInfo.addEventListener(Event.COMPLETE, onLoaderInfoComplete);
 
function onLoaderInfoComplete(e:Event):void
{
        var allFlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
		important_mc.reminder.text = allFlashVars.reminder;
        trace( allFlashVars.reminder );
}

Open in new window

0
 
rascalpantsCommented:
what gets traced out in the Flash?  undefined or soemthing else...

you should try to use FlashTracer for Firefox, and this will allow you to view the trace statements while in a browser.

also, have you made sure that the value of <%= reminder%>  is what you want by viewing the source of the html in the browser?


do you have a link to this project so i can look?

rp / ZA
0
 
cubical38Author Commented:
undefined is traced.  I have tried installing FlashTracer but there are files that have not been created and it is not working...  (another issue all together)

when viewing the page source this is what is returned:

<script type="text/javascript" src="js/swfobject.js"></script>
  <div id="flashcontent"> This text is replaced by the Flash movie. </div>
  <script type="text/javascript">
         var so = new SWFObject("flash/important.swf", "important", "575", "30", "9", "#ffffff");
      //so.addVariable("reminder", "");
      so.addParam("FlashVars", "reminder= This is a reminder&");
      so.addParam("wmode", "transparent");
         so.write("flashcontent");
</script>

so.addParam("FlashVars", "reminder= This is a reminder&");
"This is a reminder" is the text that should display in the flash piece, so the asp is being read into the swfobject but the flash is still not communicating...
0
 
cubical38Author Commented:
Thanks for all the help...  The dynamic text box was being hidden by a mask...  It was working the entire time...
0
 
cubical38Author Commented:
Mask was covering the dynamic text box, it was working the entire time...  Thanks again!
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.

All Courses

From novice to tech pro — start learning today.