Page 1

CLICK AND DRAG CODE <?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" actionBarVisible="false" title="GettingChanged"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Script> <![CDATA[

//Pants Click and Drag protected function view1_addedToStageHandler(event:Event):void { // TODO Auto-generated method stub } protected function Pants_mouseDownHandler(event:MouseEvent):void { this.stage.addEventListener(MouseEvent.MOUSE_UP,Pants_mouse _up_handler) ; Pants.startDrag(); } protected function Pants_mouse_up_handler(event:MouseEvent):void { this.stage.removeEventListener(MouseEvent.MOUSE_UP,Pants_mo use_up_handler) ; // TODO Auto-generated method stub Pants.stopDrag();

//Keeping object in x bounds if(Pants.x < 14) Pants.x = 14; else if (Pants.x > 1333)


Pants.x = 1333; //Keeping object in Y bounds if(Pants.y < -22) Pants.y = -22; else if(Pants.y > 755) Pants.y = 775; if (Pants.x > 500 && Pants.x < 700 && Pants.y > 520 && Pants.y < 615) { MrWboxers.visible = false; MrWPants.visible = true; Pants.visible = false; } } protected function button1_clickHandler(event:MouseEvent):void { // TODO Auto-generated method stub } ]]> </fx:Script> <s:Image id="BackgroundImage" left="0" right="0" top="0" bottom="0" scaleMode="zoom" smooth="true" source="@Embed('assets/background image.png')"/> <s:Image id="MrWboxers" visible="true" x="586" y="283" width="248" height="662" scaleMode="letterbox" smooth="true" smoothingQuality="default" source="@Embed('assets/MR W boxers(1).png')"/> <s:Image id="Pants" visible="true" x="41" y="720" width="208" height="370" mouseDown="Pants_mouseDownHandler(event)" smooth="true" source="@Embed('assets/Mr W just pants.png')"/> <s:Image id="MrWPants" visible="false" x="543" y="259" width="309" height="665" smooth="true" </s:View>


Click and Drag Code  

Here is my code for Click and Drag

Advertisement
Read more
Read more
Similar to
Popular now
Just for you