Posted by Sankar.G | Posted in AS3 | Posted on 2:32 PM
Below Code is useful to you to open a popup window in flash using AS3.0
import flash.net.URLRequest;
test_btn.addEventListener(MouseEvent.CLICK,fun);
function fun(event:MouseEvent):void
{
var address:String = "http://www.google.com";
var jscommand:String = "window.open('" + address + "','PopUpWindow','height=600,width=600,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0');";
var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
navigateToURL(url,"_parent");
}
import flash.net.URLRequest;
test_btn.addEventListener(MouseEvent.CLICK,fun);
function fun(event:MouseEvent):void
{
var address:String = "http://www.google.com";
var jscommand:String = "window.open('" + address + "','PopUpWindow','height=600,width=600,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0');";
var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
navigateToURL(url,"_parent");
}
Posted by Sankar.G | Posted in AS3 | Posted on 11:24 PM
Data Grid is a Very Use Full Component in Flash But we feel some Difficulties to get the Data from the Data Grid Below Link is very Use full to you to get the Data from the Data Grid
DataGrid.zip
DataGrid.swf
DataGrid.zip
DataGrid.swf
Posted by Sankar.G | Posted in smartFox server | Posted on 10:15 AM
Simple smartFox chat Application in AS3.0
below link is useful to you to get the source for the chat Application. Before download the chat Application from the below link
"SmartFoxchat.zip" "please start the SmartFoxServer"
below link is useful to you to get the source for the chat Application. Before download the chat Application from the below link
"SmartFoxchat.zip" "please start the SmartFoxServer"
Posted by Sankar.G | Posted in smartFox server | Posted on 9:47 PM
Smartfoxserver is a powerful platform for developing Multiuser Applications and Games with
1)Flash
2)Flex
3)Adobe Air
4)Java
5).Net
6)Apple iPhones
It allowing developers to quickly create any type of Multiplayer intractions
chat Applications to MMO Games this server comes with a rich set of features one of
the best sets of documentations with examples...
SmartFoxBits:
it is a set of Flex and flash UI components specifically designed to be used
in conjuction with smartfoxserver 1.5.5 or greaterit is also used to create multiplayer
applications and games
BlueBox:
it is used to allow connections behind firewall and proxies if a direct socket
connection is not available player can play and enjoy Games with restricted network
Configurations
RedBox:
It is based on Red5 project it adds audio&video streaming capabilities
its allow
1)Live one-to-one audio/video chat
2)Live events
3)Video streaming etc...
Open space:
It is powerful flash based isometric engine and multi user virtual world
Open Space Features
1)Customizable tiles aspect ratio
2)Tiles Elevetion
3)2d Objects in 2.5d world
4)Advance path finding
5)Powerful avatar management
6)Advance map interaction system
7)complete map editor
More Details About SmartFox
1)Flash
2)Flex
3)Adobe Air
4)Java
5).Net
6)Apple iPhones
It allowing developers to quickly create any type of Multiplayer intractions
chat Applications to MMO Games this server comes with a rich set of features one of
the best sets of documentations with examples...
SmartFoxBits:
it is a set of Flex and flash UI components specifically designed to be used
in conjuction with smartfoxserver 1.5.5 or greaterit is also used to create multiplayer
applications and games
BlueBox:
it is used to allow connections behind firewall and proxies if a direct socket
connection is not available player can play and enjoy Games with restricted network
Configurations
RedBox:
It is based on Red5 project it adds audio&video streaming capabilities
its allow
1)Live one-to-one audio/video chat
2)Live events
3)Video streaming etc...
Open space:
It is powerful flash based isometric engine and multi user virtual world
Open Space Features
1)Customizable tiles aspect ratio
2)Tiles Elevetion
3)2d Objects in 2.5d world
4)Advance path finding
5)Powerful avatar management
6)Advance map interaction system
7)complete map editor
More Details About SmartFox
Posted by Sankar.G | Posted in APE Engine | Posted on 4:23 PM
Below file is useful to create a Jumping Basement with APE Engine with ball
& useful to Merge the APE particle with Flash MovieClips
APE Jump.fla
APE Jump.swf
& useful to Merge the APE particle with Flash MovieClips
APE Jump.fla
APE Jump.swf
Posted by Sankar.G | Posted in AS3 | Posted on 11:09 PM
Two Dimensional Arrays is Flash is Easy .....
Below Code is very useful to you
Source
Arrays.fla
Result
Arrays.swf
Below Code is very useful to you
Source
Arrays.fla
Result
Arrays.swf
Posted by Sankar.G | Posted in AS3 | Posted on 10:43 PM
Take careful note of the differences.
Which is that the y axis is flipped.flash uses radians to measure angles not degrees,
The maximum rotation around any Cartesian coordinate system is 360 degrees.
In Flash if you are moving clock wise this will be a positive number
in degrees until you reach 180 degrees.
If your are moving counter clock wise this will be a negative number
until you reach -180 degrees
Source
Angles.fla
Result
Angles.swf
Which is that the y axis is flipped.flash uses radians to measure angles not degrees,
The maximum rotation around any Cartesian coordinate system is 360 degrees.
In Flash if you are moving clock wise this will be a positive number
in degrees until you reach 180 degrees.
If your are moving counter clock wise this will be a negative number
until you reach -180 degrees
Source
Angles.fla
Result
Angles.swf
Posted by Sankar.G | Posted in AS3 | Posted on 12:11 AM
The SharedObject class is used to read and store limited amounts of data on a user's computer or on a server. Shared objects offer real-time data sharing between multiple client SWF files and objects that are persistent on the local computer or remote server. Local shared objects are similar to browser cookies and remote shared objects are similar to real-time data transfer devices
Example Code is in Below link
shareobject.fla
Example Code is in Below link
shareobject.fla
Posted by Sankar.G | Posted in BOX2D | Posted on 10:43 PM
A Simple Example for Box2d in the Below Link with
Detailed Defined Code we dont have any proper Documentation for Box2d for Flash
we have Documentation for Box2d in c++ only in the below link we have 1 class file
in the class file i explained detailed for each line sure it will help
box2d.zip
Detailed Defined Code we dont have any proper Documentation for Box2d for Flash
we have Documentation for Box2d in c++ only in the below link we have 1 class file
in the class file i explained detailed for each line sure it will help
box2d.zip
Posted by Sankar.G | Posted in AS3 | Posted on 10:23 PM
we create a dynamic Array easily in as2 but in as3 it is little bit difficult below script is useful to Create a dynamic Array
for that we first declare a object and in the Object we create a 'n' numbers of Array
var vbox:Array
var dArray:Object = new Object();
var counter:int = 1;
var i:Number;
for (i=1;i<=5;i++)
{
vbox = new Array(1,2,3,4);
dArray[("vb" + counter)] = vbox;
counter++;
}
dArray[("vb"+1)][1]=985;
for(i=1;i<=5;i++)
{
trace(dArray[("vb"+i)]);
}
for that we first declare a object and in the Object we create a 'n' numbers of Array
var vbox:Array
var dArray:Object = new Object();
var counter:int = 1;
var i:Number;
for (i=1;i<=5;i++)
{
vbox = new Array(1,2,3,4);
dArray[("vb" + counter)] = vbox;
counter++;
}
dArray[("vb"+1)][1]=985;
for(i=1;i<=5;i++)
{
trace(dArray[("vb"+i)]);
}
Posted by Sankar.G | Posted in Red 5 server | Posted on 9:53 PM
Creation of User List using Java Red5 Server with Flash AS3.0
This below Code is used to create the Multiple user List
for this execution of this file you need red5 server
Download the below file and extract the file cut the third Folder and paste it in the
red5 installation path
C:\Program Files\Red5\webapps
paste the third folder in this location and Start the red5 server & Execute the check.fla and open 4 check.swf
and type 4 different names in 4 swf and make a click on other names after the request comes to other swf accept the invitation game will starts for the particulary 2 players
USERLIST.ZIP
This below Code is used to create the Multiple user List
for this execution of this file you need red5 server
Download the below file and extract the file cut the third Folder and paste it in the
red5 installation path
C:\Program Files\Red5\webapps
paste the third folder in this location and Start the red5 server & Execute the check.fla and open 4 check.swf
and type 4 different names in 4 swf and make a click on other names after the request comes to other swf accept the invitation game will starts for the particulary 2 players
USERLIST.ZIP
Posted by Sankar.G | Posted in Red 5 server | Posted on 12:12 AM
Go to red5 installation path open the Red5 folder and open the webapps Folder inside you have test folder copy the test folder and paste it in the same place and rename it as second
Open the second folder you have WEB-INF folder and index.jsp file open the WEB-INF folder you have
1)Classes
2)lib
3)src
4)flds
Folders &
1)red5 web prperties
2)red5-web.xml
3)web.xml
Files
open this 3 files in notepad in the re5 web properties file
you have webapp.contextpath=/test
delete the test and type second (foldername)
open red5-web.xml file you have 3 beanid delete last 2 beanid (test service & echo)beanid's
in the web-handler beanid you have class path delete the class path and type
"second.Second" and save it
And open the web.xml file using notepad in the last context-param you have param-values /test delete the test and type second (foldername) and save it
now we want to create a java file to connect the red5 server with flash
so please open the Eclipse (Java IDE)in the work space launcher set work space
c:\programfile\red5\webapps or red5 installation path and click ok
go to windows --- show view --- package Explorer open the package explorer
go the file--new--java project in the project name textbox type second (foldername) in webapps click next button and click finish
right click on the second project in the package Explorer new--package and name it as
second Right click on the package second go to new--class and name it as Second and click ok button now second java is created
now project is created we want to configure buildpath so right click on the project name second and go to buildpath--configure buildpath make a click on the source tab and click Add folder and select src folder from WEB-INF and click ok button
In the bottom default output folder Click on the browse button and select classes folder and click ok button now project in ready to write the java now we want to add the jar file in our project right click on the project and go to properties and click the libraries tab and click add External jar Button
Go to red5 installation path and select red5.jar and click ok now red 5 jar is added on our project or
Download the File from below link Extract it cut the second (folder) and paste it in the red5/webapps
start the red5 server and Compile the first.fla type some name and click the button
that name will send to red5 server and return to our flash and trace
Java file coding & flash file Coding in the Below Link
FILE.ZIP
Open the second folder you have WEB-INF folder and index.jsp file open the WEB-INF folder you have
1)Classes
2)lib
3)src
4)flds
Folders &
1)red5 web prperties
2)red5-web.xml
3)web.xml
Files
open this 3 files in notepad in the re5 web properties file
you have webapp.contextpath=/test
delete the test and type second (foldername)
open red5-web.xml file you have 3 beanid delete last 2 beanid (test service & echo)beanid's
in the web-handler beanid you have class path delete the class path and type
"second.Second" and save it
And open the web.xml file using notepad in the last context-param you have param-values /test delete the test and type second (foldername) and save it
now we want to create a java file to connect the red5 server with flash
so please open the Eclipse (Java IDE)in the work space launcher set work space
c:\programfile\red5\webapps or red5 installation path and click ok
go to windows --- show view --- package Explorer open the package explorer
go the file--new--java project in the project name textbox type second (foldername) in webapps click next button and click finish
right click on the second project in the package Explorer new--package and name it as
second Right click on the package second go to new--class and name it as Second and click ok button now second java is created
now project is created we want to configure buildpath so right click on the project name second and go to buildpath--configure buildpath make a click on the source tab and click Add folder and select src folder from WEB-INF and click ok button
In the bottom default output folder Click on the browse button and select classes folder and click ok button now project in ready to write the java now we want to add the jar file in our project right click on the project and go to properties and click the libraries tab and click add External jar Button
Go to red5 installation path and select red5.jar and click ok now red 5 jar is added on our project or
Download the File from below link Extract it cut the second (folder) and paste it in the red5/webapps
start the red5 server and Compile the first.fla type some name and click the button
that name will send to red5 server and return to our flash and trace
Java file coding & flash file Coding in the Below Link
FILE.ZIP
Posted by Sankar.G | Posted in Red 5 server | Posted on 11:40 PM
I create a simple multiplayer game concept using red 5 Server
Before compile this fla you must install the red5 Server in your system
if you want Red5.exe file please see my previous Blog
After Install the Red 5 Server Download the Below File
DEMO.ZIP
Star the Red 5 Server
C:\Program Files\Red5\red5.bat using this batch File
Extract the Zip file and Compile the Demo.Fla
after you get Demo.swf
Open 2 Demo.swf and make a click on the Box the box will get movement on that 2 Demo.swf this is the Simple Multiplayer Demo using red 5 Server
Before compile this fla you must install the red5 Server in your system
if you want Red5.exe file please see my previous Blog
After Install the Red 5 Server Download the Below File
DEMO.ZIP
Star the Red 5 Server
C:\Program Files\Red5\red5.bat using this batch File
Extract the Zip file and Compile the Demo.Fla
after you get Demo.swf
Open 2 Demo.swf and make a click on the Box the box will get movement on that 2 Demo.swf this is the Simple Multiplayer Demo using red 5 Server
Posted by Sankar.G | Posted in Red 5 server | Posted on 11:29 PM
Red 5 java Server used for
1)Streaming Audio/Video (FLV and MP3)
2)Recording Client Streams (FLV only)
3)Shared Objects
4)Live Stream Publishing
5)Remoting (AMF)
Red5 is considered as a free alternate to Adobe Flash Media Server,
and supports many of the same feature sets.
It has a few additional feature sets such as the ability to intercept live streams,
and the ability to easily plug in other Java libraries such as Hibernate
In this Below Link you can download the Red 5.exe file
install the file and go to services.msc and start the red 5 Services
Red 5.exe
1)Streaming Audio/Video (FLV and MP3)
2)Recording Client Streams (FLV only)
3)Shared Objects
4)Live Stream Publishing
5)Remoting (AMF)
Red5 is considered as a free alternate to Adobe Flash Media Server,
and supports many of the same feature sets.
It has a few additional feature sets such as the ability to intercept live streams,
and the ability to easily plug in other Java libraries such as Hibernate
In this Below Link you can download the Red 5.exe file
install the file and go to services.msc and start the red 5 Services
Red 5.exe
Posted by Sankar.G | Posted in AS3 | Posted on 3:37 PM
Below link is helpful to put tool tip for a movie Clip or Buttons you can't want to do calculation for this
download this below file and Enjoy......
you can get Tooltip using this below class file
ToolTip.as
How to use the class file with example at below Link
ToolTip.zip
Output for this file is below
ToolTip.swf
download this below file and Enjoy......
you can get Tooltip using this below class file
ToolTip.as
How to use the class file with example at below Link
ToolTip.zip
Output for this file is below
ToolTip.swf
Posted by Sankar.G | Posted in AS3 | Posted on 10:19 AM
Below links is helpful to you to do hitTest for an irregular shape object
you can't want to do any math calculation for this download the below file and
enjoy .......
you can do hitTest for a irregular shapes using this below class file
HitTest.as
How to use the class file with example at below Link
hittest.zip
Output for this file is below
hittest.swf
you can't want to do any math calculation for this download the below file and
enjoy .......
you can do hitTest for a irregular shapes using this below class file
HitTest.as
How to use the class file with example at below Link
hittest.zip
Output for this file is below
hittest.swf
Posted by Sankar.G | Posted in AS3 | Posted on 2:16 PM
This script is used to load the images from web using XML and display
it on the stage script is in the Below Link downLoad it and use it
XMLimages.zip
it on the stage script is in the Below Link downLoad it and use it
XMLimages.zip
Posted by Sankar.G | Posted in papervision | Posted on 5:15 PM
copy this below code and save it as a "four.as" and give link to the file from flash and dont forget
the download the papervision.zip file from the previous Blog and kept org & com & fl & this as file and
fla file in the same folder and run the file it will work
package
{
import flash.display.ActionScriptVersion;
import flash.display.Scene;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.core.utils.InteractiveSceneManager;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.primitives.Plane;
public class four extends Sprite
{
private var view:Viewport3D;
private var camera:Camera3D;
private var light:PointLight3D;
private var plane:Plane;
private var render:BasicRenderEngine;
private var scene:Scene3D;
private var man:InteractiveSceneManager;
private var universe:DisplayObject3D;
private var mat:BitmapFileMaterial;
public function four():void
{
init();
}
private function init():void
{
view = new Viewport3D(0, 0, true);
view.opaqueBackground = 0x000000;
addChild(view);
man = new InteractiveSceneManager(view);
camera = new Camera3D();
camera.z = -2000;
camera.zoom = 2;
light = new PointLight3D(false);
scene = new Scene3D();
render = new BasicRenderEngine();
universe = new DisplayObject3D();
mat = new BitmapFileMaterial();
mat.texture ="http://www.flowerstodubai.com/images/Mixed%20Flowers%20and%20a%20Bear.jpg"
mat.interactive = true;
mat.smooth = true;
mat.tiled = true;
mat.addEventListener(FileLoadEvent.LOAD_COMPLETE, call);
function call(event:FileLoadEvent):void
{
plane = new Plane(mat, 3000, 3000, 8);
universe.addChild(plane);
scene.addChild(universe);
addEventListener(Event.ENTER_FRAME, fun);
man.container.addEventListener(MouseEvent.CLICK, click);
}
}
private function click(event:MouseEvent):void
{
plane.rotationZ += 10;
}
private function fun(event:Event):void
{
render.renderScene(scene, camera, view);
}
}
}
the download the papervision.zip file from the previous Blog and kept org & com & fl & this as file and
fla file in the same folder and run the file it will work
package
{
import flash.display.ActionScriptVersion;
import flash.display.Scene;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.core.utils.InteractiveSceneManager;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.primitives.Plane;
public class four extends Sprite
{
private var view:Viewport3D;
private var camera:Camera3D;
private var light:PointLight3D;
private var plane:Plane;
private var render:BasicRenderEngine;
private var scene:Scene3D;
private var man:InteractiveSceneManager;
private var universe:DisplayObject3D;
private var mat:BitmapFileMaterial;
public function four():void
{
init();
}
private function init():void
{
view = new Viewport3D(0, 0, true);
view.opaqueBackground = 0x000000;
addChild(view);
man = new InteractiveSceneManager(view);
camera = new Camera3D();
camera.z = -2000;
camera.zoom = 2;
light = new PointLight3D(false);
scene = new Scene3D();
render = new BasicRenderEngine();
universe = new DisplayObject3D();
mat = new BitmapFileMaterial();
mat.texture ="http://www.flowerstodubai.com/images/Mixed%20Flowers%20and%20a%20Bear.jpg"
mat.interactive = true;
mat.smooth = true;
mat.tiled = true;
mat.addEventListener(FileLoadEvent.LOAD_COMPLETE, call);
function call(event:FileLoadEvent):void
{
plane = new Plane(mat, 3000, 3000, 8);
universe.addChild(plane);
scene.addChild(universe);
addEventListener(Event.ENTER_FRAME, fun);
man.container.addEventListener(MouseEvent.CLICK, click);
}
}
private function click(event:MouseEvent):void
{
plane.rotationZ += 10;
}
private function fun(event:Event):void
{
render.renderScene(scene, camera, view);
}
}
}
Posted by Sankar.G | Posted in papervision | Posted on 12:16 PM
First Download the PaperVision3d Pack
papervision.zip
extract the zip file
And Create a ActionScript File and Name it as "two" save the file in the same folder
And put this script in class folder
package
{
import flash.display.ActionScriptVersion;
import flash.display.Scene;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.materials.shadematerials.GouraudMaterial;
import org.papervision3d.objects.primitives.Cone;
public class two extends Sprite
{
private var scene:Scene3D;
private var viewport:Viewport3D;
private var camere:Camera3D;
private var light:PointLight3D;
private var renderer:BasicRenderEngine;
private var universe:DisplayObject3D;
private var gouraudCone:Cone;
private var gouraudMat:GouraudMaterial;
public function two()
{
init();
}
private function init():void
{
viewport = new Viewport3D(0, 0, true);
viewport.opaqueBackground = 0;
addChild(viewport);
renderer = new BasicRenderEngine();
camere = new Camera3D();
camere.z = -2000;
camere.zoom = 2;
light = new PointLight3D(true);
scene = new Scene3D();
gouraudMat = new GouraudMaterial(light, 0,0x00ff00);
gouraudCone = new Cone(gouraudMat,800, 800, 10,10);
gouraudCone.x = 0;
universe = new DisplayObject3D();
universe.addChild(gouraudCone);
scene.addChild(universe);
addEventListener(Event.ENTER_FRAME, render);
}
private function render(event:Event):void
{
universe.rotationX += 10;
universe.rotationY += 10;
universe.rotationZ += 10;
renderer.renderScene(scene, camere,viewport);
}
}
}
Create a Empty flash File and give link to the class file name in the Docoument Class text Box and run
the flash file
Result:
Cone.swf
papervision.zip
extract the zip file
And Create a ActionScript File and Name it as "two" save the file in the same folder
And put this script in class folder
package
{
import flash.display.ActionScriptVersion;
import flash.display.Scene;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.materials.shadematerials.GouraudMaterial;
import org.papervision3d.objects.primitives.Cone;
public class two extends Sprite
{
private var scene:Scene3D;
private var viewport:Viewport3D;
private var camere:Camera3D;
private var light:PointLight3D;
private var renderer:BasicRenderEngine;
private var universe:DisplayObject3D;
private var gouraudCone:Cone;
private var gouraudMat:GouraudMaterial;
public function two()
{
init();
}
private function init():void
{
viewport = new Viewport3D(0, 0, true);
viewport.opaqueBackground = 0;
addChild(viewport);
renderer = new BasicRenderEngine();
camere = new Camera3D();
camere.z = -2000;
camere.zoom = 2;
light = new PointLight3D(true);
scene = new Scene3D();
gouraudMat = new GouraudMaterial(light, 0,0x00ff00);
gouraudCone = new Cone(gouraudMat,800, 800, 10,10);
gouraudCone.x = 0;
universe = new DisplayObject3D();
universe.addChild(gouraudCone);
scene.addChild(universe);
addEventListener(Event.ENTER_FRAME, render);
}
private function render(event:Event):void
{
universe.rotationX += 10;
universe.rotationY += 10;
universe.rotationZ += 10;
renderer.renderScene(scene, camere,viewport);
}
}
}
Create a Empty flash File and give link to the class file name in the Docoument Class text Box and run
the flash file
Result:
Cone.swf
Posted by Sankar.G | Posted in | Posted on 3:41 PM
you can draw a triangle with out any design using script copy the below script and past it in flash first Frame and run the file make a three click on the stage and drag the points
var l1:Shape=new Shape();
addChild(l1);
var p1:Sprite=new Sprite();
p1.addEventListener(MouseEvent.MOUSE_DOWN,drag1);
addChild(p1);
var p2:Sprite=new Sprite();
p2.addEventListener(MouseEvent.MOUSE_DOWN,drag2);
addChild(p2)
var p3:Sprite=new Sprite();
p3.addEventListener(MouseEvent.MOUSE_DOWN,drag3);
addChild(p3)
stage.addEventListener(MouseEvent.MOUSE_MOVE,moves);
stage.addEventListener(MouseEvent.MOUSE_UP,all);
stage.addEventListener(MouseEvent.CLICK,fun);
var boo:Number=0;
function moves(event:MouseEvent):void
{
if(boo==3)
{
l1.graphics.clear();
drawLine();
}
}
function fun(event:MouseEvent):void
{
if(boo==0)
{
p1.graphics.lineStyle(1,0x00ff00);
p1.graphics.beginFill(0x00ff00);
p1.graphics.drawCircle(0,0,5);
p3.graphics.endFill();
p1.filters=[new DropShadowFilter()];
p1.x=mouseX;
p1.y=mouseY;
boo=1
}
else if(boo==1)
{
p2.graphics.lineStyle(1,0x00ff00);
p2.graphics.beginFill(0x00ff00);
p2.graphics.drawCircle(0,0,5);
p3.graphics.endFill();
p2.filters=[new DropShadowFilter()];
p2.x=mouseX;
p2.y=mouseY;
boo=2;
}
else if(boo==2)
{
p3.graphics.lineStyle(1,0x00ff00);
p3.graphics.beginFill(0x00ff00);
p3.graphics.drawCircle(0,0,5);
p3.graphics.endFill();
p3.filters=[new DropShadowFilter()];
p3.x=mouseX;
p3.y=mouseY;
boo=3;
drawLine();
}
}
function drawLine():void
{
l1.graphics.lineStyle(1,0xffff00);
l1.graphics.moveTo(p2.x,p2.y);
l1.graphics.lineTo(p3.x,p3.y);
l1.graphics.lineTo(p1.x,p1.y);
l1.graphics.lineTo(p2.x,p2.y);
l1.filters=[new DropShadowFilter()];
l1.graphics.endFill();
}
function drag1(event:MouseEvent):void
{
if(boo==3)
{
event.currentTarget.startDrag();
}
}
function drag2(event:MouseEvent):void
{
if(boo==3)
{
event.currentTarget.startDrag();
}
}
function drag3(event:MouseEvent):void
{
if(boo==3)
{
event.currentTarget.startDrag();
}
}
function all(event:MouseEvent):void
{
stopDrag();
}
Examples:
triangle.swf
var l1:Shape=new Shape();
addChild(l1);
var p1:Sprite=new Sprite();
p1.addEventListener(MouseEvent.MOUSE_DOWN,drag1);
addChild(p1);
var p2:Sprite=new Sprite();
p2.addEventListener(MouseEvent.MOUSE_DOWN,drag2);
addChild(p2)
var p3:Sprite=new Sprite();
p3.addEventListener(MouseEvent.MOUSE_DOWN,drag3);
addChild(p3)
stage.addEventListener(MouseEvent.MOUSE_MOVE,moves);
stage.addEventListener(MouseEvent.MOUSE_UP,all);
stage.addEventListener(MouseEvent.CLICK,fun);
var boo:Number=0;
function moves(event:MouseEvent):void
{
if(boo==3)
{
l1.graphics.clear();
drawLine();
}
}
function fun(event:MouseEvent):void
{
if(boo==0)
{
p1.graphics.lineStyle(1,0x00ff00);
p1.graphics.beginFill(0x00ff00);
p1.graphics.drawCircle(0,0,5);
p3.graphics.endFill();
p1.filters=[new DropShadowFilter()];
p1.x=mouseX;
p1.y=mouseY;
boo=1
}
else if(boo==1)
{
p2.graphics.lineStyle(1,0x00ff00);
p2.graphics.beginFill(0x00ff00);
p2.graphics.drawCircle(0,0,5);
p3.graphics.endFill();
p2.filters=[new DropShadowFilter()];
p2.x=mouseX;
p2.y=mouseY;
boo=2;
}
else if(boo==2)
{
p3.graphics.lineStyle(1,0x00ff00);
p3.graphics.beginFill(0x00ff00);
p3.graphics.drawCircle(0,0,5);
p3.graphics.endFill();
p3.filters=[new DropShadowFilter()];
p3.x=mouseX;
p3.y=mouseY;
boo=3;
drawLine();
}
}
function drawLine():void
{
l1.graphics.lineStyle(1,0xffff00);
l1.graphics.moveTo(p2.x,p2.y);
l1.graphics.lineTo(p3.x,p3.y);
l1.graphics.lineTo(p1.x,p1.y);
l1.graphics.lineTo(p2.x,p2.y);
l1.filters=[new DropShadowFilter()];
l1.graphics.endFill();
}
function drag1(event:MouseEvent):void
{
if(boo==3)
{
event.currentTarget.startDrag();
}
}
function drag2(event:MouseEvent):void
{
if(boo==3)
{
event.currentTarget.startDrag();
}
}
function drag3(event:MouseEvent):void
{
if(boo==3)
{
event.currentTarget.startDrag();
}
}
function all(event:MouseEvent):void
{
stopDrag();
}
Examples:
triangle.swf
Posted by Sankar.G | Posted in AS3 | Posted on 9:55 AM
var i:Number;
var a:Array=new Array("");
var b:Array=new Array("");
var c:Array=new Array("");
main();
function main()
{
for (i=1; i<
11; i++) {
a[i]=i;
}
for (i=1; i<
11; i++) {
var r:Number=a.length-1;
b[i]=Math.floor(Math.random()*r+1);
c[i]=a.splice(b[i],1);
}
for(i=1;i<
11;i++)
{
trace("n:"+c[i]);
}
}
var a:Array=new Array("");
var b:Array=new Array("");
var c:Array=new Array("");
main();
function main()
{
for (i=1; i<
11; i++) {
a[i]=i;
}
for (i=1; i<
11; i++) {
var r:Number=a.length-1;
b[i]=Math.floor(Math.random()*r+1);
c[i]=a.splice(b[i],1);
}
for(i=1;i<
11;i++)
{
trace("n:"+c[i]);
}
}
Posted by Sankar.G | Posted in AS3 | Posted on 4:26 PM
var percentage:Number=0;
stage.addEventListener(Event.ENTER_FRAME,BeeMoving);
function BeeMoving(event:Event):void
{
var nLoadedBytes:Number = loaderInfo.bytesLoaded;
var nTotalBytes:Number = loaderInfo.bytesTotal;
percentage= Math.round(nLoadedBytes / nTotalBytes * 100);
BitsLoaded.text = nLoadedBytes+"kbs /"+nTotalBytes+"kbs";
if (nLoadedBytes==nTotalBytes) {
stage.removeEventListener(Event.ENTER_FRAME,BeeMoving);
gotoAndStop(2);
}
}
stage.addEventListener(Event.ENTER_FRAME,BeeMoving);
function BeeMoving(event:Event):void
{
var nLoadedBytes:Number = loaderInfo.bytesLoaded;
var nTotalBytes:Number = loaderInfo.bytesTotal;
percentage= Math.round(nLoadedBytes / nTotalBytes * 100);
BitsLoaded.text = nLoadedBytes+"kbs /"+nTotalBytes+"kbs";
if (nLoadedBytes==nTotalBytes) {
stage.removeEventListener(Event.ENTER_FRAME,BeeMoving);
gotoAndStop(2);
}
}
Posted by Sankar.G | Posted in AS3 | Posted on 5:28 PM
var angle:Number=0.05;
var radian:Number=0;
b1_btn.addEventListener(MouseEvent.CLICK,fun);
function fun(event:MouseEvent):void
{
ball_mc.y=351.9;
ball_mc.x=250;
addEventListener(Event.ENTER_FRAME,one);
function one(event:Event):void
{
angle+=0.05;
radian=Math.sin(angle)*3;
ball_mc.y=(351.9)-radian*180/Math.PI;
ball_mc.x+=2;
if(ball_mc.y>352.9)
{
removeEventListener(Event.ENTER_FRAME,one);
}
}
}
Create 2 MovieClip and Name it as b1_btn & ball_mc
and put this script and click the b1_btn button
var radian:Number=0;
b1_btn.addEventListener(MouseEvent.CLICK,fun);
function fun(event:MouseEvent):void
{
ball_mc.y=351.9;
ball_mc.x=250;
addEventListener(Event.ENTER_FRAME,one);
function one(event:Event):void
{
angle+=0.05;
radian=Math.sin(angle)*3;
ball_mc.y=(351.9)-radian*180/Math.PI;
ball_mc.x+=2;
if(ball_mc.y>352.9)
{
removeEventListener(Event.ENTER_FRAME,one);
}
}
}
Create 2 MovieClip and Name it as b1_btn & ball_mc
and put this script and click the b1_btn button
Posted by Sankar.G | Posted in AS3 | Posted on 5:13 PM
var isKeyOne:Boolean = false;
var isKeyTwo:Boolean = false
stage.addEventListener(Event.ENTER_FRAME, checkTrue);
function checkTrue(event:Event):void
{
if(isKeyOne)
{
test.x--;
}
if(isKeyTwo)
{
test.y--;
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, makeTrue);
stage.addEventListener(KeyboardEvent.KEY_UP, makeFalse);
function makeTrue(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = true;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = true;
}
}
function makeFalse(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = false;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = false;
}
}
Create one MovieClip and Name it as test and Put this Script for Multiple Keyboard Handling
var isKeyTwo:Boolean = false
stage.addEventListener(Event.ENTER_FRAME, checkTrue);
function checkTrue(event:Event):void
{
if(isKeyOne)
{
test.x--;
}
if(isKeyTwo)
{
test.y--;
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, makeTrue);
stage.addEventListener(KeyboardEvent.KEY_UP, makeFalse);
function makeTrue(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = true;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = true;
}
}
function makeFalse(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = false;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = false;
}
}
Create one MovieClip and Name it as test and Put this Script for Multiple Keyboard Handling
Posted by Sankar.G | Posted in APE Engine | Posted on 6:44 PM
package
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import org.cove.ape.*;
public class Test extends Sprite
{
private var wp:WheelParticle;
private var array:Array=new Array("");
private var i:Number;
public function Test():void
{
stage.frameRate = 20;
addEventListener(Event.ENTER_FRAME, run);
APEngine.init(2/4);
APEngine.container = this;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
APEngine.addMasslessForce(new Vector(0,2));
var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);
rp1.sprite.name="rp1";
array.push(rp1);
var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);
rp2.sprite.name="rp2";
array.push(rp2);
var rp3:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp3);
rp3.setFill(0x666666);
rp3.setLine(0, 0xff0000, 1);
rp3.sprite.name="rp3";
array.push(rp3);
for(i=1;i< 4;i++) { array[i].sprite.addEventListener(MouseEvent.MOUSE_DOWN,one); array[i].sprite.addEventListener(MouseEvent.MOUSE_UP,two); } function one(e1:MouseEvent):void { removeEventListener(Event.ENTER_FRAME,run); e1.target.startDrag(); } function two(e2:MouseEvent):void { array[e2.target.name.substr(2)].px=mouseX; array[e2.target.name.substr(2)].py=mouseY; stopDrag(); addEventListener(Event.ENTER_FRAME, run); } function run(evt:Event):void { APEngine.step(); APEngine.paint(); } } } } Example: APE with Dragable.swf
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import org.cove.ape.*;
public class Test extends Sprite
{
private var wp:WheelParticle;
private var array:Array=new Array("");
private var i:Number;
public function Test():void
{
stage.frameRate = 20;
addEventListener(Event.ENTER_FRAME, run);
APEngine.init(2/4);
APEngine.container = this;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
APEngine.addMasslessForce(new Vector(0,2));
var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);
rp1.sprite.name="rp1";
array.push(rp1);
var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);
rp2.sprite.name="rp2";
array.push(rp2);
var rp3:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp3);
rp3.setFill(0x666666);
rp3.setLine(0, 0xff0000, 1);
rp3.sprite.name="rp3";
array.push(rp3);
for(i=1;i< 4;i++) { array[i].sprite.addEventListener(MouseEvent.MOUSE_DOWN,one); array[i].sprite.addEventListener(MouseEvent.MOUSE_UP,two); } function one(e1:MouseEvent):void { removeEventListener(Event.ENTER_FRAME,run); e1.target.startDrag(); } function two(e2:MouseEvent):void { array[e2.target.name.substr(2)].px=mouseX; array[e2.target.name.substr(2)].py=mouseY; stopDrag(); addEventListener(Event.ENTER_FRAME, run); } function run(evt:Event):void { APEngine.step(); APEngine.paint(); } } } } Example: APE with Dragable.swf
Posted by Sankar.G | Posted in APE Engine | Posted on 4:31 PM
package {
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import org.cove.ape.*;
public class Test extends Sprite
{
private var wp:WheelParticle;
public function Test():void
{
stage.frameRate = 20;
addEventListener(Event.ENTER_FRAME, run);
APEngine.init(2/4);
APEngine.container = this;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
APEngine.addMasslessForce(new Vector(0,2));
var rp:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp);
rp.setFill(0x666666);
rp.setLine(0, 0xff0000, 1);
var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);
var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);
wp = new WheelParticle(280,10,25,false,10,0.3,0.1,1);
defaultGroup.addParticle(wp);
wp.setFill(0xff0000);
wp.setLine(0,0xff0000,0);
wp.sprite.addEventListener(MouseEvent.MOUSE_DOWN,down);
wp.sprite.addEventListener(MouseEvent.MOUSE_UP,up);
APEngine.addGroup(defaultGroup);
function down(d1:Event):void
{
removeEventListener(Event.ENTER_FRAME,run);
wp.sprite.startDrag();
}
function up(d2:Event):void
{
wp.px=wp.sprite.x;
wp.py=wp.sprite.y;
stopDrag();
addEventListener(Event.ENTER_FRAME, run);
}
function run(evt:Event):void
{
APEngine.step();
APEngine.paint();
}
}
}
}
Examples:
APE with out Drag.swf
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import org.cove.ape.*;
public class Test extends Sprite
{
private var wp:WheelParticle;
public function Test():void
{
stage.frameRate = 20;
addEventListener(Event.ENTER_FRAME, run);
APEngine.init(2/4);
APEngine.container = this;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
APEngine.addMasslessForce(new Vector(0,2));
var rp:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp);
rp.setFill(0x666666);
rp.setLine(0, 0xff0000, 1);
var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);
var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);
wp = new WheelParticle(280,10,25,false,10,0.3,0.1,1);
defaultGroup.addParticle(wp);
wp.setFill(0xff0000);
wp.setLine(0,0xff0000,0);
wp.sprite.addEventListener(MouseEvent.MOUSE_DOWN,down);
wp.sprite.addEventListener(MouseEvent.MOUSE_UP,up);
APEngine.addGroup(defaultGroup);
function down(d1:Event):void
{
removeEventListener(Event.ENTER_FRAME,run);
wp.sprite.startDrag();
}
function up(d2:Event):void
{
wp.px=wp.sprite.x;
wp.py=wp.sprite.y;
stopDrag();
addEventListener(Event.ENTER_FRAME, run);
}
function run(evt:Event):void
{
APEngine.step();
APEngine.paint();
}
}
}
}
Examples:
APE with out Drag.swf
Posted by Sankar.G | Posted in AS3 | Posted on 11:29 PM
var externalXML:XML=new XML;
var loader:URLLoader=new URLLoader();
var urlrequest:URLRequest=new URLRequest("Data.xml");
loader.load(urlrequest);
loader.addEventListener(Event.COMPLETE,one);
var rows:Number;
var array:Array=new Array();
function one(e1:Event):void
{
externalXML=new XML(loader.data);
rows=externalXML.Employee.Employee_Data.length();
for(var i:uint;i< rows;i++) { array.push({name_arr:externalXML.Employee.Employee_Data[i].@ Names,age_arr:externalXML.Employee.Employee_Data[i].@ Age,id_arr:externalXML.Employee.Employee_Data[i].@Id}); } display(); } function display():void { names.text=ages.text=ids.text=" "; for each(var arr in array) { names.appendText(arr.name_arr+"\n"); ages.appendText(arr.age_arr+"\n"); ids.appendText(arr.id_arr+"\n"); } } arr1_btn.addEventListener(MouseEvent.CLICK,two); arr2_btn.addEventListener(MouseEvent.CLICK,three); function two(e2:MouseEvent):void { array.sortOn("name_arr",array.DESCENDING); display(); } function three(e3:MouseEvent):void { array.sortOn("age_arr",array.DESCENDING|array.NUMERIC); display(); } create 3 text box and name it as names,ages,ids and create 2 buttons and name it as arr1 & arr2 to arrange the values in decending order below we have XML file store the XML file near to the flash file and Name it as Data.xml < Datas>
< Employee>
< Employee_Data Names="a" Age= "10" Id= "13" />
< Employee_Data Names="g" Age= "12" Id= "523" />
< Employee_Data Names="e" Age= "55" Id= "63" />
< Employee_Data Names="w" Age= "22" Id= "403" />
< Employee_Data Names="y" Age= "24" Id= "293" />
< Employee_Data Names="q" Age= "66" Id= "883" />
< Employee_Data Names="o" Age= "97" Id= "813" />
< Employee_Data Names="z" Age= "13" Id= "723" />
< /Employee>
< /Datas>
var loader:URLLoader=new URLLoader();
var urlrequest:URLRequest=new URLRequest("Data.xml");
loader.load(urlrequest);
loader.addEventListener(Event.COMPLETE,one);
var rows:Number;
var array:Array=new Array();
function one(e1:Event):void
{
externalXML=new XML(loader.data);
rows=externalXML.Employee.Employee_Data.length();
for(var i:uint;i< rows;i++) { array.push({name_arr:externalXML.Employee.Employee_Data[i].@ Names,age_arr:externalXML.Employee.Employee_Data[i].@ Age,id_arr:externalXML.Employee.Employee_Data[i].@Id}); } display(); } function display():void { names.text=ages.text=ids.text=" "; for each(var arr in array) { names.appendText(arr.name_arr+"\n"); ages.appendText(arr.age_arr+"\n"); ids.appendText(arr.id_arr+"\n"); } } arr1_btn.addEventListener(MouseEvent.CLICK,two); arr2_btn.addEventListener(MouseEvent.CLICK,three); function two(e2:MouseEvent):void { array.sortOn("name_arr",array.DESCENDING); display(); } function three(e3:MouseEvent):void { array.sortOn("age_arr",array.DESCENDING|array.NUMERIC); display(); } create 3 text box and name it as names,ages,ids and create 2 buttons and name it as arr1 & arr2 to arrange the values in decending order below we have XML file store the XML file near to the flash file and Name it as Data.xml < Datas>
< Employee>
< Employee_Data Names="a" Age= "10" Id= "13" />
< Employee_Data Names="g" Age= "12" Id= "523" />
< Employee_Data Names="e" Age= "55" Id= "63" />
< Employee_Data Names="w" Age= "22" Id= "403" />
< Employee_Data Names="y" Age= "24" Id= "293" />
< Employee_Data Names="q" Age= "66" Id= "883" />
< Employee_Data Names="o" Age= "97" Id= "813" />
< Employee_Data Names="z" Age= "13" Id= "723" />
< /Employee>
< /Datas>
Posted by Sankar.G | Posted in | Posted on 11:49 AM
In AS2.0 we use getNextHighest depth but in AS3.0 we dont have that function for that we have
swapChildren()
swapChildrenAt()
getChildIndex()
setChildIndex()
by using this kind of function we want to create that
Below File is used to you
highestDepth.zip
next.swf
swapChildren()
swapChildrenAt()
getChildIndex()
setChildIndex()
by using this kind of function we want to create that
Below File is used to you
highestDepth.zip
next.swf
Posted by Sankar.G | Posted in AS3 | Posted on 3:59 PM
var min:Number=0;
var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER, myFunction);
min_txt.text=String(min);
function myFunction(event:TimerEvent):void
{
sec_txt.text=String(myTimer.currentCount);
if(myTimer.currentCount==10)
{
myTimer.stop();
myTimer.reset();
myTimer.start();
min=min+1;
min_txt.text=String(min);
}
}
myTimer.start();
Create 2 text box and Name it as sec_txt & min_txt and put this script
var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER, myFunction);
min_txt.text=String(min);
function myFunction(event:TimerEvent):void
{
sec_txt.text=String(myTimer.currentCount);
if(myTimer.currentCount==10)
{
myTimer.stop();
myTimer.reset();
myTimer.start();
min=min+1;
min_txt.text=String(min);
}
}
myTimer.start();
Create 2 text box and Name it as sec_txt & min_txt and put this script
Posted by Sankar.G | Posted in AS3 | Posted on 3:51 PM
var objectArray:Array = new Array();
for (var i:uint = 0;i<
Objects.numChildren;i++)
{
var point:Point = new Point(Objects.getChildAt(i).x , Objects.getChildAt(i).y);
objectArray.push(point);
Objects.getChildAt(i).addEventListener(MouseEvent.MOUSE_DOWN, process);
}
reset_btn.addEventListener(MouseEvent.CLICK, resetAll);
function resetAll(event:MouseEvent):void
{
for(i = 0; i<
Objects.numChildren;i++)
{
Objects.getChildAt(i).x = objectArray[i].x;
Objects.getChildAt(i).y = objectArray[i].y;
}
}
put all the objects in one Movie clip and name it as Objects and write this script
for (var i:uint = 0;i<
Objects.numChildren;i++)
{
var point:Point = new Point(Objects.getChildAt(i).x , Objects.getChildAt(i).y);
objectArray.push(point);
Objects.getChildAt(i).addEventListener(MouseEvent.MOUSE_DOWN, process);
}
reset_btn.addEventListener(MouseEvent.CLICK, resetAll);
function resetAll(event:MouseEvent):void
{
for(i = 0; i<
Objects.numChildren;i++)
{
Objects.getChildAt(i).x = objectArray[i].x;
Objects.getChildAt(i).y = objectArray[i].y;
}
}
put all the objects in one Movie clip and name it as Objects and write this script
Posted by Sankar.G | Posted in AS3 | Posted on 3:49 PM
var url:URLLoader=new URLLoader();
var xml:XML=new XML();
url.addEventListener(Event.COMPLETE,one);
url.load(new URLRequest("one.xml"));
function one(e:Event):void
{
xml=new XML(e.target.data);
two(xml);
}
function two(xml2:XML)
{
var list:XMLList=xml2.Book.children();
for each (var xml3:XML in list)
{
trace(xml3);
}
}
one.xml is a xml file save the xml file in same folder with this file
var xml:XML=new XML();
url.addEventListener(Event.COMPLETE,one);
url.load(new URLRequest("one.xml"));
function one(e:Event):void
{
xml=new XML(e.target.data);
two(xml);
}
function two(xml2:XML)
{
var list:XMLList=xml2.Book.children();
for each (var xml3:XML in list)
{
trace(xml3);
}
}
one.xml is a xml file save the xml file in same folder with this file
Posted by Sankar.G | Posted in AS3 | Posted on 3:20 PM
create a class file and name it as Globe and put this script in class file
package
{
public class Globe
{
public static var temp:Number = 0;
}
}
And in flash AS3.0 file temp is the global variable you can use like this
Globe.temp =5;
package
{
public class Globe
{
public static var temp:Number = 0;
}
}
And in flash AS3.0 file temp is the global variable you can use like this
Globe.temp =5;
Posted by Sankar.G | Posted in AS3 | Posted on 2:43 PM
var i:Number;
for(i=0;i<=(buttonHolder.numChildren-1) ; i++)
{
buttonHolder.getChildAt(i).addEventListener(MouseEvent.CLICK, starter);
}
function starter(e:MouseEvent):void {
var ob=e.currentTarget;
trace(ob.name.substr(1));
}
select all buttons and create a movie clip and name it as buttonHolder and put this script it will work
for(i=0;i<=(buttonHolder.numChildren-1) ; i++)
{
buttonHolder.getChildAt(i).addEventListener(MouseEvent.CLICK, starter);
}
function starter(e:MouseEvent):void {
var ob=e.currentTarget;
trace(ob.name.substr(1));
}
select all buttons and create a movie clip and name it as buttonHolder and put this script it will work
Posted by Sankar.G | Posted in AS3 | Posted on 10:58 AM
var a:Array=new Array();
var b:Array=new Array();
var c:Array=new Array();
var objec:Array=new Array();
var myarray:Array=new Array();
var i:Number;
var temp:Number;
for(i=0;i<
container.numChildren;i++)
{
objec.push(container.getChildAt(i));
}
for(i=0;i<
objec.length;i++)
{
temp=objec[i].name.slice(1);
myarray[temp]=objec[i];
}
for(i=0;i<
container.numChildren;i++)
{
trace(myarray[i].name);
}
Select all MovieClip which are all you want to put in array and create a new Movie Clip and
name it as container and push that container to array and name the movie clip inside the container in line like a1,a2,a3,a4....... like that and slice the array and store the last number in temp and corrosponding object in that array ......
var b:Array=new Array();
var c:Array=new Array();
var objec:Array=new Array();
var myarray:Array=new Array();
var i:Number;
var temp:Number;
for(i=0;i<
container.numChildren;i++)
{
objec.push(container.getChildAt(i));
}
for(i=0;i<
objec.length;i++)
{
temp=objec[i].name.slice(1);
myarray[temp]=objec[i];
}
for(i=0;i<
container.numChildren;i++)
{
trace(myarray[i].name);
}
Select all MovieClip which are all you want to put in array and create a new Movie Clip and
name it as container and push that container to array and name the movie clip inside the container in line like a1,a2,a3,a4....... like that and slice the array and store the last number in temp and corrosponding object in that array ......
Posted by Sankar.G | Posted in AS3 | Posted on 11:03 AM
import flash.utils.getDefinitionByName;
var i:Number;
for(i= 1;i<4;i++)
{
var myCube:Class = getDefinitionByName("Cube" + i) as Class;
var cube:Object = new myCube();
cube.name = "cube" + i;
addChild(DisplayObject(cube));
cube.x = i * 100;
cube.y = i * 100;
cube.addEventListener(MouseEvent.ROLL_OVER,eventfunction);
}
function eventfunction(event:MouseEvent):void
{
var bc=(event.target.name.substr(4));
trace("cube"+bc);
getChildByName("cube"+bc).addEventListener(MouseEvent.MOUSE
_DOWN,fun);
getChildByName("cube"+bc).addEventListener(MouseEvent.MOUSE
_UP,fun1);
}
function fun1(e:Event)
{
var ob=e.target;
ob.stopDrag();
}
function fun(e1:Event)
{
var ob1=e1.target;
ob1.startDrag();
}
create 5 Different Movie Clip in flash and name it as cube1,cube2,cube3,........ and give link name and same cube1,cube2,cube3...... and put this script it will work
var i:Number;
for(i= 1;i<4;i++)
{
var myCube:Class = getDefinitionByName("Cube" + i) as Class;
var cube:Object = new myCube();
cube.name = "cube" + i;
addChild(DisplayObject(cube));
cube.x = i * 100;
cube.y = i * 100;
cube.addEventListener(MouseEvent.ROLL_OVER,eventfunction);
}
function eventfunction(event:MouseEvent):void
{
var bc=(event.target.name.substr(4));
trace("cube"+bc);
getChildByName("cube"+bc).addEventListener(MouseEvent.MOUSE
_DOWN,fun);
getChildByName("cube"+bc).addEventListener(MouseEvent.MOUSE
_UP,fun1);
}
function fun1(e:Event)
{
var ob=e.target;
ob.stopDrag();
}
function fun(e1:Event)
{
var ob1=e1.target;
ob1.startDrag();
}
create 5 Different Movie Clip in flash and name it as cube1,cube2,cube3,........ and give link name and same cube1,cube2,cube3...... and put this script it will work
Posted by Sankar.G | Posted in AS3 | Posted on 11:45 AM
stop();
var speedx:Number=0;
var speedy:Number=0;
var fri:Number=0.98765;
var radius:Number=ball_mc.height/4;
var ax:Number=0;
var ay:Number=0;
var gravity:Number=2.5;
addEventListener(Event.ENTER_FRAME,pull);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydown);
stage.addEventListener(KeyboardEvent.KEY_UP,keyup);
function pull(e:Event) {
speedy+=gravity;
speedx+=ax;
speedy+=ay;
speedy*=fri;
speedx*=fri;
ball_mc.y+=speedy;
ball_mc.x+=speedx;
if (ball_mc.y+radius>stage.stageHeight) {
ball_mc.y=stage.stageHeight-radius;
speedy*=-1;
} else if (ball_mc.y-radius<0) { ball_mc.y=radius; speedy*=-1; } else if (ball_mc.x>stage.stageWidth)
{
ball_mc.x=stage.stageWidth-radius;
speedx*=-1;
}
else if(ball_mc.x-radius<0) { ball_mc.x=radius; speedx*=-1; } } function keydown(e:KeyboardEvent):void { switch (e.keyCode) { case Keyboard.LEFT : ax = -1; break; case Keyboard.RIGHT : ax = 1; break; case Keyboard.UP : gravity = 0; ay = -0.5; break; case Keyboard.DOWN : ay = 1; break; } } function keyup(e:KeyboardEvent):void { gravity = 1; ax = 0; ay = 0; } Examples: Gravity in AS3.swf
var speedx:Number=0;
var speedy:Number=0;
var fri:Number=0.98765;
var radius:Number=ball_mc.height/4;
var ax:Number=0;
var ay:Number=0;
var gravity:Number=2.5;
addEventListener(Event.ENTER_FRAME,pull);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydown);
stage.addEventListener(KeyboardEvent.KEY_UP,keyup);
function pull(e:Event) {
speedy+=gravity;
speedx+=ax;
speedy+=ay;
speedy*=fri;
speedx*=fri;
ball_mc.y+=speedy;
ball_mc.x+=speedx;
if (ball_mc.y+radius>stage.stageHeight) {
ball_mc.y=stage.stageHeight-radius;
speedy*=-1;
} else if (ball_mc.y-radius<0) { ball_mc.y=radius; speedy*=-1; } else if (ball_mc.x>stage.stageWidth)
{
ball_mc.x=stage.stageWidth-radius;
speedx*=-1;
}
else if(ball_mc.x-radius<0) { ball_mc.x=radius; speedx*=-1; } } function keydown(e:KeyboardEvent):void { switch (e.keyCode) { case Keyboard.LEFT : ax = -1; break; case Keyboard.RIGHT : ax = 1; break; case Keyboard.UP : gravity = 0; ay = -0.5; break; case Keyboard.DOWN : ay = 1; break; } } function keyup(e:KeyboardEvent):void { gravity = 1; ax = 0; ay = 0; } Examples: Gravity in AS3.swf
Posted by Sankar.G | Posted in AS3 | Posted on 12:19 PM
add this code in flash class script file and save this file as checking.as
class checking
{
var mc:MovieClip;
var t1:TextField;
var t2:TextField;
var re:TextField;
public function main(mc,t1,t2,re)
{
mc.onPress=function()
{
var a:Number;
var b:Number;
var c:Number;
a=parseInt(t1.text);
b=parseInt(t2.text);
c=a+b;
re.text=c;
}
}
}
In stage create a 3 text box 2-input text box name(text1 & text2) & 1 - dynamic text box name(res) and create a button name(ball3)and write this code in a frame
code:
var ch:checking=new checking();
ch.main(ball3,text1,text2,res);
and save it as checking.fla
class checking
{
var mc:MovieClip;
var t1:TextField;
var t2:TextField;
var re:TextField;
public function main(mc,t1,t2,re)
{
mc.onPress=function()
{
var a:Number;
var b:Number;
var c:Number;
a=parseInt(t1.text);
b=parseInt(t2.text);
c=a+b;
re.text=c;
}
}
}
In stage create a 3 text box 2-input text box name(text1 & text2) & 1 - dynamic text box name(res) and create a button name(ball3)and write this code in a frame
code:
var ch:checking=new checking();
ch.main(ball3,text1,text2,res);
and save it as checking.fla
Subscribe to:
Posts (Atom)