Showing posts with label optimize. Show all posts
Showing posts with label optimize. Show all posts

Saturday, July 6, 2013

Difference in accessing MovieClips on TimeLine and in ActionScript




I am always curious about how things happen. In flash I had a confusion as there is difference in accessing MovieClips on Timeline and accessing MovieClips in ActionScript. So somewhere on web I found this answer. I’ve just copy and pasted it here. Thanks to person “x” who explained this.


In Flash 9 when you create MovieClip instance on the Timeline and give it an instance name, you are doing two things:
  1. You're assigning the name property of the MovieClip instance to be the string equivalent to the instance name provided
  2. You're creating a variable in the current timeline with the name of the instance name that references that MovieClip instance

Flash does this behind the scenes when you publish your SWF to help you manage your movie clips on the screen. It's important to note that this behavior (specifically #2) is not seen with ActionScript. For Example:
Code:
// my_mc is the instance name of a movie clip
// created on this timeline
trace(my_mc); // [object MovieClip]
trace(my_mc.name); // my_mc

// create a new movie clip via AS
// add it to my_mc
var another_mc:MovieClip = new MovieClip();
another_mc.name = "child_mc";
my_mc.addChild(another_mc);

// instance name not available in parent timeline
trace(another_mc);  // [object MovieClip]
trace(my_mc.child_mc); // undefined
trace(my_mc.another_mc); // undefined
You can see that neither the instance name (name property) nor the variable to which the new MovieClip created with ActionScript was assigned is referencable through the movie clip in which it was added (my_mc). This is because another_mc was created and added to the timeline dynamically. Flash will only save instance names as variables for movie clips created on the timeline in Flash.

If you want to use an instance name to get a MovieClip (or any DisplayObject) instance from the timeline in which it exists, you can use getChildByName();
Code:
trace(my_mc.getChildByName("child_mc"));  // [object MovieClip]);
This will work for all movie clips despite where or how they were located as long as they are within the timeline/movie clip from which getChildByName was used.


Enjoy ActionScripting.................

Sunday, June 24, 2012

Useful tool: Size report



What you will learn
• How to generate size report of flash movie.
• How to check size of each object, on each frame.


Hello readers,

After a couple of months, i came here with couple of articles.
Here we will see, how to generate size report of flash movie.
Size report is one of the important feature of Adobe Flash. As Your flash movie contain lot of objects, sound, movieclips, bitmaps, graphics, embedded text, actionscript code. Each object allocates its size in swf file. By generating size report, you will get detailed information about size of each object used in fla. Size Reports allow you to troubleshoot and find the elements in your swf movie that causes an increase in the overall file size. Which could be help you to optimize flash file size.

How to publish size report
To publish a Size Report
  1. Go to File > Publish Settings.
  2. Click on the Flash Tab.
  3. In the Flash tab go to Advance section and select Generate Size Report.
  4. Click on Publish to generate a size report Or Click OK to get out of the Publish Setting Dialog.
  5. Come to your folder where Fla files are being saved and locate the size report document “Fla file name”+ Report.txt.
  6. Open the size report by double clicking.
  7. After compiling flash movie, you will notice the size report is being generated in output panel.
Figure 1. Size Report in Publish Settings.



The report contain following sections,
  • Frame: This explains how much size each frame contains.
  • Scene: This explains how much size each object contains in that scene.
  • Symbol: This section explains file size of all the MovieClips, Buttons and Graphic Symbols in file. This section also lists any components that used in file.
  • Font: This section lists embedded fonts and their glyphs used in the file. You will get size of font, name of the embedded font and the characters in that font that are available.
  • ActionScript: This section shows the size in bytes of any actionScript in file.
  • Bitmap: This is a very useful section to check if you are embedding any bitmaps in file. Here you will get the name of bitmap in library panel. Original file size, Compressed file size and Compression ratio of JPEG Quality.
Hope this will help you to enjoy Flash and ActionScripting.


Friday, June 17, 2011

How to create custom events

Hey..!!! Check out my article on How to create custom event on actionscript.org

Click here for more details.


Sunday, April 25, 2010

About Coding Standards

Flash applications are generally built without coding standards whrere as flex applications have some standard.
Next version of Flash (CS5) have code hinting properties where as Flex already have it.
This flexibility allows solutions to variety of  problem.
It is very difficult for anyone to understand others code. Even sometimes when code becomes wast author may have difficulty for reading his or her own code.
If a developer unable to understand the code in an application, it will not be easy to debug the code, make changes, or reuse the code.

Optimization is also one of the important factor, while you are playing with Flash, Flex or ActionScript.

Here are some useful links i found while surfing on net.

Coding Standards:
http://www.rivellomultimediaconsulting.com/files/presentations/2012/BestPractices_Coding_v1.1.pdf
http://download.macromedia.com/pub/devnet/downloads/actionscript_standards.pdf

Video:
http://www.adobe.com/devnet/flash/articles/flash_to_video.html

Image:
http://www.kirupa.com/forum/showthread.php?320007-Image-Quality-in-Flash

Optimaization:
http://www.kirupa.com/forum/showthread.php?339677-Optimise-the-game
http://gamedev.michaeljameswilliams.com/2010/02/10/optimise-as3-for-speed/
http://osflash.org/as3_speed_optimizations
http://lostinactionscript.com/2008/09/28/tips-on-how-to-write-efficient-as3/
http://wiki.joa-ebert.com/index.php/Category:Code_Optimization
http://board.flashkit.com/board/showthread.php?t=788271