ActionScript 3.0 :: Instantiating, Positioning And Animating Sprites?
Feb 9, 2010
The application in question is here:
mhayden.jahnews.com/workSample/BrickBuilder/ClassBasedSprite.html
You can right click and see the source.
1.) How can I instantiate the bricks without taking such a big performance hit?
a.) currently, I�m instantiate the bricks that make a column one at a time. I tried doing this with a repeater which did work but I could not get the animation to work on each individual brick. The animation would only work across the entire column.
2.) How can I get the UIComponent that contains the brick columns to align itself to the vertical bottom 10 pixels above the box along the bottom with the slider?
a.) I'm currently adding a UIComponent to the stage dynamically and then keeping a reference to that UIComponenet, I am adding my bricks.
3.) How can I improve the animation?
a.) Most of my research has suggested the only way to animate a sprite is to use a Timer() or connect to the onEnterFrame event.
View 1 Replies
Similar Posts:
Feb 14, 2008
I need help to animate a sprite so that when I push a direction key the sprite will animate when it moves and will return to the starting position when it stops moving.
View 2 Replies
Jan 12, 2012
I am instantiating a class that has a trace("instantiated"); in its init function. Its tracing "instantiated" two times. Why?<br><br>
View 4 Replies
Jul 9, 2010
I am trying to use AMF PHP to pass variables to a flash file, thus far I cannot see anything wrong with my code, but I have very little experience with creating classes, so here it goes, here is my code,
index.php:
<?php
include "amfphp/services/flashMe.php";
$session = true;
[Code].....
Flash is looking for the flashMe class and the push method within that class, but I keep getting null variables in my flash file when I run it
View 3 Replies
May 23, 2011
We used to write our UnitTests with FlexUnit and we were just testing our model. Now we want to test the view too. Before i run my tests i create an instance of my view and my model to test the stuff. When i try to access the view i get a null pointer exception. If i add the view to the displaylist it somehow works - even if i remove it from the list right after adding.it looks something like this:
var myView: MyView = new myView();
//myView.initialize(); will throw error
Application.application.addChild(view);[code]..............
View 3 Replies
Aug 4, 2011
I'm looking to load external .swfs that have graphical assets in them which are all 'exported for actionscript', and instantiate those assets in a .swf packaged for iOS. I'm using the adt command line packager to create the .ipa file. I'm including the .swf files while packaging. The .swf files seem to load correctly, and give me no errors, but when the Loader for each .swf's bytesLoaded equals bytesTotal the content property remains null.The program works perfectly when I package the .ipa using the -target ipa-test-interpreter flag, but not when I use the -target ipa-test.
I'm assuming the problem is that iOS doesn't allow Flex developers to load external .swf files that contain actionscript, and the 'export for actionscript' in the external .swf files counts as actionscript for the purposes of Apple's security policies. I'm looking for confirmation as to whether or not this is the problem.When using adt to package .ipa files, does iOS block external .swf files that have library assets that have been 'exported for actionscript'? [URL]
View 1 Replies
Jan 15, 2009
How do you instantiate an MC that resides in an external swf library?
So for instance loading "shape.swf" and instantiating "square_mc" from it's library onto the parent stage.
View 8 Replies
Sep 19, 2011
i've been struggling with one problem for weeks, and i've just found what i think is a possible cause (or at least a contributing factor)
This line:
Code:
var totalOffset:Point = rangedWeaponData.totalOffset;
What i thought it was doing is creating a copy of a static variable, for me to manipulate. However my debugging seems to show so far that it's actually creating a reference, and my subsequent manipulation of that is also manipulating the base variable it references.
Code:
var totalOffset:Point = new Point(rangedWeaponData.totalOffset);
View 2 Replies
Jan 28, 2010
My Class B imports Class A.Class A is associated to an FLA. This FLA has a moviclip (MC) in its library.Now I need to dynamically instantiate that movieclip MC from Class B. How can I do that??
View 9 Replies
Nov 16, 2010
Code:
var myOnStageClip:MovieClip = this.fileInstanceMC;
var myLinkage:Class = Class(getDefinitionByName(getQualifiedClassName(myOnStageClip)));
[code].....
View 5 Replies
Dec 30, 2008
When I set the following class as my document class it works (draws a rectangle) but when I don't set it as my document class and instead instantiate it using var myRec:simple_shape = new simple_shape(); in first frame of my timeline nothing happens no rectangle and no error either). why and how I can get it to work without setting it as my document class?
[Code]...
View 6 Replies
Oct 28, 2009
I asked yesterday how to call a function from an XML file, and I figured out how to make that work using the string-to-function call.so in my XML file I have <ITEM CALLBACK="ContactsList">View All</ITEM>, and my TextMenu class parses the XML file and creates my navigatable text menu instance. When enterMenu():String is called, it looks to see if the CALLBACK attribute has a value, and if so it returns it as a String.so..
var callbackFnc:String = textMenu.enterMenu();
if(callbackFnc != null)
{
[code].....
View 2 Replies
Nov 8, 2010
Is there any difference in performance, or instantiation speed, between the two? Will anything be different in the instantiation of the MyClass object?
public class MyClass
{
private var _myObject:SomeClass = new SomeClass();
[code].....
View 1 Replies
Mar 17, 2012
I've noticed that using large jpg;'s that are highly compressed take a lot of time to appear as a mc on stage after calling " new mcname();"
I have doubled my background from 1500X900 to 3000X1800. I use a movieclip in library containing the .jpg source image. Creating the larger one takes about 5 times longer to appear. Kicking my levels start from about 4 seconds to a 20 second wait.
[Code]...
View 3 Replies
May 3, 2010
I am loading one swf into another using the Loader class, but when the child swf finishes loading and is added to the display list, its Document Class is not instantiated. I have a few trace statements that should execute when the object is created, but nothing is happening when loaded into the parent SWF. When I compile the child SWF on its own, the Document Class runs as expected.
So I'm wondering... how do I associate a child SWF's Document Class with Loader.content?
[Code]...
View 3 Replies
Jul 25, 2011
I'm making a vertical (constantly) scrolling shooter & am trying to instantiate objects based on a timer. For example: At 30 seconds, place a building @ x, y. My problem is that the "building" is instantiated when the game starts and then again at the 30 second mark - instead of only @ the 30 second mark. If anyone could steer me in the correct direction,
[Code]...
View 1 Replies
Sep 26, 2011
Is there a way I can load a swf file but not automatically instantiate it's DocumentClass? Instead I want to do something like the following:
protected function mainLoaded(e:Event = null):void {
trace('mainLoaded');
var main:* = this.mainLoad.createClassByName('Main');
trace(main);
}
Where mainLoad is an instance of CasaLib's SwfLoad and createClassByName is the equivalent to
loaderInfo.applicationDomain.getDefinition();
The thing is that when my swf finishes loading I can see it is created, because of some trace calls, although its obviously not added to the display list.
View 1 Replies
Jan 14, 2009
Here is the code:
ActionScript Code:
private class someFunction(classRef:Class):void
{
try
{
var instance:Object = new classRef();
[Code]...
Can I perform the check without instantiating?
View 1 Replies
Aug 24, 2011
I quickly realized that instantiating all movieclips in the document class all at once is probably not a good idea. I want to call movieclips from the DisplayList, instantiate them when needed. How do I go about on doing that.
[Code]...
View 0 Replies
Nov 11, 2010
I've got a confusing situation which wont seem to fix itself basically I have my main class, my iContent class (which will hold each page and have functions for all pages), and my individual pages.
The homepage is instantiated by calling the iContentClass.goHome method in the main document class. The home page contains a button to go on to the next page. This button references the goColourBrowserPage function within the iContentClass, which removes the child (being the home page) and attempts to add a child (colourBrowserPage).
For some reason this doesnt work! It doesnt seem to add the child and wont let me remove the child of the home page! I've been sitting here for 3 hours trying to work it but to no avail!
[Code]...
View 1 Replies
May 16, 2010
I'm developing an AS3 application which has some memory leaks I can't find, so I'd like to ask some newbie questions about memory management.Imagine I have a class named BaseClass, and some classes that extend this one, such as ClassA, ClassB, etc.I declare a variable:
myBaseClass:BaseClass = new ClassA();
After a while, I use it to instantiate a new object:
myBaseClass = new ClassB(); some time after
myBaseClass = new ClassC();
and the same thing keeps happening every x millis, triggered by a timer.Is there any memory problem here? Are the unused instances correctly deleted by the garbage collector?
View 2 Replies
Aug 16, 2011
I am currently reading the Actionscript 3 Bible and the author shows an example in which a custom eventDispatcher class is created. When the class is later used in the code it's called as such:
//Thermometer is a custom eventDispatcher that extends the eventDispatcher class.
var thermometer:Thermometer = Thermometer(event.target); //why no new keyword?
I'm a new programmer and I was curious if someone could explain how this works? Why is the new keyword omitted? When you omit the new keyword on a class that extends another class is it essentially just calling the superclass(eventDispatcher) constructor?
View 1 Replies
Jan 17, 2009
I have a weird issue with actionscript 3.0 and I wanted to see if anyone knows what might be going on.I create a UILoader in the root layer. Then on a button click, I set it's properties and once it's loaded, I set the size and all that. It works fine.Then I try to instantiate the UILoader in the button click method and the picture loads up enormous. It never happens when I instantiate the root layer. It always happens when I instantiate it in the button click method.The code is below. Does anyone know why it would do this? I traced all the properties I could think of (xscale, yscale, height, width for both the containing movieclip and the UILoader and they are the same regardless of where it's instantiated
var myStage:MovieClip = new MovieClip();
var stageItem:UILoader = new UILoader();
//Button click function
[code].....
View 2 Replies
Feb 10, 2009
I am having an issue where I cannot use my own classes in CS3. When I try to create an instance of one class inside another class, from within the same package like this:
var t:myClass = new myClass();
gets me 1067: Implicit coercion of a value of type myClass to an unrelated type Class.
The constructor for the class is simply:
public function myClass():void {
this.isactive = false;
}
View 2 Replies
Aug 3, 2010
Is there a way to declare and instantiate an array using constants as indexes? I want to do something like:
public var arr:Array = new Array([ CONSTANT_A : "helloWorld", CONSTANT_B : "helloGoodbye" ]);
In php one could do:
$arr = array(CONSTANT_A => "foo", CONSTANT_B => "bar");
View 9 Replies
Nov 29, 2010
I'm making an app with pages set out as classes which extend the MovieClip class.
What I've got are back buttons and different pages which go to the same page, however... If I end up going out of a page and back into a page (specifically one with drawn squares and dynamic text boxes called from a web service), it seems to have kept all of the original information.
So far I've tried killing all of the children with a while loop targeting the index and also using weak event listeners - neither is working!
View 2 Replies
Jan 27, 2010
If I only instantiate a class once should I make its vars static? I understand how this is of benefit if I make multiple classes, clearly you use less memory as it creates a reference to the same place for each class. Are there any other benefits for creating static vars or functions ?
For example I have my class 'MainMenu' which I create once (might even be my document class). In it I create a
Code:
private var someHolderForStuff:Sprite = new Sprite();
Should I rather create
Code:
private static var someHolderForStuff:Sprite = new Sprite();
View 2 Replies
Jun 8, 2010
I have a MovieClip symbol that has 2 frames (for now). Depending on how it was initilialized, I want it to gotoAndStop at either frame or 2.Inside my class definition (Animal.as), I have written this as my constructor:
var type:String;
public function Animal(t:String = "") {
type = t;
[code]....
View 2 Replies
Jan 9, 2012
Let's say I have a defined ClassA. ClassB extends ClassA and there's a Movie Clip instance on the stage linked to ClassB. How would ClassC access the properties and methods of ClassB without extending ClassB or creating a new instance of ClassB? The way I'm currently doing it is by referencing the stage instance linked to ClassB and then using the dot syntax to access ClassB instance variables, and this works only if the the accessed variables are public or internal, depending on what package ClassC is part of. I would like to know if there's a better, cleaner way to accomplish this.
[Code]....
View 2 Replies
Mar 17, 2011
I'm having this problem: I have an external fla (Dawn.as) and I want to instantiate the class from the external file into the main swf timeline, but when I try doing that I get an error:
ActionScript Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Code::Chapter/initialise()
[code].....
View 5 Replies