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




Defining Classes As Their Interface Type?



I'm new to design patterns and came across this in an example:


Code:
var model:IModel = new Model();
The Model class implements the IModel interface. Is there any particular reason why this model variable (which is a Model) is defined as an IModel? Is this for memory or performance or something?

Please somebody shed some light...



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 11-15-2007, 03:33 PM


View Complete Forum Thread with Replies

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

Defining Flash Accessibility Type
Hello All,

Is it possible to make screen reader read just the name property of the _accProps Object and omitting the word "Button" when using Flash Accessibility?

Also, Screen readers seems to eat up the tab and arrow keys. is there a way around that?

And one last thing? how does the Flash Focus Manager work? because the screen readers are eating up the keys... they render my custom focus manager useless... any help is much appreciated. Thank you

Defining A Path For As3 Classes
Hi,

This has got to be super simple.
All I want to do is define a class to be imported based on a pre-defined classpath (via flash prefs).

For ex., I have the folder structure:

flash/classes/utils

in the utils folder i have a file called "init.as"

in the prefs i have the 'classes' folder added

in the init.as file i have


Code:
package com.classes.utils.init
{
public class Intern
{
public function SomeFunc()
{
//nothing
}
}
}
and in my flash file in an actionscript layer i have


Code:
import com.classes.utils.init.*;
var myIntern:Intern = new Intern;
but i get the error "type was not found or was not a compile-time constant: Intern"



what's wrong??

Declaring And Defining Classes In The Timeline (AS3)
I'm picking up a little OOP in AS3, using my Pong game (once again), which has been successfully migrated. Like most games, my game has several instances of a couple of objects. I'm thinking of creating classes for each object, which would probably clean up my code and allow me to make further optimizations.

For instance, my game's paddle objects are MovieClips, just as in AS2. They are practically identical, although one is computer-controlled. In the absence of the duplicateMovieClip() method, I'm basically forced to either write different code that draws each paddle, or make a paddle-drawing function that accepts each paddle MovieClip as a parameter. If I had a paddle class, I could put this code in the constructor function instead.

Also, none of my game's objects need a timeline, so they should not be MovieClips. I've tried changing their type to Sprite (or Shape, in some cases), but it seems that you can't declare properties of a Sprite- or of any displayobject, it seems, that isn't a MovieClip. That may have something to do with this whole "sealed class" business. However, if I made public classes for my objects, which would extend Sprite or Shape, I would probably have more freedom to do what I choose with the objects that I make.

I think that I'm preaching to the choir.

Here is my question: is there any way to declare and define a class in the timeline? All my code is currently there; if it's possible, that's where I'd like to keep it.

Of course, once I'm done I'll stick the Pong source up on the forum.

Thanks in advance!

What Type Of Interface Is This?
and where can i find tutorials on making my own

ok i have definately seen these types of flash sites around maybe even seen some source code, i was just not insightful enough to bookmark the sites!

i have quickly knocked up a simple animation of how the interface works

http://algorythm.co.uk/design/concept.gif

you have some squares or rectangles as the navigation, the position of the navigation squares represents the content on the flash canvas.

the flash movie uses a mask to hide all but the current square. if you were to click on the top right navigation square the mask (or canvas) would move over to the right, you would see the content scroll untill you reached the content you want to see.

it's simple enough, there is an example here, but it's not exactly what i'm looking for:

http://www.sirahtour.com/

if you click on the who/where etc you can see that it's a mask moving over a big image.

so if anybody knows what i mean and has seen this type of tutorial i would be very greatfull for a link.

thanks in advance

Windows Type Interface
Hi there. I have a menu where they click a word at the left and it pops up a draggable window in FLash. Then when they click another word at the left it pops up another draggable window.

My problem is in swapDepths. When I click ona window I want it to come to the very top. But when I do that say it gets put to level 3. The other 2 windows are obscured which is good. But sometimes when I click on one to go to the top, the other two below switch. Its weird. I just want to be able to click on a window, have it appear on the top level, and the other 2 stay the same until one of them is clicked. Then it comes to the top etc.


Thanks!

Any Tutorials For This Type Of Interface?
I am curious if anyone has seen a tutorial showing how to do something like what is seen on Canon's product comparison page.

http://www.usa.canon.com/consumer/co...categoryid=113

