Posted by: Yogesh Puri on: June 2, 2009
FFDMag had excellent magazine for flash and flex programmers having articles ranging from Beginner Level to expert levels. Just check some of the topics below
You can subscribe this magazine from the following link
Posted by: Yogesh Puri on: December 20, 2008
I have faced a problem when i tried to have a canvas with rounded corner and having an image. I doesn’t want to make the rounded corners in image as the content is going to be scaled. After doing some research on Net i found a good solution to the problem. it is a kind of trick where you put the rounded corner canvas as a mask on your image and it works perfectly
. Following is the code for the same
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Image source="../bin-debug/assets/bg.jpg" x="10" y="10" mask="{maskCanvas}" height="80%" width="80%" maintainAspectRatio="false" />
<mx:Canvas id="maskCanvas" x="10" y="10" width="80%" height="80%" cornerRadius="10" borderStyle="solid">
</mx:Canvas>
</mx:Application>
Do remember to create an asset folder having a “bg.jpg” image when trying this solution.
Posted by: Yogesh Puri on: November 7, 2008
A very nice utility
Sub CreateListOfSheetNames()
Set wkbkToCount = ActiveWorkbook
iRow = 1
With Sheets.Add
For Each ws In wkbkToCount.Worksheets
.Rows(iRow).Cells(1).Value = ws.Name
ActiveSheet.Hyperlinks.Add Anchor:=.Rows(iRow).Cells(1), Address:="", SubAddress:= _
ws.Name & "!A1", TextToDisplay:=ws.Name
iRow = iRow + 1
Next
End With
End Sub
Posted by: Yogesh Puri on: October 21, 2008
Following is a code to remove a child from a parent by passing it’s instance name as a string and parent as a display object
import fl.controls.Button;
//———– Draw a graphics on the stage ———-
var t:Sprite = new Sprite();
t.name = “testSprite”;
t.graphics.lineStyle(1,0×0000ff);
t.graphics.beginFill(0xff0000);
t.graphics.drawCircle(0,0,50);
t.graphics.endFill();
addChild(t);
t.x =100;
t.y = 100;
//———– Remove Child Function ————–
function removeChildWithRef(spriteName:String, parentObj:*){
var t:DisplayObject = parentObj.getChildByName(spriteName);
parentObj.removeChild(t);
}
//————- Add a Button to Stage ————
var tBtn:Button = new Button();
tBtn.label = “Remove Circle”;
tBtn.x = 50;
tBtn.y = 170;
tBtn.addEventListener(MouseEvent.CLICK,onClick);
addChild(tBtn);
//———— Capture Click Event ————-
function onClick(evt:MouseEvent){
removeChildWithRef(“testSprite”,this);
}
Posted by: Yogesh Puri on: October 10, 2008
While reading a book i come to a very interesting topic which i would like to share here
———————–
By default, The bitmap instances that reference a given BitmapData object are notified every time setPixel32( ) or setPixel( ) is called on that object. When setPixel32( ) or setPixel( ) are used in rapid succession within the same frame cycle—such as when setting the color of every pixel in a bitmap—these notifications can reduce performance. To improve performance, we can use the BitmapData class’s instance method lock( ).
Calling lock( ) on a BitmapData object forces ActionScript to not notify dependent Bitmap objects when executing setPixel32( ) or setPixel( ). Hence, before using setPixel32( ) or setPixel( ) in rapid succession, always call lock( ). After calling lock( ), assign all desired pixel color values; then call the BitmapData( ) class’s instance method unlock( ). Calling unlock( ) instructs ActionScript to notify all dependent Bitmap objects as necessary.
Example below demonstrates the approach. The example uses a loop to assign a random color to every pixel in a 500 × 500 BitmapData object. Notice the call to lock( ) before the loop and unlock( ) after the loop.
Posted by: Yogesh Puri on: October 9, 2008
The following code is solution to a problem where you need to make the accordion component’s MouseOver event to behave like a click event. The code will work only in the case if you have not given the names to the AccordionHeader explicitly. Check the solution out here
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
public function onMouseOver(evt:MouseEvent):void{
var strName:String = evt.target.name;
var strLen:int = String("_header").length;
if(strName.indexOf("_header") > -1){
accordion.selectedIndex = int(strName.substr(strLen,strName.length));
}
}
]]>
</mx:Script>
<mx:Panel title="Accordion Container Example" height="90%" width="90%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Label width="100%" color="blue"
text="Select an Accordion navigator button to change the panel."/>
<mx:Accordion id="accordion" width="100%" height="100%" mouseOver="onMouseOver(event)" >
<!-- Define each panel using a VBox container. -->
<mx:VBox label="Accordion Button for Panel 1">
<mx:Label text="Accordion container panel 1"/>
</mx:VBox>
<mx:VBox label="Accordion Button for Panel 2">
<mx:Label text="Accordion container panel 2"/>
</mx:VBox>
<mx:VBox label="Accordion Button for Panel 3">
<mx:Label text="Accordion container panel 3"/>
</mx:VBox>
</mx:Accordion>
<mx:Label width="100%" color="blue"
text="Programmatically select the panel using a Button control."/>
<mx:HBox>
<mx:Button label="Select Panel 1" click="accordion.selectedIndex=0;"/>
<mx:Button label="Select Panel 2" click="accordion.selectedIndex=1;"/>
<mx:Button label="Select Panel 3" click="accordion.selectedIndex=2;"/>
</mx:HBox>
</mx:Panel>
</mx:Application>
Posted by: Yogesh Puri on: September 26, 2008
The post contains a solution for a case where you need to attach a Library symbol and you have to pass that class name as a string to the function.
The approach followed here is by using the getDefinitionByName utility which interprets the string and convert it into a Class. Then you can use a new syntax with that particular class. Following is a code for the same solution and you can download the source files from here. The “testMC” here is a movieClip in library with the className as testMC and BaseClass as flash.display.MovieClip
import flash.utils.getDefinitionByName;
function addMovieFromLibrary(mcIName:String){
var tMC:Class = getDefinitionByName(mcIName) as Class;
var newMc:MovieClip = new tMC() as MovieClip;
addChild(newMc);
}
addMovieFromLibrary("testMC");
Posted by: Yogesh Puri on: September 23, 2008
Adobe had released the Flash CS4 professional edition at a preorder price of $699. Following are the Some of highlighted features
Check here for more details
http://www.adobe.com/products/flash/features/?view=topnew&promoid=DRHWS
Posted by: Yogesh Puri on: September 23, 2008
I have developed this XMLUtility class in conjunction with a CustomEvent Class which returns me the loaded XML/String Data along with the complete event firing. You can download the sources from here. Following is the code you need to write when you want to load this class
//------------ Import Classes
import com.flexcomps.utils.CustomEvent;
import com.flexcomps.utils.XMLLoaderUtil;
//-------- Create instance of loader class
var xmlLoader:XMLLoaderUtil = new XMLLoaderUtil();
xmlLoader.addEventListener(CustomEvent.ONLOADED, onXMLLoaded);
xmlLoader.load(xmlPath);
//----- Method to handle the returned data
private function onXMLLoaded(evt:CustomEvent) {
xmlData = evt.data as XML;
trace(xmlData);
}
Recent Comments