Solved

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

Posted on 2009-05-05
9
686 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
  • 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now