Click three boxes and hit the "Compare Now" button. I am interested in the flash interface of the page that pops up, where you can drag pictures into the matrix and switch which products are being compared.

I would like to know how people think two things are done:

1. Drag the picture onto another picture and have it load that external data. Hit test?

2. How the Matrix resizes depending on the information that is loaded into it.

If anyone has seen a tutorial explaining #2 I would be interested in hearing about it.

Thanks

Interface & Type Coercion Failure
I'm retooling my physics engine with interfaces in order to use better OOP practices, and I've run into what I think is a simple hitch, but I can't quite figure out.

I have an interface IPhysicsEntity.as

ActionScript Code:
package PhysicsSystem {
    public interface IPhysicsEntity {
        function physicsUpdate():void;
    }
}

and I have a function in another location:

ActionScript Code:
public function addObject(whichObject:IPhysicsEntity):void {
    objectArray.push(whichObject);
}

and I'm passing into the addObject function something that implements IPhysicsEntity..


ActionScript Code:
import PhysicsSystem.IPhysicsEntity;
   
public class PhysicsObject extends Sprite implements IPhysicsEntity {
/// et cetera

and I'm getting the following error:
TypeError: Error #1034: Type Coercion failed: cannot convert PhysicsObject@3135791 to PhysicsSystem.IPhysicsEntity.

Am I doing something obviously wrong?

Question About Using An Interface As Object Type
Hi all,

I am typing some of my objects to the Interface they implement. While this is helpful is many ways, I am finding myself needing to cast every time I wanted to access the object's properties such as x, y or invoke methods like addChild() and such.

I don't mid casting a few times, but it really getting to a point where there is to much casting involved. Any idea how to get around this problem?

Cheers

Filter List As You Type Interface Like On An IPod
I'm working on a filter-as-you-type list like on an iPod: partial matches show below the text field, and as you type, your search gets more specific and less strings show in the list below. This is to be implemented in a name-lookup. My problem is both with algorithm and speed.

Current setup is this:
-One text field, one ListBox. This is the search setup.
-One hidden text field, one ListBox. This is the "last search string" and original, complete list of names. On init, this list populates the filtered search ListBox 1:1.

As the user proceeds to type a name in the search box, the list below gets filtered like this:
- first check that the previously typed text is contained in the current/new search string. If it is, we know to simply filter out the mismatches and trim the list. If it is not, then this is a new search (or backed-up a character), and the entire list is recreated based on the hidden, original list.
- To recreate the list: Clear the ListBox and copy 1:1 from the hidden original.
- To remove mismatches: Loop the entire ListBox and remove items that don't match with .removeItemAt().

This is incredibly slow on my 1.6GHz machine, and on my 700MHz production kiosk, it is impossible. In addition to that, something in my implementation is buggy, and it seems to miss every other name upon filtering...

Would someone please take a crack at it and advise me where I'm going wrong or even offer a better way? Oh, and I have commented out removeItemAt in order to verify that that's a slow-down: the thing is quick as lightening when not having to alter the ListBox items...


Code:
function onSearchChange(str) {
// if search text contains previously searched text, remove items that do not contain search text,
//otherwise, rebuild list based on search
var stxt:String = txtSearch.text.toLowerCase();
var prevstxt:String = txtPrevSearch.text;
var arrstxt:Array = stxt.split(" ");
//trace(""" + stxt + """ + " " + """ + prevstxt + """);
if (stxt.indexOf(prevstxt) > -1) {
// search text contains previous search-- remove filtered
var curnam:String = "";
// loop thru entire current list
var numitems:Number = liNames.length;
for (var i=0; i < numitems; i++) {
curnam = liNames.getItemAt(i).label.toLowerCase();
// loop thru all space-delimited individual search words; compare against current item in list
if (curnam.indexOf(stxt) < 0) {
//trace("removed " + curnam + " for " + stxt);
liNames.removeItemAt(i);
numitems--; i--;// reset counters: number of items and current, b/c removeItemAt is immediate
}
}
//trace("Removed item(s)");
} else {
// search text does not contain prev search (backspace, replace, etc)-- rebuild list based on current search
liNames.removeAll();
var curnam:String = "";
var curitem;
for (var i=0; i < liNamesSrc.length; i++) {
curitem = liNamesSrc.getItemAt(i);
curnam = curitem.label.toLowerCase();
var blninc:Boolean = false;
// loop thru all space-delimited individual search words; compare against current item in list
// - only add item if all search terms are contained within current item (like an iterative AND)
for (stxti in arrstxt) {
if (curnam.indexOf(arrstxt[stxti]) > -1) {
blninc = true;
continue;
} else {
blninc = false;
break
}
}
if (blninc) {
liNames.addItem(curitem);
}
}
trace("rebuilt list.");

}
txtPrevSearch.text = stxt;
txtCnt.text = liNames.length;
}

Interface With On Stage Symbols From External Classes?
Hello. This is my third attempt. I broke this to the most simplest form and I cannot get it. I have an external class InterAction.as I have a MovieClip on the stage named PressMe_MC. I am trying to access it so I can make it a button or change color.


Code:
package
{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.MouseEvent;

public class InterAction extends Sprite
{
public var Path:Sprite = new Sprite();

public function InterAction()
{
trace("InterAction Class");

//var Container:Sprite = new Sprite();

//Path.name = "PressMe_MC";

addChild(Path);
//var target:DisplayObject = this.stage.getChildByName(getChildByName("PressMe_MC"));
//trace(getChildIndex(target)); // 0

}

public function addPathMC():void
{
Path.addChild(this.stage.getChildByName("PressMe_MC")); //make sure you assign a name to your pathMc
}
}
}
On the first frame on the stage


Code:
import InterAction;



var DoInteract:InterAction = new InterAction();
addChild(DoInteract);

DoInteract.addPathMC();
this is the error I am getting

InterAction Class
TypeError: Error #2007: Parameter child must be non-null.
at flash.display:isplayObjectContainer/addChild()
at InterAction/addPathMC()
at Main1_fla::MainTimeline/Main1_fla::frame1()

Interface With On Stage Symbols From External Classes?
Hello. This is my third attempt. I broke this to the most simplest form and I cannot get it. I have an external class InterAction.as I have a MovieClip on the stage named PressMe_MC. I am trying to access it so I can make it a button or change color.


Code:
package
{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.MouseEvent;

public class InterAction extends Sprite
{
public var Path:Sprite = new Sprite();

public function InterAction()
{
trace("InterAction Class");

//var Container:Sprite = new Sprite();

//Path.name = "PressMe_MC";

addChild(Path);
//var target:DisplayObject = this.stage.getChildByName(getChildByName("PressMe_MC"));
//trace(getChildIndex(target)); // 0

}

public function addPathMC():void
{
Path.addChild(this.stage.getChildByName("PressMe_MC")); //make sure you assign a name to your pathMc
}
}
}
On the first frame on the stage


Code:
import InterAction;



var DoInteract:InterAction = new InterAction();
addChild(DoInteract);

DoInteract.addPathMC();
this is the error I am getting

InterAction Class
TypeError: Error #2007: Parameter child must be non-null.
at flash.display:isplayObjectContainer/addChild()
at InterAction/addPathMC()
at Main1_fla::MainTimeline/Main1_fla::frame1()

Common Interface For Classes That Extend Sprite
Hei!

Im trying to implement an interface for custom classes that extend Sprite (DisplayObject), but i can't use DO methods on those instances afterwards, when called via the interface.. illustration:

Code:
interface:
public interface IListingItem extends IEventDispatcher
{
function setData( someData ):void;
}


// usage..
var instance:IListingItem = new MyDisplayObject( ); // MyDisplayObject extends Sprite, implements IListingItem
instance.addEventListener( Event.COMPLETE, onItemLoaded ); // okay, since interface extends IEventDispatcher
instance.setData( "bla" ); // still okay, since interface defines this method
instance.x = 10; // 1119: Access of possibly undefined property x through a reference with static type classes.interfaces:IListingItem.
this.addChild( instance ); // i guess this would also throw error
So maybe i do something wrong? Should be interface only used for calling some simple methods that don't work with display list?
Initially i also got an error calling that addEventListener on the content instance, that disappeared after i told the interface to extend IEventDispatcher. Is there similiar interface that defines DO properties like ISprite or something? Or should this technique not be used at all? Any ideas welcome!

Thanks design-patterns-flash-gurus!

Type Casting Classes
Alright let's say I have a MovieClip in the library with the linkage set to TestClass and I have this code...

var string1:String = "Test";
var string2:String = "Class";

var testClass:* = new Class([string1 + string2])();
this.addChild(testClass);

so testClass should be an instance of TestClass, this works for me sometimes and sometimes it doesn't.

Does any one have any advice as a better way to do this, and what this tecnique is called ( root["string" + "1"])?

Thanks for all you guy's help!

Defining/Re-defining Variable Value Based On Button Press?
I've got 50 buttons, each with an instance name of Example_1 thru Example_50.
I have a variable x whose value I would like to redefine based on the button pressed; i.e. Example_1 pressed, x = 1, Example_2 pressed x = 2, and so on.

Is there a way to do this that is more graceful than a button action for each button instance?

Thanks

Defining A :Function Type Of Function
Hi All,

There may not be a way to do this, but I thought that I would be able to return a function call by doing something like this:


PHP Code:



//pass vars zoomTo(hotels[i]);//passes "port" correctlyfunction zoomTo(whichMov):Function {    callFunc = "move_"+whichMov; //receives "port" correctly    return (callFunc);}//trying to call this function from  zoomTo() above:function move_port() {    moveMap(-1600,-1200,300,300,1);} 




The variables are being passed correctly, however, I'm not sure how to call a function this way. Any help?

Fancy Box Type Moving Graphic Type Cool Efect But Im To Dumb Type Thingy
i am tring to make a box thinky simaler to the one on www.starvingeyes.com but cant even work out how to start it. is there anyone who can point me in the right direction or to a tutorial ?

the box has a graphic inside a grided box the sections of the graphic fade in and out as the mouse goes over them and displays random sections when the user is not moving the mouse over the box

i did find java tutorials for this effect but would much preffer it to come from flash as java is a bugger to get working on some machines

Any way thanks in advance for any help

Steven Green one_mad_punk@yahoo.co.uk

Closing Tabs And Moving Interface Interface
before i start HERE is the design i am working with,

What i want to do is when you click on a menu item i want to close the tabs that are allready open and move the interface across the screen to a different position and than open certain tabs (sections) at the new position.

What i want to know is is there a way of finding out which tabs are open and need to be closed and closing them and which are allready closed and bypassing them and than moving the interface to a different position.

If there is a way of doing this could anyone point me in the right direction of where to go to learn how?

I hope i am making some sense i am prettty new to flash and this is one of my first big adventures with flash.

any help would be greatly appreciated.

ancora

Implicit Coercion Of A Value Of Type String To An Unrelated Type Function
Hi there

Why I can't use an "eval" function (i am not sure this is the right terminology) inside addEventListener (I put in yellow) ?

for (i=1;i<10;i++) {
var constructFunction1:String;
var constructFunction2:String;
constructFunction1="choix3"+i+"Handler";
constructFunction2="choix3"+i+"HandlerClick";
MovieClip(this["choix"+i]).addEventListener(MouseEvent.MOUSE_OVER,constructFunction);


Then error in the compiler:

1067: Implicit coercion of a value of type String to an unrelated type Function.

Pixel/Bitmap Vs True Type/Open Type Fonts
I'm new to flash and I've been getting conflicting advice on which type of fonts to use. I've done several searches in the forms and I'm still just as puzzled so I've decided to start my own discussion on the subject. So here we go:
1) Are Pixel and bitmap fonts the same type of font?
2) Which is better to use True Type or Pixel (bitmap) fonts and where and/or why

