ActionScript 3.0 :: Difference Between Methods Of Assigning Vars
Jul 14, 2010terrible title, but simple question. Inside the class declaration, I can bring in and assign a variable like this:
[Code]...
terrible title, but simple question. Inside the class declaration, I can bring in and assign a variable like this:
[Code]...
What is the exact difference between mc1.hitTest(mc2) and mc1.hitTest(mc2._x,mc2._y,true)
View 2 Replieschanged one of my methods to static and it worked for what I was trying to do but I would like to know what is the difference between static and instance method.
What is the difference between static and instance methods?
i am trying to load vars from a text file into a load vars object.
var kitchentext = new LoadVars();
kitchentext.load('moccastext.txt');
Once in the object, i thought i could reference them like so
kitchentext.name
kitchentext.style
but i am having trouble doing this.
i have a textbox called displytext.
_root.displaytext.text = kitchentext.name;
doesnt work
I'm trying to get better at AS3, and am working on a file that uses XML. I've got some of it to work, but can't wrap my head around this. My XML looks kinda like this:
Code:
<portfolio>
<piece>
[code].....
I have a decompiled swf which I've heavily modified consisting of two large buttons with identical behaviors. When I assign a url to the button layer after double clicking on the left button, then the right, the behavior are both applied to the same sprite which, when viewed in the library, only represents the left button ("url one"), while the second url is missing. There are two separate layers for each button on the scene, yet I can't get separate urls applied to them because of this.I could just create two separate files, but that would add to the amount of code...
View 7 RepliesI'm currently translating an application from actionscript-3 to Java code and got stuck with a variable assignment problem.
There is such block in as3 application: var num:*=0; num = 5.5;
As far as I understand AS3, variable is declared of an unknown type, which is resolved during the first assignment =0 meaning it will become int. Am I right?
So does that mean that by assigning 5.5 to it, the Number will be converted to int, and I will have num==5 in the result? Or will it become Number after assigning Number to it?
Added:but I don't have any Flash environment to test it myself. I'm converting one of the utility methods from actionscript to Java and got stuck with this problem.
Added 2: The question is, if num will contain 5 or 5.5 at the end of this block?
If I have a combo box with code:
Code:
var listenerObject:Object = new Object();
listenerObject.change = function(evtObj:Object){
years = combo2.selectedItem.data;
[Code]....
and the 2010 is chosen from the list, can I assign the label value to a variable as a string? (I need the data value to stay as is)
i have a main page that loads a swf of an xml photogallery onto the main stage. I used the classpath in actionscript settings to target the actionscript files and xml data. So far, everything works well. Now, a button on the stage unloads this swf and then loads a second photogallery. The problem is that when it appears, it contains the same data (images) as the first photogallery. This is because it is using the same classpath as the first gallery. My question is how can i assign each gallery its own class path. It seems that only one can be selected at a time.
View 3 RepliesI was wondering if it's possible to assign seperate MC's the same instance name. Say, like, 'boundary' so I can have various boundaries and not have to worry about it.I could use a for loop and name each boundary something like bounds1, bounds2, bounds3 etc. but I'm wondering if there is an even easier way.
View 7 Repliesi have a main page that loads a swf of an xml photogallery onto the main stage. I used the classpath in actionscript settings to target the actionscript files and xml data. So far, everything works well.Now, a button on the stage unloads this swf and then loads a second photogallery. The problem is that when it appears, it contains the same data (images) as the first photogallery. This is because it is using the same classpath as the first gallery. My question is how can i assign each gallery its own class path. It seems that only one can be selected at a time.
View 1 RepliesI've tried googling this simple action but cannot find anything that doesnt relate to something general - only specific issues.
I want to assign an action to a keypress - simple, but i cant do it with any keys other than:
pageup
pagedown
enter
space
[Code]....
id like these functions to assign ed to a standard key
I followed a dynamic gallery scrolling thumbs tutorial and then changed it quite a bit to fit my needs.
I basically added a previous and next button and image title box.
It all works great apart from one thing.
e.g. I click on thumb 5. I then use the next button and go to say... image15. I then click on thumb 9. When I use the prev or next button again it will resume from image15, but it should then carry on from thumb 9 as that was the last change I made.
I thought this would be as simple as assigning the thumb variable value to the image number variable. i.e myID = id; but it doesn't work. my variable myID actually loses its value when I click the thumb image (I used the trace to clarify).
Here is the code.
PHP Code:
function bttnClick(event:MouseEvent):void{
bttn.gotoAndStop(1);
root.logo.visible = false;
myID = id;
[Code].....
I have a 4x4 set of square buttons that I need to give instance names to. They will be named 'btn_1' thru 'btn_16'. Is there any shortcut to assigning the names or do I have to go through 16 times clicking on the button and clicking down to the 'instance name' text box?
View 2 RepliesI'm trying to get the arrow keys on the keyboard to control timeline navigation. The AS3 code i'm using works the first time, but then goes a bit crazy and stops working for some reason. Please see my attached fla. In the example you're supposed to be able to navigate along the timeline using the arrow keys (going back and forth) I'm sure there's a really easy solution to this problem but I'm new to AS3 and can't figure it out.
View 1 RepliesI tried the drag and drop demo at [URL]. It works well allowing me to drag an item and have it register when it is dropped on the correct target. I want to modify it so that I can drag an item to multiple locations... not just one. My desired application is the ability to drag pendents or charms onto a bracelet or chain and have them "snap" to the chain. With the above demo, I can see how 90% of it would work, but I cannot figure out how to have multiple targets named the same. The bulk of the code is attached.
The line I believe needs to changed is this one:
if (event.target.dropTarget != null &&
event.target.dropTarget.parent == myTarget){
I need this part :event.target.dropTarget.parent == myTarget
to read something to the affect of:
if item being dropped is over object A OR object B OR object
C OR object D than ... rest of my code
I'm assigning raw matrix values through Matrix3D.rawData.When assigning certain matrices it yields the following error:
ArgumentError: Error #2188: Invalid raw matrix. Matrix must be invertible.
However, I believe the matrix data I'm passing represent an invertible matrix!Is this a (known) bug? Or is the matrix not invertible and is my math failing me?
I'm trying to call my flashvar and load it in my xml.
but i'm getting an error:
TypeError: Error #2007: Parameter url must be non-null. at flash.net::URLStream/load() at flash.net::URLLoader/load() at test_3d_fla::MainTimeline/frame1()
[Code]....
I'd like to figure out how to get these four skulls to move on a constrained X axis on enter frame, and on CLICK, I'd like them to reset to their original positions.Example:On frame 1 is an mc I created named holder. Inside there's an mc named box. Inside box are four mcs, circles1-4, inside the circles I have four skulls.I've also created an mc called rectangle and dragged it over the first skull to get the coordinates I want using the following trace:
trace(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
Resulting in these coordinates: 143.95,119.05,131.15,61
So, this works MOUSE_OVER the circles
[code].....
Having a problem getting an mc to read variable data. URL...
View 1 RepliesI have created a few flex primitives on screen via action script. Now based on business logic, I need to make changes to some of these primitives such as: changing thickness, direction of arrowhead etcOne thought was to assign id's to these primitives as they are built- how do I do that?e.g. I get a line built as below
var myShape:Shape=new Shape();
myShape.graphics.lineStyle(thickness,color);
myShape.graphics.moveTo(XFrom,YFrom);
[code].....
I am using swfobject v2.1 to pass flashvars to my swf and I was wondering what the best or preferred way to pass those flashvars values to AS3 variables inside the swf.
snippet of javascript inside my html file from swfobject's required code.
Code:
....
var flashvars = {};
flashvars.myVar1 = "one";
flashvars.myVar2 = "two";
[Code].....
I essentially want to be able to pass a handful of flashvars to my swf and assign their values to AS3 variables inside (such as flv file url, skin, background colors, autoplay true/false, etc... my approach would be that certain AS3 variables would have default values (realizing my above examples do not show this), while others would require them passed from Javascript (flashvars).
is there anything changed in actionscript in flashbuilder 4? i'm new to as3.... why is following for loop not assigning value to array ?i tried in various ways, but could not get it
Code:
<fx:Script>
<![CDATA[
[code].....
I have a problem which i hope some one can help me with. I am loading in data from an XML file. This works fine, i can trace the contents of the XML file. The problem i have is this. I want to save each attribute to a class variable so i can call upon it with a getter method.The code is below:
Code:
package XML
{
import flash.events.Event;
import flash.net.URLLoader;
[code]....
If i trace(path) inside the processXML() its displays as expected. but if i fire my getter method path() im returned a value of null.
I need to set movie clips at specific frames from an existing array. For example, if I have the array [4,7,3] and three movie clips, I want the first clip to be at frame 4, the second at frame 7, and the third at frame 3. Except I have 100 of these, not just three.
Here's the code I'm using to test it out on a single movie clip. It isn't throwing up any error messages, but it isn't working, either, and the movie clip remains stubbornly set on the first frame. 'Randomorderlist' is the array, which is working perfectly. The trace is also working correctly and displaying the number of the frame I want for the movie clip.
function assignframe():void {
boxsymbol(gotoAndStop(randomorderlist[0]));
trace(randomorderlist[0]);
}
assignframe();
I think I might know why it isn't working, but I'm not sure. 'boxsymbol' is the class name rather than the instance name. I first tried the instance name, but it came up with a 1180 error and stuffed up the whole SWF badly. This was the only way I could fix it. Also, Flash wouldn't let me use the same name for the class and the instance. It forced me to use classes, even though I don't really want to.
I have a little problem and I guess it won't be difficult to solve, but I am still learning to create codes and I get stuck every once in a while (more every than once haha). What I want is to create to different arrays, one for all the buttons I have, and the other for all the instances of the frames that will take me when I hit each button. So for example if I hit mybutton3, it should take me to frame3.
[Code].....
Is this right?
var movieclip5:int = 150;
movieclip6:int = 200;
movieclip7:int = 250;
[code].....
I have a for loop - for (var i:int=0; i< results.length; i++)
and in this for loop a button is created - var multiplereportButton:Button = new Button();
I would like the integer value from i to be appended onto the name of the variable, so I thought this would work: var multiplereportButton + i:Button = new Button();
I am working on a page where three differnt buttons effect one movie clips properties, the one movie clip will go to its rollover state when any of the buttons are on rollover, hmm, that sounds about right] i have assigned functions within a loop and the rollovers, rollouts and instance in the loop have been defined for all but the movieClips dont go to the right place. the code i have used is this....
[Code].....
I have a move clip called 101.
[Code]...
assigned to 101. Inside of 101 I have dynamic text fields with the var names of price, fee, and state.I have a movieclip 102 that is exactly like 101. What I need to know is, how can differentiate 101 from 102 so that when the db data comes in that 101 and 102 display different info?Also, I can't change the var names. They must stay as price, fee, and state in both movieclips.