Forums: Flash:

 

AS3 LoaderInfo from a Class

first
 

Storm AS3 LoaderInfo from a Class

Main.as document is the root. It calls my WebServices class (which just extends MovieClip).

public var ws:WebServices = new WebServices();


In that class, I try to access all the FlashVars past in to the root with this:

public var FlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;


Why does this not pull the FlashVars to my WebServices class? I've tried parent as well and modifications of this.

This is a class component I am making so any agency can work with our WS and I collect all the FlashVars for them and store them without them worrying about passing them each time.

I guess I'm not understanding the parent/child chains of command and restrictions very well.

Any help?

 

lithium

any reason why the webservices class can't take an optional flashvars object in its constructor? e.g


package
{

import flash.display.MovieClip;

public class Main extends MovieClip
{
public var ws:WebServices;

public function Main()
{
super();

ws = new Webservices ( this.loaderInfo.parameters );

}

}

}


the benefit then being that you're not bound to flashvars for your variables, you can send it any anonymous object should you be so inclined.

*shrugs*

 

Storm

Thanks lith.

I need an easy way for the agencies building the training to access whatever I store for them. I know it's a weird project to explain and such a weird project is part of my AS3 frustrations.

I want the Flash devs using my component to.....

"hmmm...I need to display the user's first name....ah, here in the documentation for the stormy component it says I can use WebServices.FlashVars.FirstName. Cool"

versus

"How do I get access to the session information? I want to display the user's first name in the training. I need LoaderInfo? What is that? I've never used AS3 before."

I want to minimize work for others.

 

Storm

Wait, I'm losing my mind on this......

so, what you're saying is then they would just use:

WebServices.FirstName? because it spits the parameters into that class without anything else defined?


------
I also wanted to clarify......

In a MC on the stage called WebServices, this works:
var FlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;

It calls the root.

In my example above where WebServices is a Class extending MC, I can't access 'root' and that's part of what's pissed me off.

This does NOT work:
public var FlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;

What the hell is the difference between and MC on the stage and an MC called as a class. There should be no difference and is where my confusion lies.

 

JLM

Storm make sure the flash var object is not empty it takes time to populate, don't know about webservices stuff.

 

Storm

No, I can see it all in Demonster's Debugger. I just can't seem to have the class reference it to store it.

Please, feel free to treat me like an idiot.....lith come back!! Slap me around if you have to!!

I know I'm an idiot comp-sci wise and I'm ok with that. I'm a visual thinker. I have to see something to work hence why I'm a designer and love being a designer. So....here goes....

lith's idea works great.

ws = new Webservices ( this.loaderInfo.parameters );


But, I still have to declare a var in the class function otherwise the compiler chokes on me. So I put:

public function WebServices(FlashVars:Object)


but now I get ALL the parameters as variables (WebServices.FirstName) but I also get WebServices.FlashVars.FirstName. I DON'T WANT BOTH!! Why can't I just push them and have them BE (speaking philosophically).

I don't want this to be confusing to those agencies' flash guys who want to still use old POST methods that our .NET guys want to abandon, nor do I want them building in AS2 either. I want to give them EASY methods to use to communicate with our back end.

JLM, if I get any more desparate, I'm sending you files. ARGH!
smile)))))

Thanks guys for your help in changing my brain.

 
first
 

Forums: Flash: AS3 LoaderInfo from a Class

 
New Post
 
You must be logged in to post