Please help this newbie to flash and jump in with your opinion, experiences, etc.

Thanks

Making A String Type Into A Number Type
The title is probably misleading and because I’m new to flash and coding this is probably a very simple problem. What I am trying to do is make a function in which I give the name of an instance, it adds the ._alpha and then have the function take the instance and have the instance go from being visible to invisible.

The following is the code that I have developed.



function dealpha(dename:Number):Void{
dealpha = (dename) ++ (._alpha);
for(i=0;i<100;i++){
dealpha -=1;};
};
dealpha(mc_mc);

The error that I get when I compile the file is this

Syntax error.
dealpha = (dename) ++ (._alpha);

Total ActionScript Errors: 1 Reported Errors: 1


I appreciate any help that I can get with this code.

Compile Type Check For Object Type
I used Flex Builder 3 to compile my actionscript. I have a question regarding the compile type check for type Object. I have set my compiler to strict mode, but it does not seem to detect this compile type error:

var o:Object = new Object();
o.foo(); //this should generate compile type error because foo() is not method inside Object, but flex builder is just silent.

But if I try this

var s:String = new String();
s.foo(); //flex build flag this as error

flex builder correctly detects the reference error.

I can't understand the reason for the different behavior for the Object type versus the String type. Can anyone help to explain the reason for this?

