Solved

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

Posted on 2009-05-05
9
707 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

630 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