Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-05
9
Medium Priority
?
715 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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 how to record live broadcast.

670 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