Thanks.

Custom Classes: One Class Tracks Multiple Other Classes?
I'm working on a coloring that allows kids to place objects on a scene and then color them so the image can be printed out. So assume you have sky background, the child can select a bird object, drag it into place and once they have it in place, color everything on the page (with a given palette of colors.)

So far it going great. However I want to track what objects have been added to the drawing on the fly. I have a potential solution using arrays but I'm thinking this is perfect opportunity to start using custom classes.

I'm thinking that I'd create a new instantiate a copy of the object class each time an object is added to the scene. However to track the objects added to the scene I'm thinking I'll also use an listing class to track them.

What I'm not sure about is the would the listing class simply contain an array of object identifiers? Any thoughts on the structure of the listing class?

I'm very new to oop as I've mainly been doing procedural programming up to this point but I'm eager to give this a shot.

Thanks!

Using Flex Classes In Classes Linked To Symbols
Hi all

I have a fla file where I link a symbol to an action script class. This action script classes references mx.collections.ArrayCollection; so when I attempt to publish the fla file, I get the error message:
1017: The definition of base class ArrayCollection was not found.

I then tried to add a class path (this folder contains the mx... classes):
C:Program FilesAdobeFlex Builder 3sdks3.0.0frameworksprojectsframeworksrc

and the the above error 1017 wasresolved, but now I get the error:

