Sql :: Optimizing Saving To An Sqlite DB?

Dec 8, 2011

I have an as3 app which utilises an sqlite db to save metrics data. It is well known that as3 is single threaded, so when I save to this db, the Stage Video I am playing becomes jumpy! I have heard that saving db data in batches can speed up this process so I save in a loop:

for (var i:int=0; i < metricsObject.metricsComponentData.length; i++){
switch (metricsObject.metricsComponentData[i].mouseType) {
case MetricsCollator.MOUSE_OVER:
this._query_txt = "INSERT INTO " + this._tablePath[0] + " VALUES (null, " + this._sessionID +

[code]...

I have looked into pseudo threading examples but they all require a sprite or stage instance, the class I am executing this code in, is not a display class, I don't really want to pass an instance of the stage into this class.

View 1 Replies


Similar Posts:


Flex :: Saving And Loading Image To Local SQLite BLOB ?

Sep 8, 2011

I need to be able to save and load images into an SQLite database using Flex 4.5 for a mobile application. The use case is this:

Inside the view there is a spark Image object with a URL as a source

When user clicks button, the Image is saved to an SQLite db inside a BLOB field.

In a separate Image, the source is set to the ByteArray stored in the db.

The biggest question so far is this: where do I get the ByteArray for a loaded Image? I've tried debugging and inspecting Image, BitmapImage, and BitMapData but there's no sign of the byte array.... perhaps it's inside the ContentLoader? But that's null unless I enable caching.

I've done some research and there are no complete examples for how to handle this. I've written a simple View that anyone can copy and paste into a new project. It will compile without errors and can be used for testing. I will update this code as I get the answers I need so that anyone can have a fully working example of this workflow.The only caveat: I used a synchronous connection to the DB to avoid complicating the code with event handlers, I wanted to keep it as simple as possible.I will only mark this question as answered once it is fully functioning both ways.

UPDATE SEPT. 09 2011: The code below is now fully functioning in both directions (save and load). Here are some of the things I've learned: It turns out that the ByteArray of a spark Image can be found inside the LoaderInfo of the image itself. Like this:

image.loaderInfo.bytes

However, trying to set this ByteArray as the source of another image ( image2.source = image1.loaderInfo.bytes) results in this security error: Error #3226: Cannot import a SWF file when LoaderContext.allowCodeImport is false.Which is too bad because it would save so much time and processing power.the workaround is to encode the ByteArray using either a JPEGEncoder or a PNGEncoder. I used the JPEGEncoder which produces much smaller files. Here's how:

var encoder:JPEGEncoder = new JPEGEncoder(75);
var imageByteArray:ByteArray = encoder.encode(imageToSave.bitmapData);

Now the problem is saving these bytes to the DB. Saving them as they are now will not work once we read them out, I'm not sure why. So the solution is to encode them into a base64 string like this:

var baseEncoder:Base64Encoder = new Base64Encoder();
baseEncoder.encodeBytes(imageByteArray);
var encodedBytes:String = baseEncoder.toString();

So now just save that string into the BLOB field and later read it out. However, you have to decode it from a base64 string to a ByteArray like this:

var encodedBytes:String = result.data[0].imagedata;
var baseDecoder:Base64Decoder = new Base64Decoder();
baseDecoder.decode(encodedBytes);
var byteArray:ByteArray = baseDecoder.toByteArray();

Now assign the bytearray as the source of your image and you're done. Simple right?if you find any optimizations or alternative ways to do this.I will respond and keep this code updated if need be.

View 2 Replies

Flex :: Sqlite - Saving A File In Flex Air?

Aug 15, 2010

I'm trying to copy my SQLite file that is used in my Air app to user's selected directory using

var fileSaveDest:FileReference = new FileReference();
fileSaveDest.save(dbWorkedFile,'Inventory.DB');
dbWorkedFile is a File
dbWorkedFile = File.documentsDirectory.resolvePath("Inventory.db");

I tried this but the saved file isn't a valid SQLite file. Also, I was wondering whether it's possible to embed SQLite to Air? If so how can I import and export the database?

View 2 Replies

Flash CS4 Optimizing Files?

May 15, 2010

i want to create some crazy sites with Flash i created the site in Photoshop and then i imported the psd into flash but i come in one post that i should optimizing the content before publishing on internet but how and why should i do that??

View 3 Replies

Optimizing PSDs To Use In Flash

Jun 13, 2009

It seems to me everytime I export a PSD design into flash the images come out a little pixelated. Granted I do use 72 dpi though I thought that was the webstandard. By using flash can I use higher dpi images? Or is there another method I should be using instead of the direct import to lirbary?

View 5 Replies

ActionScript 3.0 :: Optimizing Demands On CPU?

Sep 28, 2009

Some AS operations are more CPU intensive than others. What are good ways to compare operations so that I can see for myself how demanding something is? Are there built-in AS3 methods for tracing system use or CPU use? Are there non-flash tools that people use?

View 2 Replies

Sound At Beginning Of 2 Scenes And Optimizing

Nov 10, 2009

I have created a X-mas card for my company. When the card opens, the 3 circles are buttons to different scenes within Flash. The text in the bottom left is a button to the final scene.

The card can be viewed here: [URL]

1) When I click on the circle button that has the red garland and tree ornaments in it, if you listen close at the very beginning of the scene, a squeek sound plays. I use this squek sound in the hamster wheel movie symbol used in other scenes, but not in this scene. I don't even have the sound in this scene of the Flash project anywhere. I can not figure out where it is coming from.

2) Does anyone have some optimization tips? My project file is huge and a lot of the people we will be sending this out to probably don't have the most up-to-date processers. Should I split each scene into it's own Flash movie that is only loaded when the button for that scene is selected instead of the whole thing loading?

