Solved

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

Posted on 2009-05-05
9
703 Views
Last Modified: 2013-11-11
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

0
Comment
Question by:cubical38
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 24308224

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
 

Author Comment

by:cubical38
ID: 24308341
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
 
LVL 22

Expert Comment

by:rascalpants
ID: 24308553
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:cubical38
ID: 24315620
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
 
LVL 22

Expert Comment

by:rascalpants
ID: 24315670
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
 

Author Comment

by:cubical38
ID: 24316775
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
 
LVL 22

Accepted Solution

by:
rascalpants earned 500 total points
ID: 24317092
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
 

Author Comment

by:cubical38
ID: 24326496
Thanks for all the help...  The dynamic text box was being hidden by a mask...  It was working the entire time...
0
 

Author Closing Comment

by:cubical38
ID: 31578160
Mask was covering the dynamic text box, it was working the entire time...  Thanks again!
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

752 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