Version.as, line 18 1004: Namespace was not found or is not a compile-time constant.

So now I am pretty much stuck. What do I need to do for this to work ? Please note that the code compiles fine in flex, so it is not som basic coding error ?

Instantiating Classes Inside Classes
I have a class called spaceship in which i have instanciated another class weapon. However, when i call on a method of weapon (which at this point is just simply trying to trace "hello"), it doenst work and the object basically doenst exist. It's delcared in the class as:

Code:
private var ShipWeapon:weapon;
Note that when I instantiate a weapon class on the main timeline the thing works and "hello" is printed to the output panel. However, nothing at all happens when instantiated the weapon class inside my spaceship class. Both traces come up "undefined". Do i need to declare the class as some sore of special class or somethings? Thanks in advance

[classes] Best Method To Communicate Between Classes
Here's the scenerio:

I have a component that is associated with a class. Inside the component is an empty movieclip.

-component (part of a class)
&nbsp;&nbsp;-mc

The main component's class upon init will load a movie from a remote server into the mc movieclip. System.security.allowDomain is in there...

Now, inside the swf that gets loaded into the mc is an empty movieclip that's associated with it's own class:

-component (part of a class)
&nbsp;&nbsp;-mc (contains loaded movie)
&nbsp;&nbsp;&nbsp;&nbsp;-mc (part of a separate class)


Now here's the challenge... I need to have the loaded movie > mc's class be able to communicate with the main component's class.

What's the best setup to be able to communicate between the two classes directly? That is, if I don't have loaded movie > mc > class inherit from the component's class.

thanks in advance...

Nathan

Best Flash Classes (Taught Classes)
I think this site is great for newbies in the flash world to Advanced flash developers. I am an intermediate flash designer/developer and I have been using flash since 1998. My strengths are more on the design side for sure. I am just curious what your experience is with going to a week long flash class. I have been to several classes and my last one was a week long one with Joshua Davis on advanced actionscript in NYC a while back. This was still coding in AS1 with dot syntax so only some of it is relevant to what we are doing today. I am wondering what are the best classes out there today and what your experiences are if you have been to any. I wish another event like this: grant skinners FITC flash 8 workshop or this Colin Moocks actionscript bootcamp were available but I can't find anything like it. My friend went to Colin's workshop a while back and mentioned how he went into design patterns with AS2 and it would be great to learn about that. ANyhow any suggestions would be great. Post your thoughts.

Instantiating Classes Inside Classes
I have a class called spaceship in which i have instanciated another class weapon. However, when i call on a method of weapon (which at this point is just simply trying to trace "hello"), it doenst work. The compiler obviously didn't flag anything, but i also get "undefined" for all my weapon class varibles. Do i need to declare the class as some sore of special class or somethings? Thanks in advance

