2 Replies - 1994 Views - Last Post: 18 April 2011 - 02:57 AM

#1 sam.bengtson  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 58
  • Joined: 21-February 11

Sending variable from asp.net to ActionScript

Posted 07 April 2011 - 02:02 PM

I know that google is littered with tutorials on this but I have been having a hard time getting this to work. There is a variable in my flash object that stores a URL of a website and I need to change it through my asp.net page

Here is my object tag
                <object type="application/x-shockwave-flash" data="WebConference/bin-release/WebConference.swf" width="100%" height="100%">
                    
                    <Param name="FlashVars" Value="room=2">
                    <param name="quality" value="high" />

                    <param name="bgcolor" value="#ffffff" />

                    <param name="allowScriptAccess" value="sameDomain" />

                    <param name="allowFullScreen" value="true" />


Here is my attempt to get at the "room" variable in my FlashVars parameter.

protected function creationComplete():void
			{
				this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
			}
			
			
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
					for (keyStr in paramObj)
					{
valueStr = String(paramObj["room"]);					}
roomName = valueStr;
//Get roomname from the Application parameters, 4/7/2011
				}
				catch(error:Error)
				{
					
				}
				
			
			protected function loaderComplete(myEvent:Event):void
			{
				var flashVars = this.loaderInfo.parameters;
				roomName = flashVars.room;
			}
			


Does anybody see what I am doing wrong? This seems to be the proper way to do it from what I read but I haven't been having any luck. Thanks!

This post has been edited by sam.bengtson: 07 April 2011 - 02:07 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Sending variable from asp.net to ActionScript

#2 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: Sending variable from asp.net to ActionScript

Posted 08 April 2011 - 02:38 AM

Where did you copy the Actionscript code from ? It is incorrect. Try this :

try {
 var value:String;
 var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
 value = String(paramObj["room"]);
 trace(value);
}catch (error:Error) {
 trace(error.toString());
}



Your above code uses a for-in loop to iterate over all the variables passed. But in your case, you pass just one variable which is room. So you can straightaway use it.

This post has been edited by chinchang: 08 April 2011 - 02:41 AM

Was This Post Helpful? 1
  • +
  • -

#3 sas1ni69  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 85
  • View blog
  • Posts: 431
  • Joined: 04-December 08

Re: Sending variable from asp.net to ActionScript

Posted 18 April 2011 - 02:57 AM

Why don't you try parsing XML?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1