简体   繁体   中英

AS3. MouseEvent click in (for) loop function

am need here onClick one of the movieclip loop_Task.addChild(tee) trace the tee.task_id.text which one is clicked from the list for ex. this

output be like
(List Clicked : 100)
(List Clicked : 101)

or onClick passed the item data it's already clicked to new class screen

here is my code

public function resultHandlerList_items(event:SQLEvent):void
    {
        // TODO Auto-generated method stub
        var result:SQLResult = selectStmt1.getResult(); 
        var numResults:int = result.data.length; 
        for (var i:int = 0; i < numResults; i++) 
        {
            var row:Object = result.data[i]; 
            var tee:listview_mc = new listview_mc
            loop_Task.addChild(tee)
            tee.y = 270*i
            tee.task_id.text = row.Tid
            tee.task_tit.text = row.Ttitles
            tee.task_stime.text = row.Stime
            tee.task_subject.text = row.Subject
            tee.addEventListener(MouseEvent.CLICK, onClickList)
        }           
        function onClickList(e:MouseEvent):void{
        trace("List Clicked : " + e.currentTarget)
        }
 }

in the first thanks to @Organis He give me the way to fix my code and he give me info about how to talk with the compiler with exactly how to make the compiler understand your code this code the fix (e.currentTarget as listview_mc) and now this my code after fixing and i do take a public var String and pass it to other Class

    public function resultHandlerList_items(event:SQLEvent):void
        {
        // TODO Auto-generated method stub
        var result:SQLResult = selectStmt1.getResult(); 
        var numResults:int = result.data.length; 
        for (var i:int = 0; i < numResults; i++) 
        {
            var row:Object = result.data[i]; 
            var tee:listview_mc = new listview_mc
            loop_Task.addChild(tee)
            tee.y = 270*i
            tee.task_id.text = row.Tid
            tee.task_tit.text = row.Ttitles
            tee.task_stime.text = row.Stime
            tee.task_subject.text = row.Subject
            tee.addEventListener(MouseEvent.CLICK, onClickList)
        }           
        function onClickList(e:MouseEvent):void{
        trace("List Clicked : " + (e.currentTarget as listview_mc).task_id.text)
         ts_id = (e.currentTarget as listview_mc).task_id.text;
         sport._sport.Remove_Home_Sc(e);
        trace("done")        
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM