ActionScript 3.0 :: Memcpy Function Ala C / C++ - Copying Aspect Of Saving One Multi Value 'object' To Another
Jan 13, 2010
I've been working on some project and have been constantly frustrated at the pointer copying aspect of saving one multi value 'object' to another. I'm getting error: 1051: Return value must be undefined when I try to execute memcpy as: myArrayA = new memcpy(myArrayB); That is when it throws the error.
I have an object, which I would like to copy into a new object. This new object would not be a pointer to the new object. I need it to be totally independent, yet identical to the first object. Example
I have two classes, call them A and B. They both contain a Loader object. In class A I load content into the Loader object.
public class A { var loader:Loader; public function A():void {
[Code].....
But that's not what I want. I don't want to manage a bunch of children when I know I only have one child but just want to change its content.
Is there a way to copy/assign a Loader directly? I tried assigning to 'content' but that's read-only. Basically I have an array of Loader objects that all get loaded with images. I then have a single Loader that's on the stage and I want to assign to it images (Loaders) from my array.
I'm curious to know if there is any examples you all could give me any examples of copying a function in AS3; then use that copy independent of the original function it copied. I want to make an animation system that heavily depends on one type of function. Since it depends on one type of function, I cant have every single piece of code calling back to the same function if I want to use it multiple times. Is there a way of properly doing this? are their performance consequences? I'd really like to do this instead of writing several different functions out separately that work nearly the same. (plus I need to feed a set of values into those functions that are created, some being called by event listeners of course)
I have a video inside of another movieclip. When I go full screen, I scale up the outer movieclip to fit the screen. So that OuterMovieClip.width is equal to screenWidth etc. How do I maintain the aspect ratio on my video so it does not get distorted? Whats the proper math for that?
When I use Bitmap.draw() to copy a displayObject do I lose the transparency? In one case I might be copying a .png file that had transparency and in another case I'm copying a composite image made up of multiple DisplayObjects. It seems as though the resulting images are bitmaps with no transparency.
Is it possible to duplicate .png files in memory, preserving the transparency and having unique objects for using in different places in the display?
I have a as3 class that loads a number of images from a given location, they are all loaded dynamically with imageloader. However I'm trying to make a Xray screen for all of them, so when I click and drag the Xray screen around, it will reveal the images loaded under each picture, creating a sort of Xray effect.I tried using masks, however since the images are all loaded dynamically they are its own class with its own layers, I'm trying to make a mask that will work for all of them (I load 2 picture for each image, example car.jpg and carb.jpg, b.jpg being the inside image).so I have my stage ---> [MyXray Box, and my Images
I'm making a card game and each card has a certain symbol on it which is loaded from an external .png file. I don't want to make it so that it has to load the .png every time it make a card, so I made it load in the preloader/background. How do I make new objects that looks the same as the loader, like copying the loader's data or something?
When a user selects a record in a datagrid I launch a pop-up window with more detailed info. The user can make changes to the record in this window but they don't have to save them. For example, they can click the X to close the window.whenever a user makes changes I update the object directly.Is there a pattern for copying the object and then mapping the changes to it when a user confirms they want to save?
Background: Sorry for the complex title, but can't think of a better way to describe this. So I have an image which is constantly moving and rotating (using matrix rotation around a specific point) on the stage. Problem: So I'm looking for a way that, when the user presses a button, a smaller image (exactly the same as the original one, only 3 times smaller) to position itself so that the smaller image's location is proportional to the the larger one's location. This means that the exact point of the larger image where it is rotating should be the corresponding part of the smaller image, thereby causing a kind of zoom out effect.
The truth is, I'm finding it even difficult to match just the x and y positions so they correspond, ignoring rotation, assuming the position is relative to the rotation point. Even this would be useful.
I want to clone an object of a class (whose source code I do not have) and copy all of the associated event handlers from the original object to the new cloned object. Does anyone know how I can do that? I know how to copy the properties from the original to the new, but can I iterate over all the event handlers and add them to the new object?
Now, I'm writing a small game. I use actionscript to load a group of soldiers.It's pretty easy. But how do I select all of the soldiers by dragging the mouse?
(I see this same type of question was posted almost three years ago with no resolution, does anyone have a solution now? am trying to save a clone of a custom object (contains arrays and other custom objects as properties) to a Shared Object.Basically I have a menu system that created this program, it's running and at any point I want the user to be able to save it so he can go back to that exact point at a later date. Here is what I do so far:1. Pause the program2. The menu saves the variable that references the running program using a bytearray to a shared object3. A a later time, to load the program I pull the data from the shared object and save it to a variable, which I then treat like the original programHere is my code to save the data:
Code: var byteArrayCloner:ByteArray = new ByteArray(); byteArrayCloner.writeObject(myProgram);
I have used SO's to save and retrieve simple variables successfully, but I am a problem saving and retreiving array data in the following example: [URL] A user selects several options using radio buttons. All that happens is that the SO should store in memory which buttons the user clicked on. If run through flash with the output window, you can see that when the save button is clicked, the data is saved. But when you load the activity a second time, the array data that was stored in the SO only gets recalled as 'undefined'.
I'm trying to save an object to a shared object, the thing is that while i run it the first time it works perfectly, but as soon as the swf is closed and re-opened my object just disappears.If I'm not wrong this is because it's a custom class instance and the .data saves a reference to the object instead of the object which is deleted as soon as the program closes.My question is:I've tried saving each var in a different data.[something], having to save five variables might not be bad but what about twenty or more.
I know the basics of shared objects but I never really got into it I was wondering if there is a way that I could save and load movieclips that I attach to the stage(Each has its own name such as clip_1,clip_2,etc) including the location(_x,_y,rot) and have it duplicate them all over again and move them to the same location as before (I'm using Actionscript 2, by the way)
I know the basics of shared objects but I never really got into it I was wondering if there is a way that I could save and load movieclips that I attach to the stage(Each has its own name such as clip_1,clip_2,etc) including the location(_x,_y,rot) and have it duplicate them all over again and move them to the same location as before
I have an AS3 program that calls a function multiple times. The function must return multiple variables, so I created a class for the function to declare an object containing all of these variables. For example, here's my class:
package { public class PER { [Code].....
Let's say the calling program calls the function, which returns the variables into data_set1 (where data_set1 depends on input variables arg1, arg2, arg3) using:
var data_set1:PER = function_name(arg1, arg2, arg3);
The calling program does some stuff, then calls the function again, but returns the variables into a new variable name, data_set2:
var data_set2:PER = function_name(arg4, arg5, arg6);
My intention is that data_set1 and data_set2 are different (e.g. not linked together).
My question is, given that arrays are passed by reference, will data_set1 be modified to agree with data_set2 upon the 2nd function call? Why or why not?
I have an object which is assigned a number of properties:
var project_array:Array = []; var slideObject:Object = { project_title : myXML.projects.project[i].title.toUpperCase(),
[Code].....
but I'm not quite sure where to place this. If I place it outside of the object constructor, I get "term is undefined", I guess because it doesn't know what project_clips_array is - but if I declare project_clips_array in the constructor, it appears to need to be defined, i.e. I can't create a blank property. But I can't place it in the constructor either, because it doesn't seem to allow me to run a function within an object constructor. What is the proper syntax or arrangement of code for executing this function to get the array within the object?
Alright, I've looked online at a bunch of different collision tutorials but they don't explain what I'm looking for. I want object A to hit object B and then execute a function via to a Event listener.
im creating multiple objects (the number is dynamic)they move randomly, but i want dont want them to be able to pass thru each other.i'm having dificulty on writing the hitTextObject code because I dont know how to refer the other objects.[code]
I am trying to create a Flash based website that runs full screen. It will have a series of still photos or possibly, a video as a background with a few menu buttons on top of them. What I don't understand is how to compensate for the various monitor aspect ratios. If I make it wide screen, a square monitor will show blank bars at the top and bottom. You can see an example of what I'm trying to do at [URL] Also, what is the optimal size to make the Flash video? I am running Flash MX 2004 (Version 7)
I want to produce a small movie using flash that i can pass onto someone else for inclusion in a presentation
They have asked for the final movie to be a quicktime .mov using the H.264 codec and that the aspect ratio should be 16:9
So my question is, how do i set up a flash project to ensure the final outputted movie will be in the correct aspect ratio? do i need to know the correct pixel dimensions?
i'd like to use one flv player .swf to play both 16:9 and 4:3 videos without stretching the 4:3. how to detect the aspect ratio of the flv file being loaded?
I found a thread in actionscript.com that resizes a bg image beautifully (without any pixelation whatsoever), except that there is a minor glitch in the script that doesn't load properly. What does the solution mean: "try waiting until after the image is loaded. call your setBackground(); function from the onLoadInit"
Here is the script:
import flash.display.*; // this tells Flash NOT to allow the assets to be scaled Stage.scaleMode = "noScale"; Stage.align = "TL";
I have developed a couple of websites before in Flash, the problem is, the resolution of the site is good on my platform. i.e. 1024 x 800. However, when I get to view the site in 1366 x 788 the whole site looks sad. Badly oriented and sometimes I have to scroll through my page up and down - you know what I mean.
how to solve the problem so that my site looks good, centre oriented, doesn't matter at which resolution the user is viewing it.
I have set my stage at 1920 x 1440 with a background bitmap that matches that size. The aspect ratio of my stage/bitmap is 4:3. When I run my Flash website on a legacy 4:3 monitor set at 1024x768, the top and bottom portions of the stage image are truncated. The remaining part of the displayed picture has an exact aspect ratio of 16:9.
I have made a resizeable box that you can resize using handles on all four cornersI have tl (top left handle), tr (top right handle), bl (bottom left handle) and br (bottom right handle)Its rather difficult to explain. See the picture attached, the blue arrows are where the mouse could move and the green arrows are where the boxes should goor now let's concentrate on moving the tl handle so that when it is moved left or downwards it gets smaller, towards the br handle