JasonHippy 739 Practically a Master Poster

I know the documentation isn't particularly clear even in the Adobe livedocs, but in it's simplest terms; As far as I understand it, an URLRequest object basically just holds a link, a http:// URL.

After creating an URLRequest, to use it you need to call something like the navigateToURL function, passing in the appropriate URLRequest.

For example. Imagine we have a movieclip or sprite in our movie which we want to use as a button. When the button is clicked, we want the user to be redirected to another website.
First up we'll create an URLRequest object to hold the URL:

var link:URLRequest = new URLRequest("http://www.mysite.com");

Next, add a click handler to our button/object:

// add the handler to the button object
myButton_mc.addEventListener(MouseEvent.CLICK, onClick);

// handler code
function onClick(event:MouseEvent):void 
{
	navigateToURL(link);
}

In the handler itself, you call navigateToURL passing our URLRequest (the variable 'link' in this example!)

One thing to bear in mind, if using a movieclip as a button you might want to set the buttonMode property to true.
e.g.

myButton_mc.buttonMode = true;

And that's about it for this example!

There are other uses of URLRequest. You can also pass URLRequest objects into functions like HTMLLoader.load(), URLLoader.load(), URLStream.load(), FileReference.upload(), FileReference.download(), and many others. Obviously which of these you use will depend on exactly what you're trying to do in your project.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

You could try using SoundMixer.stopAll();

So when the user navigates to a new page, ensure that SoundMixer.stopAll() is called before the new sound is started. That should stop any sounds that are currently playing; regardless of whether they're external or in the library.

To use SoundMixer, you'll need to use the following import:

import flash.media.SoundMixer;

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

You could try swfobject.js.
This is a free and quite small javascript library (google it, you'll find it!) which can be used for embedding flash onto any web-page.

It's cross-platform and cross-browser compatible. It can dynamically determine the browser and version of the browser that viewers of your site are using and can also detect the version of flashplayer installed on their browser. It then dynamically creates object/embed tags that will work for that particular browser.

That way, no matter what browser the users of your site are using, as long as they have the correct version of the flashplayer plugin, they will always be able to view your flash files!

It just takes a few lines of javascript, but you can embed your flash files easily and cleanly. The script will generate appropriate tags to embed the flash on the fly. So if a user is viewing your site with firefox, the script will generate the appropriate object/embed tags for firefox. Likewise for IE, Opera or any of the other major browsers.

As I've said, google it, download it and use it in your web-pages. There's plenty of documentation online to tell you how to use the script.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

If you're using the built-in media-player component that ships with flash-pro IDE's, there is a property which you can set to false to stop the video from auto-playing.

I can't remember exactly what it is called, but from the flash IDE, if you select your instance of the media player component on the stage and then open the component inspector window (or was it the properties window?? Been a while since I used the flash IDE now!) Either way, somewhere in the properties or the component inspector, you should see the auto-play property. I think it's set to true by default.
Set this to false and that should be all you need to do to stop the video from auto-playing.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Well if you're using Flash 8, there are lots of tutorials and examples that ship with flash (open up the IDE and check out the help menu and the help system).

I can't remember the path to the actual files for the examples that ship with flash 8 (all of my Windows machines are dead..I'm currently running *nix, so I can't check either!) but the paths should be documented in the help. Try a few of the examples and tutorials. From what I remember the tutorials and examples range from absolute beginner to advanced...You'll soon pick things up!

Also google for actionscript 2 tutorials, there are thousands of tutorials out there on the web. There are also lots of books available for AS2 / flash 8. As flash 8 is so old, 2nd hand copies of the books should be available for relatively low prices.

There is also the official actionscript 2 online reference hosted on the Adobe livedocs website which documents every aspect of Actionscript 2.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

So toggleButton is also the equaliser animation?

If that is the case, then perhaps you could do something like this in your startSong function:

function startSong(){ 
	songChannel = song.play();
	songChannel.addEventListener(Event.SOUND_COMPLETE, songCompleteHandler);
	toggleButton.addEventListenter(Event.ENTER_FRAME, animateToggleButton);
}

You should also remove the ENTER_FRAME event handler in your stopSong function.

The animateToggleButton function, or whatever you decide to call it should then contain whatever code is necessary to animate the button.

This function will be then be called every frame while the song is playing.

Not sure if that's what you're after.

Alternatively, you could perhaps make the animation code a part of the toggleButton class. So if you want the animation to be done on a per frame basis using the ENTER_FRAME event, you could create a private event handler function in the toggleButton's class declaration to deal with the ENTER_FRAME event (I'll call it doAnimation, but you can call it whatever you like!) and then you just create two public functions in the class called something like startAnimation and stopAnimation. The functions should do something like this:

private function doAnimation(e:Event):void
{
 	// TODO: Your frame based animation code here
}

public function startAnimation():void
{
 	this.addEventListener(Event.ENTER_FRAME, doAnimation);
}

public function stopAnimation():void
{
	this.removeEventListener(Event.ENTER_FRAME, doAnimation);
}

That way from your startSong you can do this:

function startSong(){ 
	songChannel = song.play();
	songChannel.addEventListener(Event.SOUND_COMPLETE, songCompleteHandler);
	toggleButton.startAnimation();
}

Likewise in stopSong you can call toggleButton.stopAnimation(); to stop the animation.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Have you tried this?? heh heh! :)

But seriously, you haven't given us much to go on. Which version of flash/actionscript do you want to learn?
Are you going to be using one of the official Adobe/Macromedia Flash IDE's? If so, which one?
If not, do you plan to use AS3/MXML with the free Adobe Flex SDK? Or are you planning on using some other 3rd party flash development software? (e.g. FlashDevelop, MiniBuilder, Swishmax etc.)

Also are you running Windows, Mac or *nix?

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

This should be pretty self-explanatory. Here's your code again, I've commented out a line of code which should stop your sound from auto-playing:

var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0; 
var soundIsPlaying:Boolean = true;
mySound.load(new URLRequest("Intro1.mp3"));

//Line below not needed:
//myChannel = mySound.play();
// after removing this, the sound will not play until the 
// play button has been clicked.
offBtn.addEventListener(MouseEvent.CLICK, onClickStop);
function onClickStop(e:MouseEvent):void{
myChannel.stop();
soundIsPlaying = false;
} 
offBtn.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void{
lastPosition = myChannel.position;
myChannel.stop();
soundIsPlaying = false;
}
onBtn.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void{
if(!soundIsPlaying){
myChannel = mySound.play(lastPosition);
soundIsPlaying = true;
}
}

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

0101011101100101011011000110110000100000011010010111010000100000
0111011101100001011100110010000001110011011011110110110101100101
0110001001101111011001000111100100100000011001010110110001110011
0110010100100000011101110110100001101111001000000111001001100101
0111001101110101011100100111001001100101011000110111010001100101
0110010000100000011101000110100001100101001000000111010001101000
0111001001100101011000010110010000101100001000000110001001110101
0111010000100000011000010111001100100000011010010111010000100111
0111001100100000011000010010000001100111011000010110110101100101
0010000001001001001000000110010001101111011011100010011101110100
0010000001110011011001010110010100100000011000010110111001111001
0010000001101000011000010111001001101101001000000110100101101110
0010000001100011011011110110111001110100011010010110111001110101
01101001011011100110011100100000011010010111010000100001

Bonus: Octal and hexadecimal subtitles for the binarily impaired! ;)
535453306604032272040
735413462016333666545
611573107444031266163
624403566415710071145
715653447114530672145
620403506414510072150
711453026205410061165
720403027144032272047
714403022014730266545
201111006215733423564
201633126244030267171
201503027115510064556
201433366716432267165
1513346344032272041

57656C6C20697420
77617320736F6D65
626F647920656C73
652077686F207265
7375727265637465
6420746865207468
726561642C206275
7420617320697427
7320612067616D65
204920646F6E2774
2073656520616E79
206861726D20696E
20636F6E74696E75
696E6720697421

JasonHippy 739 Practically a Master Poster

Hello, our company currently has a web based program using Adobe Flash to present flash images. We also have tools that allow a user to draw and zoom in on those images. The problem is the tools are not very robust. We need to rebuild/revamp it but don't really know where to start.

Does anyone have any suggestion on what enviornment to build the program in?
Does anyone know of any out there know of anyone that is competent enough to do such a job?

Well I guess as the existing tool is flash-based, then one of the Flash IDE's would probably be the best environment. Or you could use something like FlashDevelop and the Flex 3 SDK (or just the FlexSDK on it's own) and do the whole thing in AS3 code or MXML/AS3.

Alternatively if you wanted it to be a web-enabled desktop app, you could target the Adobe AIR runtime.

But these options would only apply if you wanted to keep the project flash based. Alternatively, I suppose you might be able to create an app or website using .NET with C# or VB.NET to provide the functionality you require. There is also the MS Silverlight platform/runtime. Never used Silverlight myself, but that could be an option!

As Iamthwee has already said; whatever you want to do, it would involve quite a bit of work, depending on how complicated you wanted to make the project.

As for who, you could always advertise …

JasonHippy 739 Practically a Master Poster

Hmmm, sounds very odd....I'm stumped!

What about your local version of the website? i.e. the version you have on your PC from when you were editing/developing the site..
Does that function properly? Do all of the links work as expected?

If not, then it is almost certainly some problem with your HTML code. In which case you need to take another look at your code. Perhaps there are some links that you needed to update or something else which you missed.
But if your local version does work properly, I think I'm out of ideas!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Personally I'd say you're on the right track with the cue-points.
You said you've put a cue point into the flv.

All you need to do now is add an event listener to your flv playback component to listen for cue-point events and a handler function to be called when a cue-point is detected by the listener.

The event handler should examine the cue-point event to determine which cue-point has been detected (if you have more than one) and then fire off another function to do whatever you need your main clip to do. (in your case making a button visible!)

It's been a while since I did anything with flash video and cue-points, so I'm a bit rusty. I haven't got time to put an example together right now either, but here are some links to a couple of tutorials you could check out:
http://www.flepstudio.org/forum/tutorials/427-cue-points-flash-cs3.html
http://www.quip.net/blog/2007/flash/how-to-use-flash-video-cue-points

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hi ajijacobm,

You can call the xml loading method using a timer. Call the function frequently within 5 seconds to 10 seconds. It will update you the code always.

Good point Raja,
My suggestion only applies if the swf modifies the xml. If you know that the swf has updated the xml, then you can reload the xml there and then. But if the xml file is updated externally (by something other than the swf) then using a timer to reload the xml would be a good option!

JasonHippy 739 Practically a Master Poster

How to get full screen in flash.(fs command)

Have you got any more info??
What exactly are you trying to do?
What version of flash/actionscript are you using?

To make a .swf fullscreen in AS3 you can do this:

stage.displayState = StageDisplayState.FULL_SCREEN;

and to go back to the normal windowed mode you can use:

stage.displayState = StageDisplayState.NORMAL;

NOTE: In order to use StageDisplayState in your AS3, you'll need to make sure you import flash.display.StageDisplayState.

Not sure if that's any help to you, but you haven't exactly given us a lot to go on!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

umm....This may sound a bit obvious, but have you tried clearing your browsers cache/history?

If the new versions of the HTML files have been uploaded to the server, then it's pretty certain that your changes to the site have actually been made.

Which means it's most likely that your browser has cached an older version of the site, so when you go back to the site, it's the cached version that you're seeing. So when you click on the contact link it's taking you to the cached contact page rather than loading the newer version.

Try clearing your browser cache/history and then go to the site again and see what that does.

I just took a quick look at the site and clicking on the contact link from the main page takes me to a page called talk_to_tft.html. Is that the page you are expecting to see?

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

In that case, once the you know that the xml has been updated, perhaps you should reload and reparse the xml file.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hmm, I'd have to echo what Nick and Clutchkiller said.
The express version of Visual C++ 2008 or Code::Blocks with mingw are the best free C++ IDE's/compilers for windows.

But I'd steer clear of Dev-C++ as it is no longer being developed or maintained. Better to stick with something more up to date IMHO!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Well, bearing in mind that you've posted in a Linux forum rather than a Windows forum, the question really is; what do you want to do after you've reformatted you hard drive??

Do you want to put Windows back on there or are you thinking of switching to Linux?

If you're thinking of switching to Linux, the best bet would just be to try a few different Linux distributions beforehand. Ubuntu, Mint and Fedora would probably be best for a Linux newbie.

All you do is go to the distro's website and download the .iso image for their LiveCD, burn the image to a CD and reboot your PC with the CD in the CD/DVD drive.

Try a few different LiveCDS. Once you've found a distro you like, reboot the computer with your chosen LiveCD in the CD/DVD drive and select the option to install it to the hard drive.

Many Linux distros nowadays have a guided installer, which makes things just as easy as installing windows! The Linux installer can automatically partition and reformat the hard-drive before installing the Linux OS, but there is also the option to set the partitions up manually. Like I said, if you're a newb, you can just leave it to the installer to sort all of that out for you!

If on the other hand you want to reinstall Windows after reformatting (in which case, you posted in the wrong forum!), you could try contacting whoever built/sold …

JasonHippy 739 Practically a Master Poster

Unless you happen to have access to the original source code for Half-life or Tomb Raider, then you have no hope of being able to port them over to run natively on Linux. But there is nothing to stop you from creating your own Half-life or Tomb Raider clone using an open source game engine. Obviously, because of copyright you wouldn't be able to call them Half-Life or Tomb-Raider. Perhaps you could call them No-Life and Sarcophagus-Snatcher heh heh! :) But that would be a pretty massive undertaking.

Personally I think the best bet would be to simply try running your old windows games with Wine. You may have varying degrees of success with this. Some windows games/programs will work fine in wine, others will need a bit of messing with, or will be unstable. And then there are those that just flat out won't work at all. So it's a bit of a lottery there!

I think the winehq website lists a lot of windows games and programs that work with wine as well as how well they run and any configuration changes that need to be made to get them to run.

Another option might be to install the games on a virtual windows machine using something like VMWare (so you're running a virtualised windows pc from within Linux). But unless you've got a pretty powerful PC, I can't imagine many games running particularly well with this option.

Dual booting your pc would also …

JasonHippy 739 Practically a Master Poster

01001010 01110101 01110011 01110100 00100000 01100001 00100000 01110100
01101000 01101111 01110101 01100111 01101000 01110100 00101100 00100000
01110111 01101111 01110101 01101100 01100100 00100000 01101001 01110100
00100000 01100010 01100101 00100000 01110111 01101001 01110011 01100101
00100000 01110100 01101111 00100000 01110000 01101111 01110011 01110100
00100000 01101111 01100011 01110100 01100001 01101100 00100000 01101111
01110010 00100000 01101000 01100101 01111000 00100000 01110100 01110010
01100001 01101110 01110011 01101100 01100001 01110100 01101001 01101111
01101110 01110011 00100000 01100110 01101111 01110010 00100000 01110100
01101000 01101111 01110011 01100101 00100000 01110111 01101000 01101111
00100000 01100100 01101111 01101110 00100111 01110100 00100000 01110011
01110000 01100101 01100001 01101011 00100000 01100010 01101001 01101110
01100001 01110010 01111001 00111111 00100000 00001101 00001010 01001010
01110101 01110011 01110100 00100000 01110100 01101000 01101001 01101110
01101011 01101001 01101110 01100111 00100000 01100001 01100010 01101111
01110101 01110100 00100000 01100001 01100011 01100011 01100101 01110011
01110011 01101001 01100010 01101001 01101100 01101001 01110100 01111001
00100001 00100000 01101000 01100101 01101000 00100000 01101000 01100101
01101000 00100000 00111011 00101001 00100000

JasonHippy 739 Practically a Master Poster

{Slaps forehead} Doh! Just thought of another thing...
There's no need for the copy of the string if we're using iterators.
We can do this instead:

bool Pstring::isPalindrome()
{
    string::iterator front, back;
    for(front = this->begin(), back = this->end()-1; front<=back; front++, back--)
    {
        if(*front != *back)
            return false;
    }
    return true;
}

J.

JasonHippy 739 Practically a Master Poster

From what I can see the function in question takes a pointer to a cNPC object, not a pointer to an array of cNPC objects.

Would it make more sense to store your cNPC objects in something like a std::vector instead of an array?
e.g. std::vector<cNPC>

That way you can alter your functions signature to pass the vector into your functions as a reference or a const reference instead of using a pointer to an array. It's just as efficient as using a pointer. It's probably also safer and less prone to bugs/errors than using a pointer to an array too!

Saying that, if you don't want to use the std::library, there's nothing stopping you from passing your array into your function as a reference or a const reference either.

Offhand, those are two options that I can see! But I'm sure there are many other ways around this problem!

Cheers for now,
Jas.

{edit: BTW, if I am way off the mark here I apologise. It is past 3am here, so tiredness is kicking in with a vengeance, I may have misread something..Think I'm gonna have to crash soon though. I've got work in a few hours...Doh! }

JasonHippy 739 Practically a Master Poster

Alternatively, you could use two std::string::iterators to iterate through the string comparing values like so:

bool Pstring::isPalindrome()
{
    // create a local string (using the std::string.c_str() function to retrieve the word stored in the base class)
    string testWord(this->c_str());

    string::iterator front, back;
    for(front = testWord.begin(), back = testWord.end()-1; front<=back; front++, back--)
    {
        if(*front != *back)
            return false;
    }
    return true;
}

Again, we're initialising back to testWord.end()-1 to avoid the null at the end of the string.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

You need to be doing something like this in the constructor:

Pstring::Pstring(string word): string(word)
{
	if (isPalindrome() ) 
		cout << "the word is a palindrome";
	 else
		cout << "the word is not a palindrome";
}

The ": string(word)" I added to the constructor will initialise the std::string part of Pstring with the passed in std::string (aka word).
Also you only need to call isPalindrome() once, not twice! And you don't need the static std::string in your constructor either.

Next up, in your isPalindrome function, you can retrieve the string from the base class (the std::string part) of your Pstring by using the c_str() function, which returns a c style string. If you use the c style string to create a tempory local std::string in your function, you can then use your two indexes (i and j) to index the string. No need to use two strings here! Simply set i to index the start of the string and j to index the end and compare the two values before incrementing i, decrementing j and reiterating through the loop.

Like so:

bool Pstring::isPalindrome()
{
	int i,j;
    
    // create a local string (using the std::string.c_str() function to retrieve the word stored in the base class part of Pstring) 
	string testWord(this->c_str());
	for (i = 0, j = testWord.size()-1; i <= j; i++, j--) {
		if (testWord[i] != testWord[j]) {
			return false;
		}
	}
	return true;
}

Note, the index j is initialised to testWord.size()-1 to take the \0 …

JasonHippy 739 Practically a Master Poster

For now, I'd say take a look at my example and have a go at it to see how you get on. Afterwards, if you decide you want to stick with the boost library, then by all means try learning as much as you can about it. I'm still learning boost myself. I've only done a few odd bits with boost::bind, boost::serialization and boost::archive, but not a lot else so far!

Some of the boost code in my example may initially look quite esoteric, but not all of it is that difficult to understand. Some of the boost classes I've used in my example (e.g. the boost::filesystem::fstream class) are just specialized, extended or derived versions of their std::library equivalents (in this case std::fstream!).

Boost can be a bit of a daunting beast. I must admit whenever I try something new with it, it usually takes some time to get my head around it. I've always found a lot of the boost documentation to be either incorrect, incomplete or incomprehensible, so it often takes a bit of digging and experimenting to get things working properly. But it is worth the time and effort IMHO because the classes in the boost library are quite powerful, not to mention rather robust and they can save you both time and unnecessary lines of code when developing your own applications (at least they can once you've invested some time to learn about some of the boost classes and how they can be used!).

