ActionScript 3.0 :: Does Cached A Bitmatp Improve Speed Of Vector Object Or Bitmap Object
Aug 5, 2009does cached a bitmatp improve speed of vector object or bitmap object?
View 1 Repliesdoes cached a bitmatp improve speed of vector object or bitmap object?
View 1 RepliesI wonder if there is a way in actionscript 2 that makes something happen if an object hit another object with a specific speed. For exemple: If Object 1 hits Object 2 with a speed greater than 10 I want something to happen.
View 5 RepliesIm writing a app that stores run time values in an object and uses them (instead of i.e. an array). The defaults I load in from an XML file. XML itself beeing an object; could i just use the XML object to keep the current values or is this a 'slow' object compared to as3.0 internal objects. Speed is of the essence since it is supposed to become a game. The internal object isnt as fast as normal array access but so far its working fast enough.
Loading in the XML into a new (but totally similar object) seems silly. If it operates on the same prinicple/speed i could rewrite it and really clean up and simplify the code. Noy wanting to try it if its gonna be slower.
I am having a major problem trying to move an object to another object with a set speed I want object1 to move towards object2 for collision. Right now I control object2 with my keyboard and I want the script to tell object1 to move towards object2.
View 2 RepliesI'm trying to trace the path of an object by using setPixel on the object's position every frame in a BitmapData/Bitmap pairing. These pixels aren't showing up normally and I suspect I have a fundamental misunderstanding of the BitmapData class. Here's what I'm doing:
public var contrailBase:BitmapData;
public var contrail:Bitmap;
private var contrailColor:uint;[code].....
Using this code, the red pixels don't show up. If I initialize contrailBase to 0xFF000000 instead then I get a black screen on which the red pixels DO draw, but I need the bitmap to be transparent except for the contrail. What am I doing wrong?
I know the topic of "duplicating" movieclips is a hot issue with the new virtual machine. Luckily, I understand the implications. I only am [currently] interested in duplicating a Bitmap. See, I load an image from an URL using 'flash.display.Loader.load', which is a non-blocking operation in Flash Player.However,I may use multiple copies of the loaded image (which is reported to be a Bitmap, naturally) in the display list at the same time.Hence, I naturally do not want to load the image from an URL every time, because I don't want to wait for a non-blocking call to complete. Nor do I need to - I mean one copy is already loaded, so it should be possible to just "duplicate" it, right?
My idea is to do use the bitmapData property of a Bitmap and pass it to the constructor of a new Bitmap object. I have not tried the following in action, but I want to hear whether any of you did and if the following would not work, what would:
Code:
var original_bitmap: Bitmap;
var copy_of_original_bitmap: Bitmap = new Bitmap(original_bitmap.bitmapData);
LiveDocs mention that the BitmapData being passed to a Bitmap constructor is "being referenced", which to me might suggest it cannot be used twice? There is also the BitmapData::clone() method, which I am not sure is applicable here or not.I know this is a lot of talk instead of just trying this out, but I test so much Flash Player code daily just to see "what works" (which should be documented instead by Adobe),
I am working on my first Adobe Flex application, and have a code section that appears to be running very slowly (but it does function properly!). CC_Output is a text control, all the other controls are checkboxes (CC, CC_Duration, etc.)[code]
View 3 RepliesI am wanting this to improve the initial download speed of the page. I have already added a Poster Frame to video's, however it still seems to be loading the video file and just autoplaying. Is there a way to NOT load the video file until the person hits play? This is the AS3 script I used...
import fl.video.VideoEvent;
myPoster.addEventListener(MouseEvent.CLICK, playMovie);
function showPosterFrame(event:Event):void { myPoster.visible = true;}
function hidePosterFrame(event:Event):void { myPoster.visible = false;}
function playMovie(event:MouseEvent):void { myVideo.play();}
[code]....
Look at the example: Left sqaure mc1 is cachedAsBitmap right square mc2 is usual MC.
Go mouse over the edge for scaling for both mc's. Cached movieclip goes crazy
How I can bypass this thing easily?
I am using the Camera on Flash, but when I finish to use, now can I "destroy" the camera object for improve the application performance?
private var camera_atual:Camera = Camera.getCamera();
private var video_camera:Video = new Video(820, 546);
camera_atual.setQuality(0,100);
camera_atual.setMode(550,480,30,true);
video_camera.attachCamera(camera_atual);
this.palco_mc.addChild(video_camera);
I want to test if an object is a vector, any vector, not only a vector of a single type.I ran a test:
var v:Vector.<int> = new Vector.<int>();
v.push(3);
v.push(1);
[code].....
First: When creating a Vector, does it have to contain a Flash data type (uint, int, Number) or can I have a Vector of objects I created classes for?
Second :I cannot instantiate a Vector object. All of the documentation I am finding is saying[code]
I get "1084: Syntax Error: expecting identifier before lessthan". I was thinking that maybe I needed to include a library, but the error seems like it knows that I am trying to create a Vector.
If I have declared my vectos object as such ActionScript Code:
private var _delsUI:Vector.<Single> = new Vector.<Single>();
fill it with data like:
ActionScript Code:
_delsUI.push(newListing);
Then later on I decide to use this:
ActionScript Code:
_delsUI = new Vector.<Single>();
Will this essentially destroy all objects and prepare them for GC if there are no other references any where else? or do I have to loop through the entire Vector and delete and set null each object?
Why is it that I can never change a vector object's color? I mean I would think it'd be as simple as changing the fill color but that does nothing.
And why is it that copying and pasting vector objects from illustrator very inconsistent? Sometimes I get the exact copy, and other times their's three anchor points missing, very much screwing up the look of the object. Also, when I import a vector png image made in photoshop to flash, the fill is hollow at times.
I'm having a very weird problem with a vector in my application.
Details...I have the following classes.
Person,Player,PlayerController.
Player extends Person. Person extends ObjectProxy in order to enable binding.So the Player class has the [Bindable] tag.The PlayerController class contains a remote object calling a php method to receive a firstname and a lastname and when the CallResponder gets the result from the call,the result handler creates a Player instance. At that moment I am trying to push the player object into a Vector..
The problem is the following.Every time the push method is called, the vector is being populated with the last player that was created but not just in the end of the vector. It replaces the other instances as well! So the vector always contains the most recent player instance but in every position of it.I have also tried doing it with an Array and the results are the same.
So far, I have a class that creates a Vector object, and pushes data into it:
ActionScript Code:
public var mList:Vector.<cusClass> = new Vector.<cusClass>();
The data is read by a second class like so:
ActionScript Code:
trace(firstClass.mList);
The problem Im having is take that same Vector and passing it into a third class (from the second class) as an argument in a method: ActionScript Code: views.mUpListing(firstClass.mList);
[Code]...
I have a little utility takes lists of letters, combines them in every possible permutations, and lists out all the combinations that are words. For example, I would feed it in "cde,abc,tbrn" and it would let me know that cat, cab, car, can, dab, eat, ear, and ebb are all valid words.I've tried two different approaches: Load a dictionary text file, and splice it into dict:Array. For each possible letter combination run:
if(dict.indexOf(testWord)!=-1) trace(testWord);
The other option is to convert dict:Array into an dictionary:Object
for (i=0; i<dict.length; i++){dictionary[(dict[i])] = dict[i];}
and then run:
if(dictionary[testWord]) trace(testWord);
Although I've read arrays are faster than objects, testing to see if the word exists in an object, and iterating 10s to 100s of times over a several thousand word dictionary is orders of magnitude faster than checking to see if the word exists in the dict:Array.
I have a CSV reader class that parses a CSV file.....
1,11.15126526
2,11.28306635
3,10.78296071
4,10.79878325
The CSV reader class works and produces a Vector.<Point> ... However the container class (which includes an instance of the CSVFile class) needs to access the resultant Vector. Whenever I 'return' the Vector.<Point> to the container via a CSV method it is always empty...I don't know if its something to do with the size of the Vector<> or what?
what I try I can't get the Setter function to work on a vector.<object>
Mean while the getter works fine Example as below
Code:
public function get frameData() :Vector.<Object>
{
trace("getter");[code]....
the code runs fine without the set function, but not without the get.
I have some basic experience with actionscript but have hit a wall with this. I am working on a swimming pool simulation and would like a swimmer to do a length of the pool in a fixed time. When a swimmer reaches the end they hit a pad and turn and this repeats. I can to the collision detection fine even have a running time. How can I for example get a length to take 30seconds.
View 1 RepliesI am trying to get an object to track my mouse on press and i am using a tween. However, the nature of the tween is such that the time taken for the object would move would always be constant despite the distance.
I would like to make the object travel at a constant speed regardless of the distance. Is it correct for me to use a tween? If not what should I be using?The code for my tween is as follows.
map_mc.tracker_mc._x = map_mc._xmouse;map_mc.tracker_mc._y = map_mc._ymouse;startx = map_mc.crosshair_mc._x;endx = map_mc.tracker_mc._x;starty = map_mc.crosshair_mc._y;endy = map_mc.tracker_mc._y;
trackTweenx = new Tween(map_mc.crosshair_mc, "_x", Regular.easeIn, startx, endx, spd, true);trackTweeny = new Tween(map_mc.crosshair_mc, "_y", Regular.easeIn, starty, endy, spd, true);
map_mc.tracker_mc is the mouse cursor that would appear when onPress while the map_mc.crosshair_mc is the object that would track my cursor's movements.
If I create a MovieClip object, and want it to move with some speed, what should I do?I have read a tutorial which was using "xspeed" and "scaleSpeed" to make the small MovieClip moved, but it seemed that this didn't work in my code.such as Code: Select all rectangle.xspeed = Math.random() * 10 - 5; rectangle.yspeed = Math.random() * 10 - 5; rectangle.scaleSpeed = Math.random() * 0.05; and rectangle is an instance of MovieClip.I wonder if that kind of speed properties isn't in as3, or I made some mistakes.
View 1 RepliesHow can I rotate an object using AS and also control the speed it rotates at?
View 4 RepliesI trying to learn and follow some tutorials about classes and stuff like that. If you look att my code I have posted a object called "FallingObject" falls every third second in the speed of "y += 10;" I want my falling object to increase the speed every 20 second. How do I do that?
PHP Code:
var TimerFallingObject:Timer = new Timer(3000);TimerFallingObject.addEventListener(TimerEvent.TIMER, OnStartFallingObject);TimerFallingObject.start(); function OnStartFallingObject(e:Event){ var af:Sprite = new FallingObject(); af.x= Math.random()*640; addChild(af);}[code].....
I am trying to snap 2 vector points together but for some reason its moving the entire object instead of the point. I am trying to follow instructions in a book and the book shows that it is using the solid (filled) selection tool and it has the magnet turned on for snap options. It shows I am suppose to click where the (right triangle) appears beside the mouse arrow and then snap. but it keeps moving the entire Object even with the (right triangle) appear beside the mouse arrow. what could I be doing wrong ??
View 2 RepliesBecause of the inability to create Vectors dynamically, I'm forced to create one with a very primitive type, i.e. Object: var list:Vector.<Object> = new Vector.<Object>(); I'm assuming that Vector gains its power from being typed as closely as possible, rather than the above, but I may be wrong and there are in-fact still gains when using the above in place of a normal Array or Object:
[Code]...
Vector Scaling Object Without Affecting the Original Point
View 1 RepliesI cannot find how to have an object follow the mouse at a CONSTANT speed. The code I keep on finding is something like this:[code]I don't know if I'm just missing some really simple detail, or some major idea, but I'm pretty sure something as easy as this is possible.
View 1 RepliesI am using Flash 8 and AS2. I have been looking and looking, but I cannot find how to have an object follow the mouse at a Constant speed. The code I keep on finding is something like this:
Code:
onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
} onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
The "/speed" part makes the object move slower the closer it gets.
I use something like this code to detect the speed of the movement of a dragged object
PHP Code:
if (!go) {
this["position_"+i] = this._y;
i++;[code]....
This way I can find in what direction the mouse vertically has moved and at what speed. The problem is that every once in a while the speed will be in the opposite direction. What do people use to detect the direction of the movement of the mouse?