Help Defining Function
I am tring to build a navigation system, that when the user rolls over a certain MC, the MC will rollout to a predetermined position along the x axis. I believe the best way to accomplish this would be by creating a function that when the user passes over the MC, it slides out. I am pretty sure I'll have to use the slide algorithm to create the sliding/"rolling out" effect.

However, I am puzzled on how to accomplish this effect. Any help would be greatly appreciated. thanks.

ryan

Defining Coordinates
hi,
I have a rectangle and a circle drawn in it. Then I have a draggable movie clip in the rectangle.
My problem is, I want the movie clip to move inside the rectangle (given the constrain to rectangle option) but not enter the circle.
What script do I define for the movie clip to drag upto a maximum of some coordinates(the rectangle) and not go below some minimum coordinates(not enter the circle).

Thanxz.

Defining Variables
I know this is kind of a dumb question, but I need help anyway. I'm trying to call a global variable from a movie clip. In my main timeline I have declared a variable called "scene". In my movie clip I want to check the value of "scene".
Here is the main timeline code:

scene = "vehiclereg";

Here is the movieclip code:

if (scene == "vehiclereg") {
nextFrame ();
} else {
prevFrame ();
}

I've messed around with trying _root.scene and other scope stuff, but I can't get it to work. The movie clip just sits there. Well, any help would be appreciated.

Thanks!

Defining A Grid
Can anyone explain to me how I'm supposed to define a grid? Like, if i wanted to make a chess game.

I looked at some source, and realize I can create rows and coulms using two arrays with For loops, but how do I define the position of each row/column/cell using x-y coordinates so that a piece on the grid can be moved to specific square?

Thanks.
CountBule

Defining Functions
How do I define a function in flash 5, and how do i call it when i need it ie. on(press)?

Thanx!

Pre-defining MX Privilages
Hey, is there anyway of doing this?

You know if you load up an .swf and it asks you if you want to give it access to your microphone; how much space it can take up etc - is there a way of pre-defining it so it never prompts you?

Defining Functions
so apparently there's 2 ways of defining functions

function myFunction(args){
}

OR

myFunction = function(args){
};

What's the difference?

How come the first one returns [function, myFunction] in the outputWindow and the second one returns just [function]?

Why can't I call the second one with a setInterval but I can call it directly?

Defining Positions...
Hi there,

I've made a 'navigation' using this scripting, which I've got from the forum a couple of months ago... .

the file I'm talking about is available at

www.woowoos.com/vccc/damn.zip (7.04Mb)


what I need to do, is to make sure that once you click a name of someone, flash redirects the big movieclip to put that person in the middle of the stage... .

Is that possible with this script?


greetings

robin

Defining Boundaries
Hi,
I have a ball (as a MC) with a Stop action on frame 1.
Frame 2 has the following:

if (_y<0) {
_y = 0;
if (_rotation>=0) {
_rotation = 180-_rotation;
} else {
_rotation = -(180+_rotation);
}
} else if (_y>600) {
_y = 600;
if (_rotation>=0) {
_rotation = -(180+_rotation);
} else {
_rotation = 180-_rotation;
}
}
if (_x<0) {
_x = 0;
_rotation = -_rotation;
} else if (_x>800) {
_x = 800;
_rotation = -_rotation;
}
_y -= Math.cos(0.01745*_rotation)*speed;
_x += Math.sin(0.01745*_rotation)*speed;
if (speed>0.1) {
speed -= 0.1;
} else {
speed = 0;
prevFrame();
}

Frame 3 just has:
prevFrame();
play();

The ball basically bounces off the 4 walls of my 800x600 movie when activated. But how do i define another smaller set of boundaries within my movie (see diagram)so ball will bounce in this smaller section as well?
I thought about using hittest on an invisible area so when ball enters this area it changes the boundaries to the smaller section i need? is this right or is there an easier way?? help!

cheers
geoff

Defining And Using Objects
I'm making a game and I've decided the best way to do it is to make my own objects. I'm just not sure how I would do this. What I want to do is make a function so that I create a new enemy object that has a certain amount of health or something (would that be called a class?). Heres what I think i have to do, just tell me what I have to change.
I put this in the first frame of my movie, all of the other code is in frames, not in movieclips.
function Guy() {
health = 1;
ammo = 10;
moveSpeed = 20;
}
I know about parameters and stuff so I know how to set health to a variable. But I dont know how to set a movie clip to this object. Do I do it within the method or after i declare the object? I'm guessing that you attach a movieclip to the object like this
Frank = new Guy();
Frank.attachMovie("badguy", "badguy" + i, i);
I tried that though and it didn't work out too well. Do i have the right idea? I just need to know where to put stuff.

