Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




When To Use The "this" Keyword...



I was just fooling around with my prior work, and this code works:


ActionScript Code:
package {    import flash.display.*;    public class ArrowDirection extends Shape {//Constructor        public function ArrowDirection():void {            //color is black, alpha is 1              graphics.beginFill(0x000000,1);            graphics.moveTo(0,-12);            graphics.lineTo(6, 0);            graphics.lineTo(3, 0);            graphics.lineTo(3, 5);            graphics.lineTo(-3, 5);            graphics.lineTo(-3, 0);            graphics.lineTo(-6, 0);        }    }}

Alternatively, if I add the "this" keyword to the graphics method, the result is the same (it works too).


ActionScript Code:
package {    import flash.display.*;    public class ArrowDirection extends Shape {    //Constructor        public function ArrowDirection():void {            //color is black, alpha is 1                        this.graphics.beginFill(0x000000,1);            //draw the arrow            this.graphics.moveTo(0,-12);            this.graphics.lineTo(6, 0);            this.graphics.lineTo(3, 0);            this.graphics.lineTo(3, 5);            this.graphics.lineTo(-3, 5);            this.graphics.lineTo(-3, 0);            this.graphics.lineTo(-6, 0);        }    }}
Can someone tell me why (with the explanation limited to this example)?

I don't have a full understanding of the "this" keyword-never have. All I understand is that "this" is referring to itself, in code, although that's probably a gross oversimplification. I know that "this" can be swapped out for an instance name sometimes, but is there a general rule for the "this" keyword?

Thanks in advance.



Ultrashock Forums > Flash > ActionScript
Posted on: 2007-06-26


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

When Not To Use Var Keyword
In declaring variables, is there any time when one should NOT use the keyword 'var' ?

AS2 'this' Keyword
From my understanding, the this keyword in AS2.0 classes is not needed to access class-level properties. What I'm curious about is whether you can use it, to prevent naming issues. For example, I often do something like this with the naming of parameters to functions:


ActionScript Code:
class Point  {    var x:Number;    var y:Number;    var z:Number;    function Point (x:Number, y:Number, z:Number):Void    {        this.x = x;        this.y = y;        this.z = z;    }    ...}


Would the function's parameter being named the same as a class property still raise issues?

[EDIT]====================
Also, are there any naming restrictions to classes? I know some languages don't allow numbers at all, some don't allow them as the last character in a name, some don't allow them as the first, etc.

Confused About The 'this' Keyword
I am using MX 2004

What is the deal with the 'this' keyword? It seems to act differently for
buttons and movieclips. It's confusing me because it seems illogical. Why
is the following occuring?

If I create a script on a movie clip, 'this' seems to make sense.

onClipEvent(load) {
trace(this._x);
}

Traces the value of the x co-ordinate of the movie clip. Logical.

If I create a script on a button, 'this' seems illogical. The exact same
code as above doesn't trace the value of the x co-ordinate of the button,
but instead it traces the value of the x co-ordinate of the movie clip the
button is inside of. Why?

Am I missing something or am I going to have to buttonName_btn._x instead of
this._x ? I just don't see why this works for movieclips but not for
buttons.

Keyword Questionnaire
anyone know the best way to set up a series of questions in Flash in which keywords are searched within the user's answers to pull up "canned" answers containing those keywords? would it use an outside text file of some kind? any tutorials anywhere?

any help appreciated!

How To Use Restricted Keyword?
Hi all,

I'm trying to do something like this:


Code:
var this_variable:XML = <stuff>get</stuff>;
But I get an error because "get" is a restricted keyword. I tried wrapping it in quotes but that doesn't work -- how would one get around this? I just want the string "get" inside of <stuff> tags. Thanks!

'internal' Keyword
Can someone just explain what this is used for?

Thanks

'this' Keyword And Buttons
If I create a simple flash document, draw a rectangle, convert it to a movie clip, give the movie clip an instance name, then put this code on it:

quote:on (release) {
trace (this._name);
}

I get a debug window with whatever the instance name is.

If I change the movie clip to a Button object and apply the same actionscript to it I get nothing, or a null response. Why can't I get the Button's instance name the same way I can with the movie clip?

Is Bg A Reserved Keyword In AS2 ?
Hi there!

I use Flash 8
In my ASPanel, colored coding marks my variable bg as a keyword (like true or undefined or _visible, etc).
I didn't find any warning about the string "bg" in the Flash Help.

Could somebody light my lantern?

Keyword Search
Hi,
Lately, I learned on this site that I could make flash (MX and 2004) load a text an external file and display it in a textbox.
I would like to know if there is a way, anyway, to make a "keyword search" from those external files in flash.
Thanks,
Any help will be appreciated.

Component Keyword~
did anyone notice the highlight when inputing "component" simply(i'm with 2004 pro) ? is that somewhat hint ?

Adding Keyword
Hi !!
Im making a flash game,but I need to access a new key word into Action script
In the code
on (KeyDown <"RIGHT">) {
_root.i += 1;
_root.fire = 1;
duplicateMovieClip....
}
Flash doesn't recognize the "<CONTROL>" option for asinging actions in button instances. I need to fire a spaceship, but I need control in order to make it more useful to user. Please,help me.....
The code is in the shooting tutorial of the mouse-crab in Kirupa.

:::goto();:::

Undocumented AS Keyword
I was working and writing some ActionScript recently and came across the keyword "shadow". I looked through the ActionScript dictionary and didn't find any documentation, does anyone know how to impliment it?

XML Keyword Search
Hello,

I'm trying to create a keyword search box. I looked at the atomz.com tutorial here and tweaked it so that I send user to a page based on the input. What I don't need is a full search feature. These are to be keywords that the user would have received in a bulletin or scrolling announcements about a certain event. Example here: http://www.evbc.org/frog/main/index.html. In the keyword box, enter fallkickoff and you will be taken to the correct page. The path to the fallkickoff page is harcoded, except for that one word. I want the box to read in the users input, then compare it against an XML list of keywords and then go to the link that is in the XML file under that keyword.

I hope this makes sense.

Thanks for any input,

-fjhughes

Private Keyword
What is the point in the private keyword. A variable I can't access I could just choose not to read in the first place, surely? Who cares?

Keyword Search
Hi,
Lately, I learned on this site that I could make flash (MX and 2004) load a text an external file and display it in a textbox.
I would like to know if there is a way, anyway, to make a "keyword search" from those external files in flash.
Thanks,
Any help will be appreciated.

Component Keyword~
did anyone notice the highlight when inputing "component" simply(i'm with 2004 pro) ? is that somewhat hint ?

/: Keyword Before A Variable
anyone recognize using /: before a variable and what it denotes?  I came across it in some code, perhaps its from actionscript 1.0.

Using CDATA Keyword In XML For Text
I want to use the CDATA keyword to load plain text, so I tried:

<a><!CDATA[[test's]]></a>

But flash gives me:

test&apos;s

why?

thanks,
brian riley

Question Regarding Delete Keyword
The flash documentation says:

Operator; destroys the object reference specified by the reference parameter, and returns true if the reference is successfully deleted; false otherwise

Then later on it says:

Predefined objects and properties, and variables declared with var, cannot be deleted

But when I declare a variable using the var keyword e.g


Code:
var greeting:String = "hello";
trace(delete greeting); // This returns true
Why does it return true when the docs say variables declared with var, cannot be deleted.

Thanks in advance

A Little Prototype And The Delete Keyword ...
Here is a little proto for my XMLNode:

Code:
XMLNode.prototype.numSiblings = function()
{
goingDown = this;
goingUp = this;

numSiblingsDown = 0;
numSiblingsUp = 0;
numSiblingsTotal = 0;

while (goingDown.nextSibling)
{
numSiblingsDown++;
goingDown = goingDown.nextSibling;
}
while (goingUp.previousSibling)
{
numSiblingsUp++;
goingUp = goingUp.previousSibling;
}

numSiblingsTotal = numSiblingsDown + numSiblingsUp;

return numSiblingsTotal;
delete numSiblingsTotal;
}
Is inserting the final line delete numSiblings considered good form in that I am deleting a variable I have finished with therefore making my code cleaner, or will this actually extend processor time and I shouldn't worry about it. Looking for efficiency.

Thanks,
Stephen.

KEYWORD SEARCH ISSUE
Hi, I'm building a custom flash based website for my photos. I have keyworded all of the photos for my site through Lightroom for search categories. I want to be able to search via the embedded keywords on the site, and I can't find a way to get that happening. Is anyone familiar with this that could point me in the right direction?

Thanks !

Andy

This Keyword Inside Object
I'm using this:

imageLoader_listener.onLoadInit = function(target_mc:MovieClip) {

the only way I know how to access variables I set in target_mc is by using the array access like this...

this[target_mc].theVar

but I can't use this inside an object because it refers to the object.

How do I deal with this? Do I have to make a separate function with these statements that gets called for the object?

Thx, a little confused with this, I've run into this a few times any clarification is appreciated.

_name Property For This Keyword
When you are using the keyword this inside of an event handler it refers to the object that triggered the event.

For example if OnLoadInit of a sound object is triggered you can say

this.play();

Is there any way of returning the instance name of this the way you can get the name of a movie clip

ie somemovieclip_mc._name

It is probably not that simple. If there is a solution it probably needs several lines of code.
However, it would be worth while for a lot of debugging purposes.
Any help would be greatly appreciated.

Problems With Keyword Activity
Hi everyone! Just wondering if anyone has a simple answer to my problem, because I don't. I am developing a cloze/keyword question activity in flash where the user types a certain 'keyword' into a text box and then clicks on a button to validate if they have typed in the correct word. First of all I set up a string on the first line of code that executes when the user clicks on the submit button. Then the next line executes a function to convert what they have typed in the box into another string variable and then compare it to the stored variable within a simple if/else statement.

I have run some trace commands to attempt to debug the script but they all indicate that it should be working. The code is attached to this post.

Any assistance to this would be very helpful as I have googled the heck out of it and all I can find is dodgy software which generates these cheesy flash activities for a price i would not pay when i should be able to code it myself.







Attach Code

on (press){
var textAnswer1:String = "contract"
var text1:String =textField1.text;
trace(text1);
if (text1 == textAnswer1){
trace("correct!")
}else{
trace("incorrect")
trace(text1);
}
}

Array Notation And This Keyword
Hello

I am trying to create a number of movie clips in my main movie but I don;t seem to be able to access these movies using array notation and the 'this' keyword

Here's some example code in a main timeline

var i=0;

createEmptyMovieClip("clip"+1,0);
trace(this["clip"+i]); ////undefined - why?????

var clip=createEmptyMovieClip("clip_holder",1);
clip.createEmptyMovieClip("clip"+i,0);
trace(clip_holder["clip"+i]); /////_level0.clip_holder.clip0. This is ok

What's wrong with this["clip"+i] ?

Strange Error With Is Keyword
Ok, so what I'm trying to do is create a function that looks for an Object in an Array with the same Class type as the parameter. This is the function I'm using.


Code:
/**
* Searches for the first Controller in the Entity with the same Class type as the parameter,
* and if exists, returns an instance of that Controller.
*
* This should only be used if only one of a type of Controller is expected to exist.
* For gathering multiple Controllers, use getAllControllersOfType(cls:Class)
*
* @param cls The Class type of the wanted constructor
* @return The wanted Controller, otherwise null
*/
public function getControllerOfType(cls:Class):Controller
{
for each(var c : Controller in controllers)
{
if(c is cls) {
trace("c is cls? "+c is cls);
return c;
}
}
return null;
}
In my example, I'm putting in a Controller (for this example, I'm using a PhysicsController) and testing it against a class that has a PhysicsController in it. The trace statement returns "c is cls? true", and the function is not returning null. Now, in my DocumentClass I'm calling this function again and I'm running a trace statement of
Code:
var c:Controller = player.getControllerOfType(PhysicsController);
trace("c is a PhysicsController? "+ c is PhysicsController+ ". c is null? "+c == null)

// returns "c is a PhysicsController? false. c is null? false"
This is also returning the same if I test c as a Controller, but if I test it as an Object, it says it IS an Object. I don't understand why this is happening.

XML Keyword Search Problems
I am making a program to download files from a server with a simple interface, but I am having a problem with the search box. My problem is that the search box only returns a value if the XML node value is exactly the same value that was searched for. If I type in "Internet Explorer 7" I get the result, but If I were to type in "internet explorer 7" or just "internet explorer" nothing comes back.

I want my users to get search results even if they don't know the exact name they are looking for.

Any thoughts?

Thanks!

Here is what I have so far.

Partial XML
<Software>
<program category="Internet">
<name>Internet Explorer 7</name>
<location>file:///S:/ClientApps/ie7/IE7-WindowsXP-x86-enu.exe</location>
</program>
<program category="Internet">
<name>Internet Explorer 6</name>
<location>file:///S:/ClientApps/ie6/ie6setup.exe</location>
</program>
........................

Actionscript
function searchParseData(dataInput:XML):void {
var searchString:String = txtSearch.text
var nameList:XMLList = dataInput.program.(name == searchString);
cboName.removeAll();
universalNameList = nameList;
//Add Items to Name ComboBox
for (var i:int = 0; i < nameList.length(); i++)
{
cboName.addItem({label:nameList.name.text()[i], data:nameList.name.text()[i]});
}
}

Purpose Of Package Keyword In As3
What does the words after package do?

Below is an example:
package com.example.flower

what does com.example.flower do?

and

why most package has the word com.***.*** ?
com is?

How To Add Keyword To Search Specific Flv
Hi everybody-I am creating a xml driven video site with over 50 clips and would like to add a keywords search text area(within flash) that searches all the flv's linked to the keyword.

Can anyone give me a direction on how to accomplish this?

Many Thanks

Using POST Method, But Need To Use A Keyword As Variable?
I'm working on integrating a form submission into a .swf file, that uses the POST method...

the only problem is that one of the variables the receiving CGI script (that I have no control over) requires me to use a variable named "add"

... is there a way for me to send a variable with that name despite the fact that "add" is an operator?

What's Your Favourite Function,object, Keyword ?
just wondering which function, objects or keywords in flash coders find most important and use most frequently..

mine seems to be duplicateMovieClip().. and the Array and String Objects..

How To Access XML Node With ActionScript Keyword Name
I have a following problem, i need to access a xml "<switch>" node but "switch" is an actionscript keyword so following E4X notation:


Code:
myXML.switch
in an ActionScript statement where "myXML" is XML object doesn't work. Does anyone know how i can still access "<switch>" node?

thanks a lot

[F8] Refreshing XML List Based On Keyword?
Hope someone can point me in the right direction for this. I've got an FLV playlist with a large number of flv's. I've got the list loading no problem and everything works great. My question is what kind of coding i need to be able to make it so if you click on a button it will refresh the list so it only shows items with a specific node value?

this is an example of the XML i'm working with:


Code:
<playlist>
<video url="streams/Video1.flv">
<Title>Video 1</Title>
<img_src>images/Video1.jpg</img_src>
<desc>This is Video 1</desc>
<category>Drama</category>
</video>
<video url="streams/Video2.flv">
<Title>Video 2</Title>
<img_src>images/Video2.jpg</img_src>
<desc>This is Video 2</desc>
<category>Comedy</category>
</video>
<video url="streams/Video3.flv">
<Title>Video 3</Title>
<img_src>images/Video3.jpg</img_src>
<desc>This is Video 3</desc>
<category>Drama</category>
</video>


So now I want to have a button called "Drama" which when clicked will refresh the list to only show the video's which list "Drama" under the category node. Other buttons would than be used to choose to refresh the list based on other category values.

My AS code for the playlist is below:


Code:
var vlist:XML = new XML();
vlist.ignoreWhite = true;

var images:Array = new Array();
var titles:Array = new Array();
var desc:Array = new Array();

vlist.onLoad = function() {
var playlist:Array = this.firstChild.childNodes;
for(i=0;i<playlist.length;i++) {
_root.videoList.addItem(playlist[i].firstChild.firstChild.nodeValue, playlist[i].attributes.url);
titles.push(playlist[i].firstChild.firstChild.nodeValue);
images.push(playlist[i].firstChild.nextSibling.firstChild.nodeValue);
desc.push(playlist[i].firstChild.nextSibling.nextSibling.firstChild.nodeValue);
}

startImage.holder.loadMovie(images[0]);
ns.play(_root.videoList.getItemAt(0).data);
ns.pause(true);
startImage.title_txt.text = titles[0];
startImage.desc_txt.text = desc[0];

_root.videoList.selectedIndex = 0;
}

var vidList:Object = new Object();

vidList.change = function() {
Screen.clear();
ns.clear();
startImage.holder.loadMovie(images[_root.videoList.selectedIndex]);
startImage._visible = true;
ns.play(_root.videoList.getItemAt(_root.videoList.selectedIndex).data);
ns.pause(true);
startImage.title_txt.text = titles[_root.videoList.selectedIndex];
startImage.desc_txt.text = desc[_root.videoList.selectedIndex]

pauseButton._visible = false;
playButton._visible = true;
}

_root.videoList.addEventListener("change",vidList);

vlist.load("videos.xml");


I'm somewhat new to working with AS and XML so any help on how I would go about this would be appreciated.

Thanks

Textfield - Cant Get An '@' - Wrong Keyword Setup
hi!

im having a simpel textfield in my AS3 application where you can input an email adress and send it afterwards.
unfortunetaly i cant type an "@" in this textfield. with my german keyboard i usually get this by typing AltGr+Q. when i want to have it in flash it comes when typing Shift+2 or something.

dont really get it. the normal keyboard setup should be also applied on the flash textfield, shouldnt it?

thanks,

tek

HI-Quality <- (Keyword There) Sound Effects
Ok, I'm looking to put some sound effects in a flash movie I am making, but am unable to find any sites with (here it is again) HIGH QUALITY sound effects. Where could I find sites that would have (and once more) HIGH QUALITY sound effects. The reason I ask is because I have searched and I can't find anything that sounds have decent. I did do a search, but all that ever came up was "flash kit" which has poor quality sounds.

I'm looking for things like splats, falling noises, goo-like slurps, etc.

Thanks in advance.

[AS 2.0] 'this' Keyword Not Working Inside OnLoadInit
I'm tyring to do some OOP coding but have trouble figuring out how to keep it all nice and clean. Observe the following class I've made:


Code:
class Link {
public var identifier:Number;
var xpos:Number;
var ypos:Number;
var nummer:String;
var omschrijving:String;
var image:String;

var loadLinkListener:Object;
var mcLoader:MovieClipLoader;
function Link(id:Number, x:Number, y:Number, n:String, o:String, i:String){
this.identifier = id;
this.xpos = x;
this.ypos = y;
this.nummer = n;
this.omschrijving = o;
this.image = i;

_global.respectMovie.mc_grid.createEmptyMovieClip("link" + identifier, _global.respectMovie.mc_grid.getNextHighestDepth());

this.loadLinkListener = new Object();
this.mcLoader = new MovieClipLoader();
this.mcLoader.addListener(loadLinkListener);
this.mcLoader.loadClip("link.swf", _global.respectMovie.mc_grid["link" + identifier]);

this.loadLinkListener.onLoadInit = function(linkMC:MovieClip):Void{
trace(this);
linkMC._x = this.xpos;
linkMC._y = this.ypos;
linkMC.nummer = this.nummer;
linkMC.omschrijving = this.omschrijving;
linkMC.mc_image.loadMovie(this.image);
}
}
// more class definition...
}
The problem is that I can't access my class properties inside the onLoadInit event function. What is the good OOP way to access these properties?

Thanks in advance

How To Access Xml Node With ActionScript Keyword Name
I have a following problem, i need to access a xml "<switch>" node but "switch" is an actionscript keyword so following E4X notation:


Code:
myXML.switch
in an ActionScript statement where "myXML" is XML object doesn't work. Does anyone know how i can still access <switch> node?

thanks a lot

HI-Quality <- (Keyword There) Sound Effects
Ok, I'm looking to put some sound effects in a flash movie I am making, but am unable to find any sites with (here it is again) HIGH QUALITY sound effects. Where could I find sites that would have (and once more) HIGH QUALITY sound effects. The reason I ask is because I have searched and I can't find anything that sounds have decent. I did do a search, but all that ever came up was "flash kit" which has poor quality sounds.

I'm looking for things like splats, falling noises, goo-like slurps, etc.

Thanks in advance.

Keyword Search HTML JAVA Or FLASH
Does anyone know how to do a simple HTML JAVA or FLASH keyword search. To search my web pages for keywords that have been typed in?

'new' Keyword To Dynamically Create An Object Instance
Hi,

I was just wondering if the following is possible. Can I dynamically create new instances by passing in the type of object I want to create:

Consider the following pseudocode:


Code:
var typeOfThing:String = figureOutWhatToCreate();

// 'newThing' is the superclass of the typeOfThing I am trying to instantiate.
var newThing:[superclass] = new [typeOfThing] (param1, param2...);
Or, does the parameter after new need to be a class object ? I know that the above code doesn't work because I've tried it, but I guess I'm asking of it is possible through other means.

I just have a huge switch statement that I am trying to do away with. If this is a totally stupid question, just tell me to forget it altogether and keep the switch.

Thanks in advance,

Classes, The 'this' Keyword And Function Literals: A Problem
Hi,

Sorry for the somewhat incomprehensible title. I am working on custom class MenuClass which is linked to a movie clip symbol in the library via the Object registerclass method.

Inside the init() function of MenuClass, I'm having a problem. Let's see the code:


this.txtColor = new Color(this.mc_icon);
this.btn_menuButton.onRollOver = function() {
this._parent.txtColor.setRGB(0xFF0000);
}

As you can see, the point of this code is to change the color of a menu item element (a plus/minus indicator). This code appears inside the MenuClass's init function. I have four menu items created with the attachMovie() method that are based on MenuClass. My problem is this: this piece of code is supposed to make the icon in every movie clip turn red when the MC's button is rolled over. However, regardless of which clip I roll over, it is the FIRST MenuClass mc that changes to red, the others remain unaffected.

The full code:

menuArray = new Array("CV", "Om meg", "Kontakt", "Arbeider");

function menuClass(menuLevel, menuLabel, xPos, yPos) {this.menu_level = this.menuLevel;
this.menu_label = this.menuLabel;
this.menu_x = this.xPos;
this.menu_y = this.yPos;

//class methods
this.setName = setName;
this.init = init;
this.openMenu = openMenu;

//initializes clip
this.init();}

function init() {this._x = this.menu_x; //positioning menu items
this._y = this.menu_y; //positioning menu items
this.txt_menu.autoSize = true; //textfield dynamically resizes to accomodate text
this.txt_menu.text = this.menu_label; //menu label is set

//onRelease handler
this.btn_menuButton.onRelease = function() {
trace("clicked");
}

//creating Color object
this.txtColor = new Color(this.mc_icon)//creates color object based on menu's +/- indicator

//onRollOver handler
this.btn_menuButton.onRollOver = function() { //changes icon indicator color when rolled over
this._parent.txtColor.setRGB(0xFF0000);
}
this.btn_menuButton._width = this.txt_menu._width + 2; //setting button size corresponding to menu label (+2 makes it slightly bigger)
this.btn_menuButton._height = this.txt_menu._height - 3; //setting button size corresponding to menu label (-3 makes it slightly smaller)}


menuClass.prototype = new MovieClip; //inherits MovieClip class
Object.registerClass("menu", menuClass); //creates movie clip/class relationship

for(i = 0; i<menuArray.length; i++) {
if(new_yPos == null) {
new_yPos = 0; //if variable is undefined, create it
}
this.attachMovie("menu", this["menu"+i], i, {menuLevel:0, menuLabel: menuArray[i], yPos: new_yPos}); //instantiating menu item
new_yPos += 20; //changin yPos variable for next menu item}


Can anyone help? I'd be very grateful

[edit]I almost forgot. Another issue I seem to have is not understanding quite how the "this" keyword functions within function literals in classes. It doesn't seem to refer to the class any longer, so what does it refer to? [/edit]

cheers,
Terpentine

Conflicting Info: Keyword Meta Tag Question
Hey everyone,
I had come across some information stating that the max number of keywords is 864 to put into the meta tag of the html file. I've also found information stating that if your keywords don't have a corresponding link, the crawlers award you less relevance points. My question is if I'm sticking a flash file into an html doc to put up on the server, would the crawlers be able to see the links in the flash file? Would I be safe using the 864 keywords in my meta tag anyway? I'm trying to make the site highly searchable, so I don't know how to go about solving this problem.

Thanks for the help,
Nebraska girl

"this" Keyword Not Working To Address Local Variables In Mc
I have like 10 grasshopper movie clips. Each one has its own set of variables.

I need to attach to each mc at different times

onClipEvent (enterFrame) {
this.gotoAndPlay("loop2");
}


Where "loop2" is a certain frame inside the clip.

The problem is that none of the grasshoppers are obeying!! Mutiny! How do I solve this probelem?

Conceptual Question About "package" Keyword
I've read through a lot of Adobe documentation about how "package" is used primarily as a way to avoid naming conflicts. Fair enough, but how does a nameless package work?


ActionScript Code:
//Greeter.as
package
{
    public class Greeter
    {
        public function sayHello():String
        {
            var greeting:String;
            greeting = "Hello World!";
            return greeting;
        }
    }
}

//in the main timeline
//(mainText is a textField on the stage)
var myGreeter:Greeter = new Greeter();
mainText.text = myGreeter.sayHello("Bob");

1) Why can this package get away without a name?
2) How does a .fla file know to use Greeter.as when compiling my .swf? Where does the "import" occur?

What Is The Keyword For "Pause" In Actionscript ?
Hi,

If i want to make a few secondes pause in the execution of my code, what keyword should I use ? Is there a timer or something like that ?

Thanks !

Wandi




Mark this message as the answer

ActionScript 3 "virtual" Keyword
In examples of accessing services of WebOrb I saw some realy interesting stuff:

ActionScript Code:
var ro:RemoteObject = new RemoteObject(”GenericDestination”);
ro.SomMethod.addEventListener(ResultEvent.RESULT,onServiceResult);

private virtual function onServiceResult(event:ResultEvent):void


After an hour of searching an internet I found nothing about the strange undocumented virtual keyword (or what is it).

Does anyone have an idea about what it is? Maybe links?

Getting A Substring Of Keyword "this"
I have a mc called "mc3" which is contained within the mc "gridClip". If I use the "this" keyword to send the name of the mc (that gets clicked on) to a function(below) it sends:"_level0.gridClip.mc3". No surprises here. Note also that trace(nameOfClip) DOES = "_level0.gridClip.mc3" from within the function. The substring method just doesn't seem to work on this string.

function getLargeImage(nameOfClip) {
var nameOfClip:String;
var clipNumber:String;
clipNumber=nameOfClip.substring(17);
}
I expect to get a value of "mc3" , but clipNumber is undefined instead.
Is the keyword "this" not treated as a regular string data type?

Trouble With The "this" Keyword
So I'm not sure if I'm doing something wrong here but I was going through a tutorial in a book I found and one of the example statements was something like this

Code:

this.addEventListener(MouseEvent.MOUSE_OUT, grow);
      
      private function grow(Event:MouseEvent):void
      {
         bttnOne.scaleX *= 1.5;
         bttnOne.scaleY *= 1.5;
      } // End Grow

In theory this should call "grow" function by whatever movie clip was moused over. I noticed some really funny things happening though when using this method. The whole movie stage seemed to jump around when I would mouse over my object. My object didn't simply grow, it grew and moved. So after fiddling with this for a while I tried adding the event listener just for the button it self. BOOM every thing worked. So I wondered what is in this "this" variable, so I traced it out. I was expecting the name of the object to be the outcome of the trace statement but what I got was:

[object ButtonClass]

So how do you use the "this" key word in Actionscript 3. All of the tutorials have made it seem that the calling movie clip will be referenced by the "this" keyword.

Any assistance on the matter?

Thanks,
Steve

"this" Keyword
I have downloaded code from http://www.flashkit.com/movies/3D/En...1937/index.php

and there is a portion of code:

function point3d(x,y,z) {
this.num = num;
this.x = x;
this.y = y;
this.z = z;
this.scale = 100;
num++;
}
.
.
.
point1 = new point3d(-50,-50, -50);
...

Well i read about "this" in help:
In the following example, the keyword this references the Circle object.

function Circle(radius) {
this.radius = radius;
this.area = Math.PI * radius * radius;
}


but i still can't understand what is the difference between this.x and x, what are the values?
thanks!

"this" Keyword Help
Hi everyone,

This is my first post here, so hi!

I've just started learning as3 (I have no as2 exp.), and I'm having a little trouble understanding what the "this" keyword does and how it can be used. I've been trying to find resources but it is hard, as "this" is a very common word so there are many irrelevant links in google. (and the flash cs3 help is confusing for a beginner)... Can anyone point me to an explanation which is a bit easier to understand for someone like me?

Also, and I'm not sure if this warrants a whole post, but I'm wondering in situations where I have many buttons, and I want each button to output a number when it is pressed, is it necessary to have one function for each button or will a single function suffice?

Thanks! I hope I used the proper terminology and you guys understood what I was trying to say...

Copyright © 2005-08 www.BigResource.com, All rights reserved