The easiest way is to declare a public variable in the class.  That
becomes a public property of the object. Something like:

 

class RSSParser

  public var zipCode:String = ""

....

 

Then

rssParser = new RSSParser();

rssParser.zipCode = "30117"

 

You can do a similar thing using getter an setter functions instead of
the variable, if you need to take an action when the property is set:

Public property set zipCode(value:String):void

...

 

Finally, you can pass parameters into the class in the constructor:

rssParser = new RSSParser(sZipCodeVar);

 

Technically speaking, you pass data into an object instance, not a class
or a package

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of christopherjdunn
Sent: Wednesday, January 17, 2007 5:25 PM
To: [email protected]
Subject: [flexcoders] Pass a value into a package

 

New to flex and attempting a small Weather app to learn flex. I'm 
attempting to pass a variable into a package and can't seem to find any 
info on how to do this. Here is the code from my app that calls the 
package:

public function initApp():void {
rssParser = new RSSParser();
rssParser.addEventListener("dataWritten", onDataReceived);
}

Which works just fine. What I would like to do is pass the text from an 
input field (zipcode.text) into the rssParser package but can't seem to 
get this working. Any guidance would be great.

 

Reply via email to