Help W/ Defining Variables
im kind of new with this flash stuff and this is was made as more of a learning thing for me and im kind of having a problem w/ getting a variable from a mc to my main variables, is there something that i have to do w/ _root, if you want to see what im talking about because i usualy confuse everybody, go to www.dark-studios.com/crosshairgame.swf

when you click on the target, it adds 1 to the variable hit, and after adding 1, it says to refresh the dynamic text telling you how many hits you have, and its there where im having problems, please tell me what im doing wrong

A Little Help Defining My Variables?
I have created a couple hundred SWFs that I am trying to access through a bookmark (via a cookie). I have the main swf file successfully reading the cookie, and going to the map page if there is no cookie, but I am having trouble getting the enter button (below) to read the cookie string to load the bookmarked swf. I know I have something screwed up in my "else" statement, but can't figure it out.

on (press) {
getURL ("javascript:document.PR101.SetVariable('_level0.t xtReadCookie',(document.cookie) ? document.cookie : '');");
}
on (release) {
if (_level0.txtReadCookie eq "") {
loadMovieNum ("map.swf", 0);
} else {
var pageToLoad = "_level0.txtReadCookie";
// pageToLoad = bkmk();
loadMovieNum = ("pageToLoad" + ".swf", 0);
}
}

Defining A Variable In MX
I would like to define the data in a dynamic text box named score as a variable, but I'm not really sure of the syntax.
thanks.

Defining OnRelease Twice?
Can i add an onRelease function to a button that has already has an onRelease function defined elsewhere in the script ?

My 5 buttons were created and defined from within a for loop. The buttons animate on a onRelease function within this loop. So thats all fine and dandy, i have a navigation bar that kinda works, but now i want to add content with attachMovie for each button without adding more script to my for loop.

G

Defining A Variable. HELP...
Hey all,

I've got several nested thumbnail pics which are buttons, that when pressed, need to go into a another nested symbol, play the first ten frames, and then, depending on which thumb was pressed, go to a specific frame label.

I'm trying to define a variable on each button that's activated when pressed so it will remember and then go to the right label.

this is on the first btn;

on(press){
vendor="baileyStreet"
_root.homeDecor.gotoAndPlay("intro");
}

and then once it's played the ten frame intro I need it to jump to a specific frame in that same symbol by acknowledging the defined variable and going there.

this is on the last frame after the intro;

stop();

gotoAndPlay(vendor);


I'm doing something wrong because it's just sits on the 10th frame and doesn't go anywhere. I need some help!

thanks...

Defining A Variable... HELP... (again)
I've got several nested thumbnail pics which are buttons, that when pressed, need to go into a another nested symbol, play the first ten frames, and then, depending on which thumb was pressed, go to a specific frame label.

I'm trying to define a variable on each button that's activated when pressed so it will remember and then go to the right label.

this is on the first btn;

on(press){
vendor="baileyStreet"
_root.gotoAndPlay("home decor vendors");
}

and then once it's played the ten frame intro I need it to jump to a specific frame in that same symbol by acknowledging the defined variable and going there.

this is on the last frame after the intro;


gotoAndPlay(vendor);

Once a variable is defined, it's global right? Not just applicable to that nest level... It's got to be a syntax issue, but I can't figure it out. would really appreciate some enlightenment...

thanks...

Defining A Range...
Hi All,

I have a problem. My movie width is 500 pixels, I need this size to represent x size and be able to define the x size so that I can move a line along that line by a user being able to specify a value (x) in a input box.

This is a GPS app, basically I have a city center, the lat and long values have a range of 1500, but my movie is only 500 wide (and 500 high), when I get the lat and long values I need to move 2 lines along the X and Y values to show your location. If you took this example the movement of this would have to be 500/1500 = 0.33 . Does Flash support the ability to move a line by ultra small decimals? (I noticed it rounds decimals up to 1 decimal place)

I hope you understand what I mean.

Cheers

Carl Bruiners

Defining Loadedmc
I have a collection of buttons in a external swf. Each of the buttons has