Here is a link to view the .FLA file: [URL]

View 1 Replies

Optimizing All Static Bitmaps / MovieClips?

Jun 25, 2009

I'm working on a flash website that consists of 3 frames (1 = preloader, 2 = instances of symbols, 3 = the main page/view). I've gone through and optimized all my static bitmaps/movieClips and removed any symbol that I've exported for ActionScript from exporting in the first frame. Even after all these steps frame one is still the longest to load (797kb on a 32.6 kbps simulated download), only showing the preloader when the whole file is at 86% complete. Any further steps to take to get frame one's size down?

View 3 Replies

Professional :: Optimizing Movie Clips?

Feb 1, 2010

I'm working with a few .flv movie clips in my timeline based flash file. I've imported and embedded the files into movieclip symbols. My file is now sluggish and close to 10mgb.What's the best way to optimize the videos so my .fla and final .swf are as small as possible?

View 5 Replies

Professional :: Optimizing FLA Files For SWF Output?

Mar 16, 2012

This question was posted in response to the following article: [URL]..

View 4 Replies

ActionScript 3.0 :: Optimizing My Search XML Function?

Dec 23, 2009

I've got this simple GUI that has a search box and a couple result fields for "Word" and "Definition"...I've also got an XML file with about 800 or so terms and definitions.Currently the flash works just fine, it reads in the XML glossary, splits it into a word array and definition array and when I search through it, it creates a List filled with terms that match the string that I search for. We wanted it to update the list of possible matching terms each time you changed the search term: a, ap, app, appl, apple... etc.

Everything works, its just incredibly slow when you throw 800 terms at it to search through.I was wondering if anyone could either optimize my search somehow, show me another way of doing it.Here is the code pulled from the whole GUI.

ActionScript Code:
var glossary_xml:XML;
var xmlReq:URLRequest = new URLRequest("glossary.xml");[code].........

View 6 Replies

ActionScript 3.0 :: Optimizing Bitmapdata Using Netstream?

May 29, 2010

you can see my project here:

[URL]

It uses bitmap data to draw each frame of the video, which is streamed using the netstream class. My question is - how can I optimise the speed at which it plays? It plays fine when the stage is small, but when on full screen it starts to get jerky.

View 3 Replies

Actionscript 3.0 :: Optimizing Graphics Rendering?

Jul 27, 2010

My app draws a handful of very large Shapes to the screen very frequently. I've already implemented some logic to reduce that frequency in certain situations, but I'm wondering whether there is anything else I can do.My Shapes' graphics are basically rectangles with BitmapData fills. (Smoothing's turned off.) I can use some simple logic to find the regions where their boundary rectangles intersect the Stage. If I redraw my Shapes' graphics so that they only draw to those intersections, will my app take less time to render?

View 2 Replies

ActionScript 2.0 :: Optimizing Code Execution?

May 7, 2002

I have written a small bit of actionscript code which is designed so that small objects fly across a window from left to right at varying speeds, and then get moved back again with different attributes once they reach the right edge. The code is fully functional.My problem is that this eats a huge amount of system resources, and runs slowly on a 1Ghz machine. Is there a more efficient way to achieve this?

//Frame 1 Code - create 20 objects of varying scale, x/y position and alpha.

