Aiwa
08-30-2006, 09:49 PM
package
{
import flash.display.Sprite;
import flash.text.*;
import flash.events.MouseEvent;
final public class main
{
// --- Class Propertie ----------------------------------------
private var conref:Sprite;
private var btn:Sprite;
// --- Class Constructor --------------------------------------
final public function main(param_con)
{
this.conref = param_con;
// --- Init ---
this.createBtn();
}
// --- Class Method: Create btn --------------------------------
final private function createBtn()
{
// --- Create btn ---
btn = new Sprite();
btn.vars = "Storing data"; // <-- How do I glue data to a sprite in AS3 and trace it later
var btn_txt:TextField = new TextField();
btn_txt.text = "press me";
btn_txt.selectable = false;
btn.addChild(btn_txt);
btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
conref.addChildAt(btn, 0);
}
// --- Class Method: Mouse over --------------------------------
final private function mouseDown(event:MouseEvent):void
{
trace(btn.vars);
}
}
}
(How do I glue data to a sprite in AS3 and trace it later)
I how do I solve this error sence in AS2 it where okey to do it but itīs a hole other beef whit AS3 or is it ?
:)
ReferenceError: Error #1056: Cannot create property vars on flash.display.Sprite.
at main/main::createBtn()
at main$iinit()
at Timeline0_86a764da85234e4a8b79f0be4754258/::frame1()
{
import flash.display.Sprite;
import flash.text.*;
import flash.events.MouseEvent;
final public class main
{
// --- Class Propertie ----------------------------------------
private var conref:Sprite;
private var btn:Sprite;
// --- Class Constructor --------------------------------------
final public function main(param_con)
{
this.conref = param_con;
// --- Init ---
this.createBtn();
}
// --- Class Method: Create btn --------------------------------
final private function createBtn()
{
// --- Create btn ---
btn = new Sprite();
btn.vars = "Storing data"; // <-- How do I glue data to a sprite in AS3 and trace it later
var btn_txt:TextField = new TextField();
btn_txt.text = "press me";
btn_txt.selectable = false;
btn.addChild(btn_txt);
btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
conref.addChildAt(btn, 0);
}
// --- Class Method: Mouse over --------------------------------
final private function mouseDown(event:MouseEvent):void
{
trace(btn.vars);
}
}
}
(How do I glue data to a sprite in AS3 and trace it later)
I how do I solve this error sence in AS2 it where okey to do it but itīs a hole other beef whit AS3 or is it ?
:)
ReferenceError: Error #1056: Cannot create property vars on flash.display.Sprite.
at main/main::createBtn()
at main$iinit()
at Timeline0_86a764da85234e4a8b79f0be4754258/::frame1()