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.aspackage { 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?
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 07-29-2008, 09:20 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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?
One Conceptual Question.. RIA
One conceptual question.. RIA
Hi folks.
What is RIA?? is one concept or onother produtc from macromedia??
I only "do" RIA with flash remoting???
Thanks
Conceptual Problem
Can someone help me to understand which would be the sintaxis to do this?
I have a component (piechart) that uses this sintaxis to add data to it:
var items = [ {label:"Tom Hanks", value:100, color:0xF2AC0C},
{label:"Tom Cruise", value:35, color:0x1160B8},
{label:"Hugh Jackman", value:35, color:0xBF0000},
{label:"Jack Nicholson", value:25, color:0x00247C},
{label:"Denzel Washington", value:20, color:0x008900},
{label:"Hugh Grant", value:10, color:0xE95D0F},
{label:"Billy Bob Thornton", value:10, color:0xAC12CD}];
pc.setSeries(items);
On the other hand, I have a PHP that sends to my SWF 2 arrays: theNames and theValues.
How can I assign those 2 arrays to the component? I canīt figure out how to assign it dinamically. The documentation on the components is not good neither.
Conceptual Help For Algorythem.
I'm trying to make an mmorpg but am unsure how to proceed. I would like to make it along the lines of: v5.neondragon.net/ but there are a few things that I'm not sure how I'm going to do. I have it where it saves data on the server (still working on it), I've also made a server clock to keep everything synced. I've always been annoyed by the fact that websites like the one above could make things run smoother by packaging it all in flash. The trouble I'm running into is I can't actually install any software on my server so I'm making do with saving data in a text file. Everything will have to be done this way. I'm just having a bit of trouble conceiving how to do the battle system this way or adding or subtracting resources considering all of the calculations will be done in the swf. I would love to work on this with someone else. If anyone's interested then just pm me.
Conceptual Approach To This
I have a question as to whether there is a better via variable tracking or something to accomplish this.
I have a desk calendar movie clip. Upon an onRelease function on the main timeline, the clip will be loaded into an empty clip and will play the first few frames which will rip off the top piece, zoom the graphic to a bigger size and then populate two dynamic text boxes with the current date and a random quote.
Upon clicking a 'close' button in this movie clip, the calendar will zoom back down to the original size and just have the date visible.
From this point on, I don't want to replay the initial animation but rather just zoom the calendar to the bigger size where the date and quote is available.
So, I thought I could, via this new movieclip, upon the close just zoom down and then load a new movie into the clip which only has the animation I need and a label with the same name so that I don't have to have to worry about the newest movie clip to be named.
This way, once the initial animation is seen, it won't be seen again...unless of course they diable their cache and come back later on the same day but that doesn't bug me.
The other technique was to use:
ActionScript Code:
this.onRelease = function() {
delete this.onRelease;
}
Within the initial movie clip after all the animation but then I couldn't reshow just the date and quote.
Is there a better way to tell Flash.. "onRelease, load this movie clip and play this animation. But, if they have already seen the first part, just play the clip from "x" point on?"
Thanks
Design/conceptual Question
Would anyone here take a minute and look at this http://web.icq.com/shockwave/0,,4845,00.swf
I have been asked to do something similar to this and I have a few questions on how:
1) If I were given the graphics...would there need to be a graphic for every animated movement?
2) Would it be suggested to do a movie clip for each deer/santa and then to put each graphic on a keyframe?
3) What graphics would work best for this?
4) To bring say, deer1, back to its original state, or first keyframe...how would this be done? I suppose to play deer1 I could just say onclick play "deer1" movieclip?
Thanks,
jhb
More Of A Conceptual Question Regarding When Flash Displays Frames
hi guys, just wanna clarify a few concepts regarding flash's process of rendering and displaying frames:
for e.g
consider the code
Code:
var SW:Number = Stage.width;
var SH:Number = Stage.height;
var nMover:Number = setInterval(mover, 500);
function mover():Void{
ball_mc._x = 900;
if(ball_mc._x > SW - ball_mc._width/2 || ball_mc._x < ball_mc._width/2 ){
ball_mc._x = SW/2;
ball_mc._y = SH/2;
trace("inside");
}
updateAfterEvent();
}
Now the first time i saw this code i thought that for a split second the ball_mc would be at 900 pixels and then it would be put back to cordinates SW/2 and SH/2. But this isn't the case ..instead it isnt put at 900 pixels at all.
Is this because when flash is in a function it does not refresh the screen until ALL the statements in the function have been executed?
Also i know updateAfterEvent refreshes the screen so then in the above code if i put the update event directly after ball_mc._x = 900 like :
ball_mc._x = 900;
updateAfterEvent();
Should'nt now at least it go to x = 900 for a split second and then return?
Yeah the way and when exactly, and in which conditions flash refreshes/renders/ displays the frames is confusing me a bit.
Any input would be appreciated cheers
Using Scenes To Navigate A Conceptual Portfolio Site.
im wondering if there is anyway to template a certain scene...if scene 1 has static shapes all linked to seperate scenes....can i template scene 1's design to import it into all the other scenes? with out importing actions from the original scene?
here's an example i tried to whip up, but had troubles linking scene 3...so after scene 2 wait a sec, and it will transition into scene 3 which SHOULD be activated by clicking the "white box"
http://www.motiv8gaming.org/peejah/test.html
thanx alot,
pj
Conceptual Player And Ground Collision Question..
NEVERMIND. I figured it out. This is the first time I think I have the concept down right, but my issue was that during each frame, I was adding gravity AFTER checking for collision. I thought I should leave the post intact just in case it helps someone else.
I've never actually been able to figure out this specific issue, but I am trying once again to make a flash game which has a player falling onto ground at some point with gravity being the reason.
I need to make sure I have this right conceptually. My player has a variable vy. The player movie clip has it's x,y at the bottom left of the image. The ground movie clip has it's x,y at the top left of the image.
Each frame, I add gravity (ex. 1 pixel/second) to the vy variable. So it is accelerating the player down. However, before I actually add the vy value to the player's y value, I check to see if the player's next position will collide with the ground. To do this, I use hitTestPoint. Specifically, I run ground's hitTestPoint on the x,y+1 of the character (so the point just below my player), and on every value up to x,y+vy. This is to check the character isn't flying right through the ground.
Hopefully I am making sense so far.
If that collision test doesn't return true, then I go ahead and add the vy to the y value of the character.
However, if it returns true, I set the vy to 0. I also move the player x,y to one pixel above the ground x,y value.
My problem is that the player falls, hits the ground, and then keeps getting bumped up and down one pixel.
I tested ground's hitTestObject on the player, and it is returning true. If I am thinking correctly, shouldn't this never return true? I thought I set it up so that the player's box never actually hit's the ground's box, because of the prediction using hitTestPoint...
I believe this problem is what caused huge issues down the line for me once before when I attempted to make a game. What am I doing wrong? Thank you.
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!
'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'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]});
}
}
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?
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
|