dcount = 1;
dupcount = 20;
while (dcount<=dupcount) {[code]......

View 1 Replies

ActionScript 3.0 :: Optimizing Code For Removing Lag?

Oct 14, 2011

I recently completed the battle engine for my game.But the problem is that it is lagging horribly.optimize the code(because the graphics I'm using are really very basic)

View 13 Replies

Professional :: Best Practices For Optimizing A Transparant Png Image?

May 8, 2010

What are the best practices for optimizing a transparant png image? What things can be done to make such a png file as small as possible without loosing to much of its quality? Best tools? Best Photoshop plugins? Other tips?

View 2 Replies

ActionScript 3.0 :: Optimizing Short Code With XML Objects

Jul 14, 2010

I'm trying to take into account the Garbage Collector (GC), so I decide to optimize this code:[code]For instance, is it useful to put "xmlOne = null" in every iteration?  I'm checking with the Flashdevelop's profiler, but I don't see the difference.maybe, I can also reuse the item object rather than creating it every time, right?

View 1 Replies

ActionScript 3.0 :: Optimizing Flash File For Internet?

Sep 28, 2010

I have a 10MB flash file that I have uploaded to my website. No idea if this is large or small for a Flash file! The Flash appears on my index.html page. I have noticed that different browsers react differently, but when I open the page initially the video does not start playing straight away.

View 13 Replies

Unknown Error Optimizing Byte Code

Sep 29, 2010

We have a big project, which include about 700 classes and based on Robotleg frameworks.at some point looks we reach some limitation of flash ide, we got this error and can't render properly.[url]...

View 1 Replies

Flex :: Reduce SWF Filesize By Optimizing The Code?

Jan 26, 2011

Considering we have already done the following actions:

Flex Framework as RSL
Compiling with debug=false
Loading most images at runtime
Drawing other simple images with flash draw features

[code].....

We believe we spent a lot of time into asset optimization and most of the work is remaining on the code.By analyzing our link-report, our guess is that the heavy part of the code is comming from Flex .mxml nested components. We don't think there is much to do on our pure AS classes.Is there any analysis or coding best practice in order to reduce the impact of the code on the swf filesize ?

View 3 Replies

Actionscript 3 :: Optimizing Collision Detection Code?

Aug 9, 2011

I have two mc's on the stage, the first one is called missiles and the second one is called boxes. So accordingly I put boxes in the boxes mc and missiles in the missiles mc. My problem is how to detect whether any of the missiles collide with boxes and make damage to the box.

I am using simple and effective algorithm which works but it is very slow when there are many missiles and boxes on stage. I am using two nested "for" cycles which is a bad practice, but I don't have other idea at the moment.

Here is the code

public function onEnterFrame(e:Event) {
for(var i:int=0;i<ground_mc.boxesLayer_mc.numChildren;i++){
mc1=ground_mc.boxesLayer_mc.getChildAt(i);
for(var j:int=0;j<ground_mc.bmLayer_mc.numChildren;j++){

[code].....

Are there other techniques to solve this problem. I have already tried to add detection code in every missile but it is also slow with "for".

View 3 Replies

Actionscript 3 :: Flash - Optimizing Collision Detection

Oct 25, 2011

I'm trying to make my first game in Actionscript 3. Its a simple artillery game where you have a gun at bottom left corner and AIs flying across the screen which you have to shoot down. Now, in a classing shooter game how this is achieved is either by firing a bullet from the gun and doing a hitTest of that bullet with the AI movieClip or by simply removing(or playing the death animation) the AI movieclip. But here's the problem. I dont wanna do either of them. I want to show a gun with a rapid fire rate and hence no bullets. And I also don't want the player to click exactly ON the AI movieclip to destroy them (just the gun/turret pointing at the correct direction should be enough). So here's what I tried. This image should help picture the whole thing.

Tried attaching a 'line' to the turret and checking for collision with AI clip. This obviously failed because of the bounding box problem when the line is slanting.
I tried putting multiple tiny movieClips ON the line and iterate through them in a loop and checking for any collision with the AI. This method partially worked, but it was too slow and didn't seem like the 'correct' method. I draw 2 hypothetical lines. One between p1 and p2 and other connecting p3 and p4 (please see the image above). p3----p4's lenght = AI.width and is a horizontal line running right through the center of the AI MovieClip. Upon mouseClick I check for any intersection between these two lines. Now if I have multiple AIs on the screen, Again i need to iterate through each of them, draw a fresh p3-----p4 and check for intersection with p1-----p2.

[Code]....

View 1 Replies

Flex :: Optimizing Application - Where To Find Bottlenecks

May 29, 2009

My Flex web application is almost ready for launch. I'm currently optimizing as much as I can in order to make sure even low-end clients are able to run it fluently. The problem is, I have no idea where to optimize more than I've already optimized. My question is, what are the usuals suspects regarding bottlenecks? What tips and experiences do you have when it comes to Optimizing a Flex app?

View 4 Replies

ActionScript 3.0 :: Optimizing Code Button Array

Nov 16, 2009

[code]I'm pretty sure I could just run a for loop and add the listeners and settings for each button that way, but what would it take to do this, if the buttons are added on the stage's timeline, they're not added via actionscript.Should I just create an array in AS with each name as an object in the array? [code]Or should I add the dynamic text field inside of the button MovieClip and just change the text to "A", "B", "C" etc in the For loop, as well as setting the mouseEnabled property to false? That way, I don't even need the buttonText array at all.

View 6 Replies

Flash 10 :: Optimizing A Large Vector Movieclip?

Apr 3, 2011

I have an extremely complicated (10 frames, 3 layers, around 200 objects per layer) vector object, and wish to create 5 instances of this object in my SWF simultaneously. Unsurprisingly, attempting such a feat causes my program to slow down dramatically.

I can freely combine the layers, convert to bitmap or whatever is needed, although the object is very often rotated in my ActionScript code, and is at the third layer of a much larger object. What would be the best (reasonably fast, as I need to repeat this process 10 times, on 10 seperate frames each time) way to optimise this object to increase the run speed without hitting load times too drastically? (The size of the object in question is 7x700 'pixels')...

View 1 Replies

ActionScript 3.0 :: Optimizing Multiple Scrolling MovieClips?

Aug 19, 2011

I'm currently working on a project for a client who just keeps adding and adding more and more visuals and functionality (while developing!) to an already complex website . The website is very high-end with a lot of 3d rendered PNG-sequences and looks beautiful, but as you can imagine my flash-project is getting cluttered and becoming very slow at runtime very fast.

For a small baseline: I am currently working with swf files of 15mb a piece (the site will have multiple sub-sites). Each with full-browser moving bitmaps, movieclips and png-sequences. Anyway, the site layout at this point: I have multiple sprites layered on top of each other. These will, based on the mouse position, move parralax-style to simulate depth. Within these sprites I have the following visual contents:

a. a static PNG which acts as a static visual. This PNG is duplicated multiple times within the sprite (tiled) to make sure that the visual is browser-filling.

b. a moving PNG-sequence using this solution from the guru's at greensock: forums.greensock.com/viewtopic.php?f=1&t=4243&p=16835#p16835

c. a multiple of movieclips which act as buttons displayed at various positions within the parralax-moving scene, these buttons popup new screens and load external content.

Currently I've managed to fix all the parralax sprites through the scrollrect option, with only the bare minimum of each animation visible at the same time (the scrollrect is always as big as the max sprite height and max screen width), but because of the visual madness of the website, the swf still runs as fast as a tortoise on ritalin.

View 3 Replies

ActionScript 2.0 :: Optimizing XML To Increase Loading Speed

Jul 9, 2007

I was wondering how to optimize my XML to increase it's load speed. I am using XML to load articles onto stage. Now they load, but one article in particular takes over 20 seconds when I test it on my machine which leads me to believe that is flash player that is choking.

View 14 Replies

ActionScript 3.0 :: Implementing Invisible Buttons - Optimizing Performance

Feb 6, 2009

I know of a couple of methods of implementing an invisible button or "hotspot" or clickable area:
1) Draw a fill region on a Sprite with an alpha of 0.
2) Create a Button with only a hitArea
Which method would be less resource intensive? Since Adobe recommends against using too much alpaha, I image (2) is better. Are there other methods which could be even less resource intensive? In the movie I am doing, there will be many of these on the screen so optimziing for performance is important.

View 4 Replies

Removing Unused Items / Optimizing File Size?

Jun 3, 2009

I have a large swf that is embedded in Director as a sprite I now want to put it onto a web page, so file size is critical Is there a way to remove unused library items when publishing so that file size is reduced?  Is there another way to compress the swf so it is much smaller?The current size is about 25 Mb.What about streaming the swf?I'm not talking about streaming video or audio, just any Flash content.In Director, there is a way to right-click on a cast member and choose "find in score".If something isn't found it means that it either is not used in the movie or is implemented through code

View 3 Replies

Professional :: Optimizing Flash Graphics - Use Filters Or Vectors?

Mar 28, 2011

I'm trying to lighten the load on the users' machine as much as possible. Which requires less resources: using Flash filters for Drop Shadow/Glow or creating vector shapes for the shadow/glow with the Modify > Shape > Soften Fill Edges command?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved