PDA

View Full Version : Class with param


kefas123
11-16-2006, 11:12 AM
I have this code attach to Tree's iconfunction:

private function treeIconFunction(item:Object):Class {
return MyIconClass;
}


package
{
import mx.controls.Image;
import flash.display.Sprite;
import mx.core.BitmapAsset;
import mx.core.*;

public class MyIconClass extends Image
{
[Bindable]
[Embed(source="../../assets/icon.png")]
public var icon0:Class

public function MyIconClass():void {
var color:int=0
var i:BitmapAsset= new icon0() as BitmapAsset;
for (var y:uint = 3; y < 6; y++) {
for (var x:uint = 4; x < 9; x++)
i.bitmapData.setPixel(x, y, color);
}
this.source=i;
}
}
}


My question is:
How can send param (item) from treeIconFunction to MyIconClass?

robmarston
01-28-2009, 12:21 AM
There's numerous ways to do it...

In your main document class...

var item:String = 'success';

var treeIcon:MyIconClass = new MyIconClass(item);

and in your class file...

public function MyIconClass(item:String):void {
trace(item);
}