Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-26-2009, 03:10 PM   #1
ScottH87
Registered User
 
Join Date: Nov 2009
Posts: 25
Default C++ Style Pointers?

Hi,

I'm fairly new to actionscript but not new to programming. I've had around for years of using C/C++ as a student before now.

Basically my question is, does AS3 have any functionality comparible to pointers in C/C++?

I'm trying to implement the A* algorithm into my Flex project, but am finding it difficult due to getting used too pointers when coding in C++. When I used A* in C++ I found pointers to be almost essential with the amount of data getting stored and passed around. Now I can even get the algorithm to work right :S

Please help

Thanks
ScottH87 is offline   Reply With Quote
Old 11-26-2009, 04:17 PM   #2
maskedMan
Obfuscated Coder
 
maskedMan's Avatar
 
Join Date: Apr 2008
Posts: 1,571
Default

Actionscript does not support C/C++ style pointers that I'm aware of, unless you're using Alchemy.

Of course, if you're using Alchemy, you're writing in C/C++ anyway, and not Actionscript.
__________________
http://www.scriptocalypse.com - It's not the end of the world. It's just Actionscript!

man.mask = mask_mc;
maskedMan is offline   Reply With Quote
Old 11-26-2009, 06:32 PM   #3
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

as maskedman says, no pointers in AS3. Two completely different kinds of languages.

Anways though... here is an A* algorithm I wrote in AS3:

http://code.google.com/p/lodgamebox/...arMonotonic.as

the differenty types usable with it are in the package:

http://code.google.com/p/lodgamebox/...uct/engines/ai
__________________
www.lordofduct.com - come read my blog!

If you want to know how to program, take a math class, take a lot of math classes!
lordofduct is offline   Reply With Quote
Old 11-26-2009, 08:19 PM   #4
ScottH87
Registered User
 
Join Date: Nov 2009
Posts: 25
Default

Ok so can i ask how i would go about implementing the following scenario.

I have a Class "X" and a class "Y" both seperate from each other. However at one point in some methods inside "X" i need the information held in "Y". Now we're talking about alot of data here not just a couple of ints that are needed, the whole class will be needed to either get, set or use variables.

In C++ i'd pass in a pointer to "Y" into "X" either in the constructor or another method. This means i'm only passing about a small memory address rather than a whole classes worth of data. How would I best go about this in AS3.0?
ScottH87 is offline   Reply With Quote
Old 11-26-2009, 09:00 PM   #5
bowljoman
Senior Member
 
Join Date: Jan 2008
Posts: 831
Default

think of all vars as pointers, and simply pass one class to anothers method, and parameter typed as the class.

Then you can read the vars and use methods as needed.

ActionScript Code:
a:ClassA=new ClassA(); b:ClassB=new ClassB(); b.setClassAReference(a);
__________________
i = (Andy)this;

Last edited by bowljoman; 11-26-2009 at 09:02 PM.
bowljoman is offline   Reply With Quote
Old 11-26-2009, 09:05 PM   #6
bowljoman
Senior Member
 
Join Date: Jan 2008
Posts: 831
Default

if classB has a
ActionScript Code:
var ref:ClassA;
It will only be a pointer to the same data structure in memory, unless you call 'new' and copy it to a new instance.

Only the memory address of the OBjectA will be held in the other's class member.
__________________
i = (Andy)this;
bowljoman is offline   Reply With Quote
Old 11-26-2009, 10:16 PM   #7
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall
Default

Quote:
Originally Posted by lordofduct View Post
as maskedman says, no pointers in AS3. Two completely different kinds of languages.

Anways though... here is an A* algorithm I wrote in AS3:

http://code.google.com/p/lodgamebox/...arMonotonic.as

the differenty types usable with it are in the package:

http://code.google.com/p/lodgamebox/...uct/engines/ai
This looks really cool, do you have any documentation, or plans add asdoc comments? I don't have immediate use but I've been looking for a good non-tile-based pathfinding algorithm I can integrate with my own code for a long time...
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:29 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.