JasonHippy 739 Practically a Master Poster

Here is my advice:
You've come up with an algorithm, so now try translating that to code yourself. Come back here and make another post if you hit any problems with your code.

If you do have any problems, remember to be as clear as you can about the nature of the problem and post the code segment that is giving you the problem. Oh and don't forget to use code tags to enclose your code in your post!

As things stand, I think that's about the best advice you're going to get here.

BTW: Did you even search the forum for threads relating to prime factorization before making your post? If you had done, you almost certainly would have found something that you could use to make a start on your own coded solution. I hardly think you're the first person ever to come to this site with problems relating to prime factorization!

JasonHippy 739 Practically a Master Poster

I've not used tinyXML++, but I endured the terrible tutorial in Ancient Dragons link a while ago.
I was looking at it a few months ago and had a bit of a mini nightmare with it! Whoever wrote that piece posted some badly untested code. I couldn't get it to compile on any compiler on any of my machines.
Fortunately a little bit of digging allowed me to work out and solve the problems with it.

To save others from having to suffer what I did, here's something I came up with. It's based loosely around the tutorial/documentation in AD's link. The only difference is, this actually does compile and work!

BTW: I aught to make it clear here, I'm not having a go at AD in this post; but rather the poor quality of the article in the link, which is the original authors fault, not AD's! ;)

I created this example in VS2003 when I was originally trying to get my head around the boost vs XML thing. Apologies if there are any minor non-portable bits of code in there. Most, if not all of it should be pretty standard! It should certainly work with any recent version of Visual studio. I managed to get it working in VS2008 with no modifications to the code.

gcc and any other up to date, standards-compliant compilers should also be able to compile it without error (but I've not tested it with anything other than …

Ancient Dragon commented: Nice -- thanks for not blaiming me for the code in that link :) +26
JasonHippy 739 Practically a Master Poster

What about the fuzzy selection tool, which creates a selection from a colour? Its the tool that looks a bit like a magic wand.
Click on the fuzzy select tool, then click on the logo's background area and then tweak the tolerance for the colour (in the fuzzy select tools properties) until the required area becomes selected and then fill that area with solid black (or whatever your dark colour is!) That may well solve your problem.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

I have an old RM Tablet PC (which uses a Wacom tablet/screen) at home which is currently running Ubuntu 9.04 on it with no problems.
The stylus works fine for the usual mouse-like activities (e.g. navigating the file-system and for drawing in gimp, blender and Inkscape etc.)

Regarding handwriting to text:
I know there are a few on-screen keyboards that work with the tablet/stylus in linux, but I don't know offhand if any of them support converting handwriting to text. I use a mini-usb keyboard with my tablet for text input, so I've not used any of the on-screen keyboards yet. But it might be worth trying a few of them and having a play just in case they do have input panels for converting handwriting to text. I've got a sneaky suspicion that at least one of them does.

If you can find an on-screen keyboard that supports handwriting to text, that would probably solve your problem! Try taking a look in the repositories or perhaps do a quick google to see if there are any other open source on-screen keyboards for linux that perhaps aren't in any of the major distros repositories.

There's quite a lot of open source linux software out there that doesn't get into the main repositories of the major distros. The only minor downside to this of course is that you'd probably have to build the software from source (which could prove to be a pain if it has …

JasonHippy 739 Practically a Master Poster

I think the reason the OP wanted to install IronPython was probably to have an IDE for python.
Obviously, as already stated IronPython is only for windows, so that is out of the question.

However there are several other python IDE's available. Idle and SPE (Stani's Python Editor) immediately spring to mind. I can't think of any others offhand but take a look in the software centre and you should see a few other python IDE's, if memory serves.

Most of the time I just use gEdit for writing my py scripts, as it has python syntax highlighting built in, but whenever I need an IDE (usually when debugging errant scripts), I tend to use Idle...Works for me, never had any problems with it.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hey Tom!

You said that this portion of code was causing the runtime error:

void CEntityController::SpawnEntities( )
{
	for( int i = 0; i < m_vEntities.size( ); ++i )
		m_vEntities[i]->Spawn( );
}

Bearing that in mind, have you tried using an iterator to dereference the vector, or perhaps even using .at() which is more type-safe than dereferencing the vector directly??
Might be worth a try, .at() should throw an exception if there's a problem with one of the items that you're dereferencing. That might shed some light on the problem.

You've also said that the CEntity::Spawn method doesn't do anything ATM, so we know that's not the problem. Plus CEntity::Spawn is not listed in the call stack, so we can definitely rule that out.

Which leaves the vector and the items it contains (Pointers to CEntity objects wasn't it?). I suspect it's most likely that one or more of the objects/pointers in the vector have not been initialised correctly.

I also noticed that the CEntityController::Start function is listed further up the stack-trace... Is there any chance that there is something going awry somewhere in the Start function which could be causing the problems you're seeing in the SpawnEntities function? It could even be something that gets set-up before the start function is called and that the start function is merely triggering the bug.

I'd say take a look at any code which deals with the vector of entities, starting with the very first …

JasonHippy 739 Practically a Master Poster

Aha, got it!

As mentioned previously, you'll need to create an xml file called maude.lang and put it in the following location:
/usr/share/gtksourceview-2.0/language-specs/

If you take a look at the other .lang files already there, you can get a feel for how they work, ready for when you create your own.

You also need to set up a mime-type .xml file called maude.xml and save it to the following location:
/usr/share/mime/packages/

Again, take a look at a few of the existing ones to see how they're laid out and create yours to follow a similar fashion.

The final step is to rebuild your mime-type database. To do this open up a command-line and type the following command:
sudo update-mime-database /usr/share/mime
(obviously the sudo part only applies if you're using a debian/ubuntu derived distro, you might need to substitute that for su. or whatever else you use in order to run as root!)

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Perhaps put a request in to the gEdit developers for a maude highlight plugin?

Otherwise, you could make your own, which will involve creating an xml file describing the various rules of the language in /usr/share/gtksourceview-2.0/language-specs/ calling it maude.lang (take a look at a few of the other .lang files in that directory if you want to know how the xml should be structured). You also have to set up a new mime-type (another .xml file) for the .maude files and update your mime types database. which will allow gEdit to automatically highlight your .maude files according to the rules set out in maude.lang.

Anyway, offhand I can't remember where you have to put the xml file for the new mime type, or the command-line commands required to rebuild the mime-type database.

I had to manually set up Actionscript highlighting for gEdit on one of my linux boxes at home, so I've made some notes on how to do it. But I don't have it in front of me, so I'm operating purely from memory ATM. But if I get a chance tonight, I'll try firing up one of my Linux boxes and have a gander and repost with more info.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Found a youtube version - thanks, never heard of them. Almost Gregorian - nope, it is Gregorian, wow!

Glad you liked it.
There's also War Pigs (or Verres Militares) and Planet Caravan (Planetarum Vagatio) on youtube too.

The rest of the tracks on the album are equally amazing.
If you can get hold of a copy of the CD, it's well worth it IMHO!

Another recent(ish) Sabbath tribute I quite liked was the Venetian Snares "Sabbath Dubs" e.p. (2 tracks, Black Sabbath and Electric Funeral done in a really heavy dub stylee....Nice!)

JasonHippy 739 Practically a Master Poster

Jonsca PM'ed me and brought something to my attention that raises a very good point regarding this thread.

We've both recommended that the OP uses 'new' to create a new instance of the complex class in the operator+, but this would actually cause a memory leak as the memory allocated by new never gets deleted.

After a few messages back and forth, I came up with this solution which should completely avoid a memory leak.... I think!

#include<iostream>

class complex 
{
	float x;
	float y;
	public:
	   complex(){}
	   complex(float real,float imag)
	   {
   		x= real,y=imag;
   	}
  complex operator+(const complex)const;
   	   void display(void);
};
 complex complex::operator+(const complex c)const
 {
	complex temp(*this);
	temp.x+=c.x;
	temp.y+=c.y;
 	 return(temp);
 }
 void complex::display(void)
 {
	 std::cout<<x<<"+j"<<y<<"\n";
 }
 int main()
 {
 	complex c1,c2,c3;
 	c1=complex(2.5f,3.5f);
 	c2=complex(1.6f,2.7f);

 	c3=c2+c1;
	std::cout<<"c1=";c1.display();
	std::cout<<"c2=";c2.display();
	std::cout<<"c3=";c3.display();
 	return 0;
 }

So the major changes there are in the operator+. Instead of returning a pointer or a reference to a complex object, I've changed the signature to return a complex object by value. For the sake of const correctness I've also made the function and the parameter to the function const.

In the operator+ function, instead of creating a pointer to a new complex object, I'm using a temporary local complex object created using the this pointer. Effectively, that makes temp a copy of the left hand operand in the addition operation. We then add the passed in object (the right hand operand in the addition) to temp and return temp by value, so a copy of …

JasonHippy 739 Practically a Master Poster

The unmistakable sound of tinnitus...Yet again! Will I ever learn not to remove my ear-plugs at rehearsal??!

Currently trying to drown out the insanity-inducing high pitched noise with a bit of Rondellus - "Sabbatum". An estonian folk band doing an album of Black Sabbath covers using medieval instruments with the song titles and lyrics translated into latin...The description sounds really odd, but it really works! It's a bit wierd, but very chilled out! Some unusual, but great choices of songs on there too!! Not your typical Sabbath tribute!

JasonHippy 739 Practically a Master Poster

You have a missing semicolon ; at the end of line 2.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

iam unable to get the appropriate out put for this code.I think the problem is with the operator overloading.Could any one come up with solution??

The main problem I can see is in your operator overload at line 17. The pointer 'temp' is uninitialised, it doesn't point to anything.
You need to use:

complex *temp = new complex();

Which creates a new instance of the complex class and assigns the pointer to point to it. Now your calculation should work.

I also noticed that you're not qualifying the std::namespace for cout. I'm not sure whether or not your compiler needs the qualification, I'm assuming your one of those unfortunate students who've been forced by your institution to use an old borland compiler. It's been donkeys years since I used any of Borlands old compilers, so I really can't remember. But on the off-chance that it does, it might be an idea to put the following line of code underneath the #include:

using std::cout;

(Obviously if you aren't getting error messages about it, your compiler doesn't need it so don't bother!)

Looking at your code, you might also get some warnings about truncation from double to float at lines 29 and 30. (Again, if you're using an old Borland compiler you might not get the warnings. My memory doesn't stretch back that far!)
On the offchance that you are getting warnings, you can get rid of them by doing this:

c1 = complex(2.5f, 3.5f); …
jonsca commented: Above and beyond +2
JasonHippy 739 Practically a Master Poster

I have c++ functions in which all the arguments are integers....I was wondering if there was a way of telling the computer this, other than typing int before each and every variable....I tried
function S(int a, b,c..)
but did not work....

Short answer...No, you can't. You have to specify a type for every parameter passed into a function, even if there are more than one of the same type.

Inside a function body, you can define local variables of the same type like so:

int main()
{
    int a, b, c, d, e;
    // Some code here........
}

But for function declarations and definitions, you have to specify the type for each parameter:

void myFunc(int a, int b, int c, int d, int e);

Hope that clears things up for you.
Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

It may make sense to make use of your debugger to try to find the problem here.

Try running a debug build from your IDE. When the seg-fault occurs you should be given the opportunity to break out of the program and you'll be shown the line of code that causes the seg fault.

If it's a line of your own code that's highlighted, then you should be able to trace the problem back fairly easily. If it highlights any other code (lower level system code or std library code, or STL code etc) then you just need to take a look up the call-stack until you see something that you recognise from your code. Clicking on that part of the call stack should bring up the line of your code that is causing the seg fault further down the stack.

Once you've located the offending line of code, you should find it easier to diagnose the problem.

If that still doesn't help, it may be worth setting some breakpoints in your code near to the point in your code where the segfault occurs.
That way you can break out and step through your code whilst keeping an eye on the values in any relevant variables.
Keep stepping through the code and watching the variables until the seg-fault occurs. As long as you're watching the right things, the cause of the seg-fault should become more or less apparent.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Thanks for the help guys. Jason, I will consider saving my code in CS3 next time so you can get a chance to look at it LOL.

Heh heh, bit of a moot point now...Looks like our one and only Windows (XP pro) machine at home has finally given up the ghost and died...I spent many hours last night trying to ressurect the damn thing, but to no avail. Part of the problem appears to be with Windows, a few files used during boot/windows startup have corrupted, looks like one or more of the device drivers have gone a bit wonky. It also looks as though the hard drive has almost completely packed up too (old age!). There are no viruses or malware on there, so no foul play is suspected. I think the corruption is due to the HD's old age.

I managed to get most of our important docs off of it, but as the PC is really old, I'm thinking of perhaps putting a new drive in and slapping linux on there, I've had enough of Windows and the constant need for updates, patches and workarounds!
It noticeably slowed down after service pack 2 was installed on it, and after service pack 3 it was even worse. So I think linux will run a lot better on the tired old thing. We'll be able to get things done a lot faster on it without windows!

So it looks like I'm gonna be doing all …

JasonHippy 739 Practically a Master Poster

I'm afraid I'm out of this one...Looks as though your file was made with CS4 which I don't have! I've got a .swf decompiler on my work pc that should allow me to decompile it to a flash CS3 compatible .fla or pure AS3/flex. I'll have a go at that tomorrow morning, unless raja posts something in the meantime!

Cheers for now,
Jas.

iamthwee commented: Next time I'll compile it for AS3... +11
JasonHippy 739 Practically a Master Poster

Aha, This looks like the sort of thing I was expecting:

mc.transform.matrix = new Matrix(1, 0, 0, 1, -regx, -regy);

That should allow you to set the registration point of a movie clip. At least according a poster at the page on the following URL:
http://www.kirupa.com/forum/showthread.php?t=245159

Not tried it out yet. Will get back to you when I have!

Cheers for now.
Jas.

JasonHippy 739 Practically a Master Poster

Hmm, this is something that's stumped me recently too.
I've been messing around with importing Inkscape .svg's into AS3, but the registration point of the .svg's are always at 0,0 (top left), whereas I usually want the registration point to be at the centre of the graphic.

For now, I've resorted to shifting everything in my .svgs so that the centre of the image is at the top left of the canvas. Which works ok for .svg images, but that won't work for .jpg or any other bitmap/raster images.

Not sure if there's a way of setting a transform or something......I don't know. The Flash IDE's allow you to set the registration point for any type of object and most of the stuff available in the Flash IDE is also accessible via actionscript, so I would imagine there must be a way of doing it, but I gotta say I'm still searching for it!

As ever, if I come up with anything I'll post it here!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

The entire OO package isn't installed in the standard Ubuntu LiveCD installation. It's missing openoffice.org-base and maybe one or two other bits. Also openoffice formula is hidden in the main menu, but you just have to make the shortcut to it visible in the menus if you want to access it directly.

Assuming you're using still using GNOME as the desktop manager try going to system->preferences->main menu.
In the window that opens up, select the "Office" icon from the list of menus, then in the main pane you'll see several icons, including one for openoffice.org formula which is deselected.
Select that sucker and hit ok and you've got formula available from the main menu.

That takes care of formula, to get base installed, you can either do it through the command line:
sudo apt-get install openoffice.org-base

or by using the graphical package manager, or the add/remove programs (or Ubuntu software centre if you're using 9.10).

I think there's also a meta-package that installs all of openoffice.org, you'll probably see it if you go via add/remove programs (or the Ubuntu software centre for 9.10). I think it's listed as "OpenOffice.org Office Suite" in 9.10, probably called something similar for earlier versions of Ubuntu too.

If you install the meta-package, it should just download and install any missing OO.org packages (like base). It shouldn't affect any of the already installed OO.org packages.

After …

JasonHippy 739 Practically a Master Poster

Ooops, good point Dave. Nicely done!

I should've been using unsigned ints in my code too. I completely forgot to take the sign into consideration. The rotate functions in the OP's code won't work with negative numbers! {kicking self!}

I toyed with the idea of doing something like your UINT_BITS definition to get the actual system size, but admittedly I would've ended up doing it for int... Tut! I should've thought it through! However, I decided to run with the hard-coded 32 that the OP posted in their code.

Anyways, hats off to the Davester!

Jas.

JasonHippy 739 Practically a Master Poster

456 is certainly far too big for n. n should be somewhere between 1 and 31 (shifting x by 32 places in either direction will give you x!)

This is the statement you were referring to, just to clarify things here I should really have written:

456 is certainly far too big for n. n should be somewhere between 1 and 31 (shifting x by 32 places using rotateleft or rotateright will give you x!)

[edit] But as there is rotation going on, I guess that entire statement is actually pretty redundant!

JasonHippy 739 Practically a Master Poster

But if you take another look at the code that is being used in the rotateleft and rotateright functions in the OP, it's not just a straight shift, there actually is some rotation going on. (or at least something equally as cunning!)

There are two operations in the rotateleft and rotateright functions. The first operation is a straightforward shift of x by n places in the relevant direction, but the result of the first operation is OR'ed with the result of the second operation. The second operation shifts x by 32-n places in the opposite direction.

Try running my code and vary the values a little and you'll see.
Perhaps keep x as 4 (or something easily predictable) and try varying the value of n.
In fact if you set n to 32, you'll find that the result of shifting x by 32 places in either direction (using rotateleft or rotateright) results in the value of x staying the same.


[EDIT] In fact, because it actually does rotate, try n as 64, 96, 128 or any other multiple of 32 and the result will be x.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Basically, he's talking about passing an .xml file from python to a flash application.

The OP could take a look at this link:
http://www.swaroopch.com/blog/big-brother/

Here, the author has created a python script to monitor a users pc usage, logging the details of time spent in different applications and writing the details out to a text file.
He's then created a flash file (using flex) to read the text file and output a graph of the users time spent in different applications.

And that's about as simple as you can get. Run the python script to generate a text file and then use the flash file to open the text file and read the data from it. (Or in the OP's case an xml file rather than a text file)

In fact I've done something vaguely similar, I created a flash based clock application to sit on my active desktop which counts down how long I have left until I can go home. Each morning when I first start up my work pc, a C++ program I wrote is fired up which asks me what time I clocked in. Optionally I can let it know how many hours I want to work that day, otherwise it defaults to my standard contractually obliged amount (8 hours and 18 minutes including lunch, I'm on flexi-time, so that's how many hours I have to average per day).

The C++ program then creates an xml file which …

JasonHippy 739 Practically a Master Poster

The macro functions rotateleft and rotateright perform binary shift operations, shifting the binary value of x by n places in the appropriate direction using the << and >> binary shift operators.

So using some smaller, more sensible values for x and n (e.g. x=4 n=2);
if we now did something like:

x= rotateleft(x,n);

Using my example values for x and n, we know that x==4.
In binary 4 is represented as:
100

if we shift the binary value of x (4), n places to the left (n==2 remember), we get this..
10000
Which is the binary representation of the number 16.

So the value of x would become 16.

To get the original value of x back, you need to call rotateright passing x and n, which will output the value that results from shifting x (16) to the right by n (2) places.
So we'd call this:

x = rotateright(x,n);

This time the value of x is 16. n is still 2.
16 in binary is:
10000

shifting 2 places to the right gives you the binary value:
100

Which is the number 4 (the original value of x!)

Just in case you're not 100% clear, have a butchers at this simple example:

#include <iostream>
#include <string>

#define rotateleft(x,n) ((x<<n) | (x>>(32-n)))   
#define rotateright(x,n) ((x>>n) | (x<<(32-n)))

using std::cout;
using std::endl;

void output(const std::string &message, const int &x, const int …