![]() |
|
||||||||||
|
|||||
|
[+6 04.04.09]
Регистрация: Apr 2009
Сообщений: 32
|
Здравствуйте!
Делаю схему этажей торгового центра. С помощью программиста добились такого результата: http://dmitry-design.ru/shema/shema.swf есть два файла с кодом. note.as package{ import flash.display.*; import flash.events.*; // public class Note extends MovieClip{ public function Note():void{ this.buttonMode=true; this.mouseChildren=false; addEventListener(MouseEvent.CLICK,onClick); } private function onClick(event:MouseEvent):void{ removeEventListener(MouseEvent.CLICK,onClick); if(parent) parent.removeChild(this); } } } package{ import flash.display.*; import flash.events.*; import flash.net.*; // public class Main extends MovieClip{ private var xmlLoader:URLLoader= new URLLoader; private var imgMap:MovieClip=null; private var top:Sprite= new Sprite; // public function Main():void{ addChild(top); btn0.buttonMode=true; btn0.addEventListener(MouseEvent.CLICK,onClick0); btn1.buttonMode=true; btn1.addEventListener(MouseEvent.CLICK,onClick1); btn2.buttonMode=true; btn2.addEventListener(MouseEvent.CLICK,onClick2); btn3.buttonMode=true; btn3.addEventListener(MouseEvent.CLICK,onClick3); btn4.buttonMode=true; btn4.addEventListener(MouseEvent.CLICK,onClick4); btn5.buttonMode=true; btn5.addEventListener(MouseEvent.CLICK,onClick5); xmlLoader.addEventListener(Event.COMPLETE,onXmlComplete); xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,onXmlIOError); btn0.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); } private function onClick0(event:MouseEvent):void{ show('0.xml',Map0); } private function onClick1(event:MouseEvent):void{ show('1.xml',Map1); } private function onClick2(event:MouseEvent):void{ show('2.xml',Map2); } private function onClick3(event:MouseEvent):void{ show('3.xml',Map3); } private function onClick4(event:MouseEvent):void{ show('4.xml',Map4); } private function onClick5(event:MouseEvent):void{ show('5.xml',Map5); } private function show(fileName:String,map:Class):void{ xmlLoader.load(new URLRequest(fileName)); if(imgMap && imgMap.parent) removeChild(imgMap); imgMap=null; var mc:MovieClip= new map; addChildAt(mc,0); imgMap=mc; } private function onXmlComplete(event:Event):void{ var xml:XML= XML(event.target.data); while(top.numChildren>0) top.removeChildAt(0); for each(var point:XML in xml.point){ var s:Spot= new Spot(point); s.x=point.@x; s.y=point.@y; top.addChild(s); s.addEventListener(MouseEvent.CLICK,onSpotClick); } } private function onXmlIOError(event:IOErrorEvent):void{ trace(event.text); } private function onSpotClick(event:MouseEvent):void{ var spot:Spot= event.target as Spot; var note:Note= new Note; note.tf.text=spot.item.note; note.x=Math.round((stage.stageWidth-note.width)/2); note.y=Math.round((stage.stageHeight-note.height)/2); addChild(note); } } } import flash.display.*; class Spot extends Sprite{ public var item:XML; public function Spot(item:XML):void{ this.item=item; this.graphics.beginFill(0xff0000,0.0); this.graphics.drawRect(0,0,item.@width,item.@height); this.graphics.endFill(); this..buttonMode=true; } } Пробовал вставить значения Mouse._x и Mouse._y но не работает. Подскажите где править код, в as3 не силен. Спасибо. Последний раз редактировалось dmitry_kiv; 16.09.2009 в 13:15. |
|
|||||
|
[+1 16.08.10]
Регистрация: Jun 2009
Сообщений: 93
|
ну во первых там эти Note создаются бесконечно, то есть если не кликать по Note то они постоянно накладываются друг на друга
|
![]() |
![]() |
Часовой пояс GMT +4, время: 00:56. |
|
|
« Предыдущая тема | Следующая тема » |
|
|