Code:
on (release) {
_root.centre.boxmc.target_xscale = 675;
_root.centre.boxmc.target_yscale = 445;
_root.centre2.loadMovie"one.swf";


....."two.swf, three.swf etc etc


This works fine, however if i press the button that has the relevant loaded swf, if reloads it. Is there some script that i can add to the button that when pressed, itll check which swf is loaded and if the swf is the same as the pressed button action itll just ignore it and NOT reload the same movie..?

....i hope this makes sence...thanks in advance for your help...i feel like i want to cry!

Defining An Instance Name If 1 In Cs3?
Hi all

Ok I was using this script to create a menu system, Now I am using cs3 I am having some problems with instance names.

Code here: .swf attached below:


PHP Code:



numOfMenu = 4;
defaultY = 40;
max = new Array(80, 80, 80, 80);


for (i = 1; i <= numOfMenu; i++)
{
    this[i].defaultY = this[i]._y;
    this[i].bg.onPress = function ()
    {
        _global.over = this._parent._name;
    };
  
   
    this[i].bg._height = defaultY;
    if (i != 1)
    {
        this[i]._y = this[i - 1].bg._height + this[i - 1]._y;
    } // end if
    this[i].onEnterFrame = function ()
    {
        if (over == this._name)
        {
            this.direction = "next";
            this.nextFrame();
        }
        else
        {
            this.direction = "prev";
            this.prevFrame();
        } // end else if
        if (this._name > over)
        {
            this._y = this._y + (this.defaultY + max[over - 1] - this._y) / 4;
        }
        else
        {
            this._y = this._y + (this.defaultY - this._y) / 4;
        } // end else if
    };
} // end of for




The 4 movie clips on stage have the instances of 1, 2, 3, 4 but with cs3 I am unable to name a new mc instance of 5, 6 ecetera... How would I go about fixing this.?

Defining Functions...
Is there a way to define global functions outside of frames? Let me try to explain...

I have a script I want to write and let's say I want to pass in an argument into a function from the actionscript in frame 3 into a function. Is there a way I can make a function that I can call on it outside of the frame?

I'm trying to get a bunch of already defined variables that are defined in one frame and access them in another frame without having to rewrite all the code... or is it already possible to do this with nothing special to define?

Does any of my questions make sense?

Basically I'm altering a bitmap with alpha pixels in certain places ("erasing" it). But after I erase a little it takes you to another frame via gotoAndPlay and shows an entirely different subject matter, BUT I want to come back to the previous frame with the altered bitmap and I need it to stay updated or be able to define a function to store the altered bitmap and return to it when I come back to the frame.

Defining A Var In Actionscript
Ok Im very used to php, and Im trying to accomplish something in actionscript... heres what im trying to do

I have a line in my actionscript that goes like this:
loadVariables("http://www.blahblah.com/member/stats/charts/nutrition/npg.php?username=Mike", _root);

What I wanna be able to do is have the username instead of = Mike, to equal whatever it was given to it via URL embedding.

So If I embed the flash into a website using these tags:
<embed
src="http://www.mymuscle.com/member/stats/charts/nutrition/nsnew.swf?username=Mike"
quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="500" height="305" wmode="transparent"></embed>

That it would recognize Mike in the URL and put it in the actionscript

Please Please help me, Ive tried everything!!!!

Defining 'e.' Or 'event.'
Well, here's the simple, incomplete code I'm working with. I simply want to make a character (hero) move and animate when the left key is pressed. However, I can't determine whether the following script works:

ActionScript Code:
package{                                               
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    import flash.events.Event;
    import flash.display.MovieClip;

    public class character_movement extends MovieClip{     

    private var walkspeed:int = 4;
    public var left:Boolean;
    public var right:Boolean;
    private var walking:Boolean;
   
    function character_movement(){
        stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
        walking = false;
        }
    private function keyDownHandler():void{
        if (event.keyCode == 37){
            if (walking == false){
                walking = true;
                hero.gotoAndStop('walk');
                hero.scaleX -= .5;
                hero.x -= walkspeed;
                left = true;
            }
            }
    }
    }
}

The problem currently is the line
ActionScript Code:
if (event.keyCode == 37){
which returns an error 1121: access of udefined property event.

But I see this "event." or "e." in everyone's tutorial. What am I doing wrong?

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