JasonHippy 739 Practically a Master Poster

From what I can see it looks like it's because you are calling newName.ShowModal() twice in your code.
In the first call to DoModal in your if statement, a dialog is created and if the user presses ok and has entered some text the dialog is destroyed and your while loop breaks out.
If the user presses ok after entering no text, the dialog is destroyed, your while loop reiterates and the first call to ShowModal is called again. OK so far, I assume this is the behaviour you want.

But if the user closes the initial text box with cancel, your code drops to the elif statement where DoModal is called a second time, creating a 2nd dialog.. In the 2nd call, whether the dialog returns via ok or cancel it will be destroyed.
So it is the call to DoModal in the elif that is the problem!

What you need to do is alter your code so that you're making one call to DoModal and then see what value was returned..
So I'm guessing you'd need to do something like this:

def OnNewButton(self,event):
        error=1
        while error==1:
            newName = wx.TextEntryDialog(self, 'Question?:','Title')
            newName.SetValue("")
            retVal = newName.ShowModal()
            if retVal == wx.ID_OK:
                if len(newName.GetValue().strip())!=0:
                    error=0
                    self.Destroy()
            elif retval == wx.ID_CANCEL:
                error=0
            newName.Destroy()

Hope that solves your problem!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster


I personally feel that for you the best way to return your doubles is with a struct.

I second that motion!
That would be preferable to the method I put forward.

I just wasn't sure how familiar the OP was with structs, pointers and arrays. So I went with the simplest example passing each value separately....

Although looking my post now, why I posted the entire body of the function instead of just posting a more compact example is beyond me! heh heh ;)

Good solution Sky!

JasonHippy 739 Practically a Master Poster

As the other guys have suggested, there are several ways around the problem.
The error you're getting is because your F_Ite() function does not return a value.

A function can only return one value, the only way of returning several values would be to either create all of the variables you want returned outside of your function and pass them into your function as pointers or references, or pass them as an array of pointers.
You could then change the return type of the function to void as the function will manipulate the contents of the pointers, so it won't need to return anything.

Or you could get your function to return an array of pointers.

I'm not sure how au-fait you are with the idea of pointers and arrays, so for now I'll go with the idea of creating the values outside of the function and passing them individually as pointers.
Here's what the code would look like:

#include<iostream>
#include<cmath>

// pass values into your function
void F_Ite(double *a, double *b, double *c, double *d, double *Fc, double *Fd)
{ //Main Function Start
	// you could initialise your variables here, or outside of the function.
	// I've gone for the latter, but whatever floats your boat!

	for(int k=1;k<(NI-1);k++)
	{ //Main 'for' Loop Start
		std::cout <<"\n";
		system("pause");
		std::cout <<"\n";
		std::cout <<"At The "<<k+1<<" Iteration :\n";

		if(Fc[k]<Fd[k])
		{ //Outer 'if' Start
			a[k+1]=a[k];
			std::cout <<"The Value Of a" << k+1 << "=" << a[k+1] << …
JasonHippy 739 Practically a Master Poster

As Sky has mentioned, there are several potential causes of this error.
I think it's most often related to incorrectly/ambiguously defined variables, function parameters or function return types.

From what I understand of this (I have encountered it before):
In MS's attempts to make VS2005 more conformable to the standard, VS2005 onwards requires all variables, parameters and return types to be explicitly declared.

In previous editions of VS, the compiler would assume int for variables which were ambiguously defined...

Consider this as a random example:

for ( int i = 0; i < (const)(myVector.size()); i++ ) 
{
    // Do something....
}

QUICK NOTE: Assume that myVector is declared elsewhere as a std::vector!

in VS 2003 and earlier, the above code would compile correctly without errors or warnings, but in VS 2005 onwards you'll get the C4430 error/warning message.

Now what was wrong with the above code?
Well, if you look at the for loop, particularly the conditional part, what do we see?

i<(const)(myVector.size());

From the first part of the for loop, We can see that i is declared as an int, but what about myVector.size() in the conditional part?? What's going on there?

Well, the return value of the call to myVector.size() has been cast to const, (probably by some insanely overzealous member of the const-correctness brigade!), but what would that convert to? const what?

In previous versions of VS (2003 and earlier), the compiler would assume that …

JasonHippy 739 Practically a Master Poster

My original code enables me to play another frame once the user has clicked on the object-as seen in the code;

stop();
btn1.addEventListener 
	(MouseEvent.CLICK, onClick); 

function onClick
( event:MouseEvent):void 

{
gotoAndPlay("8") 
}

However, when i replace gotoAndPlay with 'gotoAndStop' it doesnt work?

Do you have a call to play() in the actionscript in the timeline on frame 8 of your clip? (click on frame 8 and look in the actionscript window)
That is the most likely cause of this problem......

Changing the gotoAndPlay in the code you posted to a gotoAndStop should cause your clip to go to frame 8 and stop.
But an explicit call to play() in the AS on the timeline of your clip at frame 8 would cause playback to continue..

Remove any call to Play() from the AS for frame 8. Don't replace it with a stop() as that would cause any gotoAndPlay(8) calls to fail....

Give that a go and let me know how you get on.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hi, guys
I've a little problem, again. Before closing the thread I just wanted to ask. As you might have seen from the code, I'm reading array from the file. I want my flash to be resized depending on the array size read from a file.

I don't know whether I'm using correct word to explain what I want.
I want every square to be 100x100 always, and depending on the array size I want my flash size to resized. For instance if array is 5x5, then I want flash animation to be 500x500, if array size is 100x100, my flash will be 10000x10000. It's ok if there will be scrollbars. Is there a way to achieve this?
Thanks again.

Sorry dude, I haven't had a chance to puzzle over this properly yet!

My initial thoughts are that you'll probably have to restructure your code a little. All of the code for loading your text file and drawing and animating your arrows should probaly be moved out of Main and into a class of it's own (ArrowAnimation.as??).

Then you can set the size of the Main.swf [500X500] and add an instance of your animation to the stage inside Main.
This way your arrow animation should appear at full-size. But as you've already mentioned, it may not fit inside the visible area of the main frame (depending on the amount of data in the data file).

Bearing this in mind:
After …

JasonHippy 739 Practically a Master Poster

I'm writing a "Chicken and Eggs"-style game. I get an error in Main.as, line 160, that says "1119: Access of possibly undefined property ENTER_FRAME through a reference with static type Class." Line 160 is:

basket_mc.removeEventListener(KeyboardEvent.ENTER_FRAME,moveBasket);

basket_mc is a MovieClip of the basket used to collect falling eggs. moveBasket is a function to move the basket.

Any suggestions on how to get the program to recognize ENTER_FRAME as defined would be greatly appreciated.

The ENTER_FRAME event is a part of the Event class (flash.events.Event) not the KeyboardEvent class (flash.events.KeyboardEvent).

So to fix the bug you're having, you need to change your line of code to:

basket_mc.removeEventListener(Event.ENTER_FRAME, moveBasket);

Looking at the code in your .zip, I can see that you know what you're doing and are comfortable with adding and removing event listeners, so I won't explain further...It looks like you just made a simple syntax error in your gameOver() function when removing the ENTER_FRAME event listener for your basket_mc!!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Its not possible to cast an integer to a std::string.

Yeah, I wasn't sure myself...
One thing's for certain...my brain is not quite in gear yet today. Time for a coffee methinks!
Doh, how can I have forgotten sprintf?? {kicking self!}

Anyways, thanks for jumping in and rescuing the thread before I made any other stupid suggestions! heh heh! :)


J.

JasonHippy 739 Practically a Master Poster

OK, at this point I'll admit I've not used SYSTEMTIME before, I usually use ctime instead. So I'm not familiar with it!

But, the code looks syntactically sound, so if it doesn't work it's probably worth looking at the datatypes used in the SYSTEMTIME structure, as they are probably being stored in a format that would require casting or explicit conversion!

From a quick look in VS it would appear that they are all of type WORD, which is typedefined as unsigned short if memory serves....{checking..}....Yup!

What I'd recommend is converting 'time.wday' et al to strings. Casting them should probably work.

Have you tried this?

// attempt to put date into a string
	std::string date = (std::string)time.wDay + "/" + (std::string)time.wMonth + "/" + (std::string)time.wYear;

If that doesn't work, then you'll have to find another way of converting from unsigned short int to std::string.
Unfortunately, I don't have any decent reference material at hand at the mo. So we may have to do some googling if casting doesn't work...I've got a memory like a sieve for the standard c++ function names!

Jas.

JasonHippy 739 Practically a Master Poster

The return type for your function is string, so you need to return a single string.

Your functions return type is string and you've already built a string called 'date' in your code, which contains the date..
All you need to do is get rid of the three return statements and return the date variable instead.

NOTE: A function can only return one value, so the only thing this would return (if this code even compiles!) is time.wday. As soon as the function reaches the first return, it will return the first value, the other two will never be reached!

As mentioned, what you need to do is return date instead..
i.e.

return date;

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

p.s. the bit of code where you're building the date string could be written like this:

// attempt to put date into a string
	std::string date = time.wDay + "/" + time.wMonth + "/" + time.wYear;

Which is a little more efficient. (I don't mean perfomance-wise, but in the amount of typing required..i.e. one line of code instead of six!)

JasonHippy 739 Practically a Master Poster

OK, I think I solved it, I just installed vc redistributable package from MS, and the application started working without python installed. Installing the application makes msvcrt90.dll globally available and hence solves the problem. But it still sucks asking everyone to install the vc package.

Welcome to .dll hell....One of the few things that Microsoft really did create entirely themselves, heh heh! And yes it does suck! ;)

Not everybody who uses your app would have to install the MSVC redistributable....Just anybody who didn't already have it installed. But as you've got no way of knowing, what proportion of your users already have it against the proportion that don't, your best bet is to just bite the bullet and cover all bases by including the MSVCRT redistributable with your apps install package!

JasonHippy 739 Practically a Master Poster
def who_knows(a, b):
    """ a and b are lists """
    c = []
    for i in a:
        if is_mem(b, i):
            c.append(i)
    return uniqify(c)

 def is_mem(a, elem):
    for i in a:
        if i == elem:
            return True
    return False

 def uniqify(arr):
    b = {}
    for i in arr:
        b[i] = 1
    return b.keys()

From what I can see, the who_knows() fuunction takes two lists as parameters.
It then iterates through list a and calls is_mem() passing list b and the current item

is_mem iterates through the passed in list and tries to determine whether or not the passed in item is in the list.
If the item is in the list, True is returned by is_mem().
If the item is not in the list, False is returned.

if is_mem returned true, then the current item in who_knows() is stored in list c

Once all of the items in list a have been iterated through, the who_knows() function passes list c into a function called uniquify() and returns the value that uniquify returns (a list!)

The uniquify function iterates through the passed in list and basically removes any duplicates.

To test the code, try the following:

# these are your functions
def who_knows(a, b):
    """ a and b are lists """
    c = []
    for i in a:
        if is_mem(b, i):
            c.append(i)
    return uniqify(c)

def is_mem(a, elem):
    for i in a:
        if i == elem:
            return True
    return False

def uniqify(arr):
    b …
JasonHippy 739 Practically a Master Poster

im sorry this is kind of a silly question i know, but does anyone know any succesful ways to change a .py into a .exe? like so that someone without python installed on their computer can run it?

i've seen this topic in a couple places but everything i've tried hasn't worked... like py2ke or something i couldn't get to do it

There are a few Python libraries out there which can do this. I think the most popular is py2exe. Google it, you'll find it!

If you're a windows user, there are py2exe installers available for several different versions of Python, all you do is download and install the version appropriate for your installed version of Python.
(so if you're using 2.6, download py2exe for 2.6!)
If you're not on windows, there are also source packages available...And plenty of documentation telling you where to put the files I'm sure!

With py2exe installed, the next step is to create a script to build your app....

Take this as an example:
Here's a simple py script for the archetypical 'hello world' type app...
Without further ado I present to you 'hello.py':

# hello.py
print "Hello World!"

ok, so now we want to add a quick script to use py2exe to build our hello executable.
so here's 'setup.py':

# setup.py
from distutils.core import setup
import py2exe

setup(console=['hello.py'])

This little script tells the py2exe module that we're building a …

sravan953 commented: Your msvrc90.dll solution really helped me! Kudos if I could! +1
JasonHippy 739 Practically a Master Poster

I recently went and compiled my Tkinter application into a standalone app using py2exe. It seems to work when python is installed on the computer but when it is not installed, it shows the error - 'This application is not configured properly. Reinstalling the application may help', I read elsewhere that downgrading to python 2.5 solves this problem, but I cant, cause python 2.5 contains Tkinter 8.4 which makes my application look like crap. Please help me to solve this problem.

-vishy1618

This is purely down to .dll's. Namely the msvcrXX runtimes (msvcr70.dll, msvcr90.dll etc)

If the target machine does not have Python installed, then it needs to have the correct version of the Microsoft VC runtime installed (depending on the version of python used). I'm pretty certain it's the VC9 redistributable runtime package (msvcr90.dll) that you need to include/install in order for apps created with the Python2.6 version of py2exe to work.

The reason for this is because python2.6 was built against the msvcr90.dll, so python 2.6 depends upon the msvcr90.dll...It needs it.

Therefore, when packaging up your app ready for deployment to users, you'll need to ensure that you include the installer for the msvc90 redistributable runtime in case the users machine does not already have it (which in this case your test pc sounds like it doesn't!).

If python 2.6 is installed on your users pc (or any other app that requires the msvc90 runtime), then the msvcr90 runtime will already be installed …

sneekula commented: very detailed explanation +8
JasonHippy 739 Practically a Master Poster

hello all.
I have python 3 and want use mysql but i dont find mysqls modouls please say me a link.

I don't think they've actually released a library for python 3.0 yet.
I think the current version of mysql's python interface only works on python2.x versions

Take a look at this link..should explain it better!:
http://mysql-python.blogspot.com/2009/02/project-status-community-participation.html

Also, there's this:
http://blog.some-abstract-type.com/2009/05/mysql-connectorpython-on-launchpad.html

JasonHippy 739 Practically a Master Poster

Hey all,
This isn't so much a question as a heads up...

After using python for a few years (mainly doing blender scripts and random console/command-line apps and tools) I've recently started looking into doing some GUI based stuff using wxPython.

I've had a look at a few of the examples in the "Starting wxPython" thread at the top of the page, but I've hit an error while trying to run one of the wx.lib.plot examples..(Vegaseat's example on page 10 of the thread)
(oh yeah, I'm using Python 2.6 with version 2.8 of wx BTW!)

Anyway, in the example code, the line of code which saves the graph to an image:

plot_canvas.SaveFile(fileName='trig1.jpg')

causes the following error to be thrown by the interpreter:

Traceback (most recent call last):
File "C:/Documents and Settings/Jason/Desktop/wxPythonStuff/usingPlot2.py", line 60, in <module>
MyFrame(None, mytitle, (width, height)).Show()
File "C:/Documents and Settings/Jason/Desktop/wxPythonStuff/usingPlot2.py", line 53, in __init__
plot_canvas.SaveFile(fileName='trig1.jpg')
File "C:\Python26\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\plot.py", line 642, in SaveFile
dlg1.Destroy()
AttributeError: 'NoneType' object has no attribute 'Destroy'

Now, this isn't a bug in Vegaseat's code. It's actually a bug in plot.py in the wx library.
I've taken a look at the code in the SaveFile() function in plot.py (in the wx library) and the problem is this block of code:

extensions = {
            "bmp": wx.BITMAP_TYPE_BMP,       # Save a Windows bitmap file.
            "xbm": wx.BITMAP_TYPE_XBM,       # Save an X bitmap …
JasonHippy 739 Practically a Master Poster

Ok, I think I see the problem. It's not related to publish settings or erroneous code, its a security issue...

I downloaded your code to my desktop and unzipped it to a directory called ide. I then loaded Main.as into FlashDevelop and pressed Ctrl-F8 to build the .swf.
The swf built successfully and ran ok in a standalone player in the FlashDevelop IDE...Lots of squares with different sized arrows pointing in different directions and moving around..OK good so far.

I knocked up a quick and dirty HTML page to embed the swf and opened the page with Firefox and I got a blank blue .swf...Not so good!

I then opened up the directory containing the swf on my desktop and tried to run the swf in a standalone instance of Flash player (flash player 10) and got the following error message:

SecurityError: Error #2148: SWF file file:///C|/Documents%20and%20Settings/Jason/Desktop/ide/Main.swf cannot access local resource file:///C|/Documents%20and%20Settings/Jason/Desktop/ide/data.txt. Only local-with-filesystem and trusted local SWF files may access local resources.
at flash.net::URLStream/load()
at flash.net::URLLoader/load()
at Main/::readMatrix()
at Main$iinit()

This is a pretty straightforward thing to get around, what you need to do is inform flashplayer that your .swf is a trusted file and that you give explicit permission for it to access the local file-system.
"How do I do that??" I hear you cry "Do I need to sign a permission slip for its teacher?"

Well, to do this the following simple steps are …

NeoKyrgyz commented: As always best and correct answer. Thanks again. +1
JasonHippy 739 Practically a Master Poster

To better diagnose the problem it would be worth trying to run the .swf directly from the desktop in a standalone version of flash player, instead of via a browser plugin.
To do this, navigate to your .swfs directory on the hard drive and double click on it and the standalone player should load and run the file!

If it doesn't work properly in the standalone player, then it is most likely that your actionscript for loading the text file is incorrect.
In which case, it would be an idea to upload some code so we can see what's going on.

However, if it works properly in the standalone player, then it could be a problem with your publish settings...Unfortunately I'm on my wifes laptop at the moment, so I don't have Flashdevelop handy and can't give any suggestions on what to try.

For now, try running your swf in a standalone instance of flashplayer and let us know how you get on!

All the best.
J.

JasonHippy 739 Practically a Master Poster

Excellent, not begging or having a go or anything, but any chance you can mark this as solved??

J.

JasonHippy 739 Practically a Master Poster

looks ok to me...{using firefox..}

Could be a browser related thing...
What browser are you experiencing the problems on?
What kind of help do you need?


p.s. one thing I did think was that the site intro was a little long-winded and slow...Having the 'Enter site' link appear at the bottom throughout the intro might be an idea, as some people won't like being forced to sit through the entire intro before being able to enter the site!

JasonHippy 739 Practically a Master Poster

One thing I've just noted from reading your OP; you said that the original software could have been built using anything from VC4 to VC6 and that you were using a .dsw from your source repository.

By chance, did you try opening the .dsw with something like notepad to see what version of VC the .dsw was originally created with?

if it was created with VC6 you'll see the following in the top line:
"Microsoft Developer Studio Workspace File, Format Version 6.00"

If it was originally done for VC4 or VC5, then using VC6 could be the problem as several definitions, headers and libs would have changed between each of the VS versions...which could possibly account for some of the problems you're having!

Beside my suggestions in previous posts, the compiler version is the only other major factor that I can think of. Other than that I'm pretty much out of ideas!

J.

JasonHippy 739 Practically a Master Poster

Damn, I was certain that the include order was the problem...

hmmm......Which version of the platform SDK are you using?

If it is newer than the February 2003 version of the platform SDK then that could also be part of your woes....The Feb 2003 SDK was the last version to fully support VC6...Subsequent versions of the SDK do not work with VC6 and cause all kinds conflicts, compiler/linker errors and problems.

Took me a lot of googling to find out that nugget of info back in the day, I'd originally installed one of the 2005 PSDK's and ended up with more errors than when I started out. But installing the Feb 2003 SDK and then altering the include order (as previously described) fixed all of the problems I had.

As long as you at least have the same versions of the SDK (and the other libraries) that were used in the original build and your include order is correct, then I can't see any other obvious things that would cause these problems!

As you've mentioned in your other post, it could be that the previous version of your companies software was compiled on a different version of windows...Not sure if that would make that much of a difference though. The output from the VC6 compiler should be pretty much the same across the different versions of windows as it uses the same libraries and sources/includes to build the final executable.

Jas.

JasonHippy 739 Practically a Master Poster

Hey there, I just replied to your other thread:
http://www.daniweb.com/forums/thread195614.html

Try altering your include order as mentioned in my reply to the post in the above URL and see if that does the trick. It may solve this problem as well as the other problems you were having!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

I seem to recall having similar issues at my previous job, I had some software to maintain in VC6 which threw up several errors when I first tried to compile the source, despite having paths set up to all of the relevant external libraries and includes...

winsock.h and winsock2.h were a couple of the headers which were conflicting...Amongst many others

All I did to solve the problem was alter the order of the includes and libraries and the conflicts ceased to be an issue. The sources I had compiled and built with no issues from then onwards!

To get rid of the winsock problem I found that the platform sdk had to be included before the standard VC98 includes.
I also had to move things like Zlib, Freetype and dxsdk above the VC98 includes to get rid of some of the other conflicts I was having!

To alter the include/library order in VC6:
Go to 'Tools->Options' and select the 'directories' tab.
In the 'show directories for' drop-down select 'include files' and ensure that the platform SDK include directory is above the VC98 includes. (select the entry for the platform SDK and move it up or down the list with the arrows in the dialog)

Similarly, select 'library files' from the 'show directories for' dropdown and ensure that the platform sdk lib folder is above the VC98 libs.

Note: if you don't have paths set up to the platform SDK lib/include directories, …

JasonHippy 739 Practically a Master Poster

Hi, I am using Flash 8 with Actionscript 2.0. I am unable to stop my Flash Videos from playing as soon as the page loads. Tried everything...please help, Thank You

Have you tried setting the autoPlay parameter of the FLV playback component to false? That should solve the problem...

To do this:
Open up your .fla, select the instance of the FLV playback component on the stage and then open up the 'component inspector' panel. (by selecting 'Window->component inspector' from the top menu or by pressing Alt+F7)

In the parameters tab of component inspector, right at the top of the list is a parameter called autoPlay, which is set to 'true' by default...Set this to 'false' and that should stop the video from auto-playing when the page loads..The user will then have to manually start the vid by pressing play on the FLV playback components controls.

Note:The above steps will only work if your FLV component has been manually added to the stage (i.e. you dragged and dropped an instance of it onto the stage from the component panel).

If you are dynamically adding your FLV player instance onto the stage via actionscript instead, then you'll need to do the following:
Wherever you're attaching the new instance of the FLV playback component, be sure to add the following line of AS to set the autoPlay property:
{FLV player instance name}.autoPlay=false;

So if you used actionscript to attach an instance of an FLV …

JasonHippy 739 Practically a Master Poster

I can't see anything obvious...

The only thing I can think of that you could try is perhaps removing your variables from the flash movies URL..
i.e. change the following lines:

<param name="movie" value="flash/arcs.swf?testing=test" />

to

<param name="movie" value="flash/arcs.swf" />

and

<object type="application/x-shockwave-flash" data="flash/arcs.swf?testing=test" width="380" height="130">

to

<object type="application/x-shockwave-flash" data="flash/arcs.swf" width="380" height="130">

Then, where you have your <param name> tags try adding the following line....

<param name="flashvars" value="Testing=Test" />

Note: It looks to me like you'll need to put two copies of the above line in your code. One under the first line you edited and another a couple of lines below the second edited line! (because it's in the middle of your !IE thing!)

It's the only method I've ever used to pass variables into flash, so it should work....Let me know how you get on!
I've never used the old querystring method of passing params before, so I don't know much about it!

Addendum:
If memory serves, using flashvars makes the parameters available to the root of the movie, so your getqry method will probably be redundant as you won't be using querystring any more!

I know that the flashvars thing isn't the most secure way of sending parameters to a flash file, the only other method I am aware of which I used once (but too long ago for me to remember the specifics of) is FSCommand which I think is more secure...

Cheers …

JasonHippy 739 Practically a Master Poster

P.s. I just zipped up the files with a hastily put together readme.
In the zip there's a folder with a Flash 8 Pro/AS2 source .fla, a precompiled .swf, a skin for the FLV component, the XML playlist and the aforementioned README.

After unzipping the folder, all you need to do is copy four FLV videos into the directory and edit the 'title' fields of the XML file to include the filenames of the FLV's and then run the .swf to view the vids!

Note: The .fla was created using Flash 8 Pro, so the precompiled .swf will probably only work with FLV's encoded using the flash 8 video encoder or earlier...Videos encoded using later versions of the video encoder may not work properly!

loading the .fla into CS3 or CS4 and re-exporting the .swf may or may not work....I've no idea as I don't own CS3/CS4...I use Flashdevelop for my AS3 stuff!!

Anyways, enough o' my inane wibbling... The .zip file is attached!

J.

JasonHippy 739 Practically a Master Poster

hi i have created a movie clip that should play external flv files i have placed the flv files in thier own key frames and have buttons that gottoand play frame number but when i click on the buttons it only play the 1st video in the 1st frame but the other dont play what script can i use to play the other frames with flv files

One option would be to have your flash file load an XML playlist and assign each of the entries in the file to an instance of a button on the stage.

I've got code for an AS2 FLV player I started to put together for my band a while back (using flash 8 pro), but I never got round to finishing it off....It works, but there are a few other tweaks I wanted to make to it...I'll go into that in a bit!
This neat little FLV player was made during a 30 minute lunch-break at work and it hasn't been touched since...Maybe I will finish it one day, but feel free to take the code and do with it what you will!

At the present time, I've got a one frame, one layer movie with an instance of the FLV playback component (called m_player) and four buttons (btn0, btn1, btn2 and btn3) on the stage and that's about it!

This is what the XML file (vidPlaylist.xml) looks like:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<videolist>
	<video>
		<title>video1.flv</title>
		<description>This is …
JasonHippy 739 Practically a Master Poster

OK, I've reskinned the FLV player component before, but I've never had to reskin the tree component. So I'm not sure what would be involved. However, I do know that most, if not all of the components that ship with the various versions of flash are fully skinnable and customisable...So reskinning and customising the Tree component should be possible.

A quick google reveals that the answer to your question most likely lies in the Adobe flash livedocs.....( http://tinyurl.com/qnxf8g - click the link and follow the top result!)

The docs state that the tree component uses an instance of the RectBorder class for its border and a scrollbar component...I'm not sure if the scrollbar is a sub-component used in the Tree's RectBorder instance, or if it is just a direct subcomponent of the Tree (like the RectBorder instance). I guess you'll have to look into that yourself!

Anyway from the link provided, you should be able to access all the help you need. Skinning of components has been around since at least mx2004, so the whole process of skinning should be well documented.

From a cursory look in the livedocs, they detail how to skin components and their sub-components, so you should be able to find all of the info you're looking for in there!

The process will probably be quite long-winded, and probably also prone to problems but I'm sure you'll get there in the end!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hi All,
I downloaded Flex 3 software from www.adobe.com/flex.
Its downloaded sucessfully after that its expand also.

The problem don't know what to do after that:'( ....... Plz can anyone tell me

Now you've got the flex3 SDK you can create AS3 classes using a text editor and use them to build flash movies using the command line tools that come with the SDK.......If like me you're too lazy to manually build your swfs there are a couple of very good free IDE's which can be used with the Flex3 SDK. Flashdevelop (www.flashdevelop.org) or eclipse (www.eclipse.org) are the best. Personally I use Flashdevelop (only available for windows at the moment!!).
Not sure on what to do with eclipse as I've never used it, but with flashdevelop it's just a case of downloading and installing the latest version. When you attempt to build your first AS3 project, the IDE will ask you for the path to the flex 3 SDK. All you do is navigate to the folder containing the flex3 SDK and hit OK. And that's it. You can now compile and build AS3 projects.

Flashdevelop supports using mxml/AS3 or pure AS3 to create flash content you can even create apps for adobes AIR runtime environment as well as using Haxe there are even options to create AS2 based projects.

cheers for now,
Jas.

p.s. there are tons of tuts and examples on the flashdevelop forums!

JasonHippy 739 Practically a Master Poster

Apologies for the delay in replying to this...For some reason I didn't spot this post until today!

From the code you've posted, the 2nd line of the following block of AS contains a simple typo which is the source of your problem:

mySoundObject = new Sound();                         
//initializing my sound 
MySoundObject.attachSound("explosion.wav");

In line 1 you've declared a sound object called "mySoundObject" and in line 2 you're attaching a sound file "explosion.wav" to a different object called "MySoundObject" (see the capital M? There's your problem. Identifier names are case sensitive, so mySoundObject and MySoundObject are treated as different entities!)

Try the following:

var mySoundObject:Sound = new Sound();                         //initializing my sound 
mySoundObject.attachSound("explosion.wav");

and that should solve your problem. Everything else in your code looks good!

Cheers for now,
Jas.

iamthwee commented: good spot +19
JasonHippy 739 Practically a Master Poster

Despite being a C++ programmer by trade nowadays, I still mess with Flash rather a lot. So one of the main bits of free web development software I've been using lately is Flashdevelop (www.flashdevelop.org) which is free open source software (Windows only) for creating flash content. If you download the Adobe Flex3 SDK (from Adobe, also free) you can use Flashdevelop to create flash movies in AS3....Beats the hell out of paying through the nose for Flash CS4!

Alongside creating flash movies, I also use Flashdevelop as my main HTML/CSS/Javascript editor...So there's no need to fork out for Dreamweaver either!

If you download the latest Papervision3D AS3 library (http://blog.papervision3d.org) you can also easily create 3D content in flash.

I use Blender (www.blender.org) and Google Sketchup (from Google) for creating 3D models to use in my papervision flash projects.

Inkscape (www.inkscape.org), GIMP (www.gimp.org) and Paint.NET (www.getpaint.net) are my image editors of choice (for photo/gfx editing and texturing). All top quality free open source software...Again, eliminating the need to shell out for Photoshop, Illustrator or Fireworks!

I also use Python (www.python.org) for writing Blender scripts and for general system tools.

Oh and Audacity (http://audacity.sourceforge.net) for editing audio files.

So there's a list of free legal software that can be used for web-dev stuff.

As for tutorials, I find that google is my best friend there...Can't say that there …

peter_budo commented: Nice set of resources +19
JasonHippy 739 Practically a Master Poster

JasonHippy
Thank you very much for forwarding me to an easier way of doing it. I've installed flashdevelop and using it. Now I realized that AS3 is really programming language with all OO properties (class, polymorphism, inheritance) There are still some problems, but since I'm in correct way I will find solutions for them.
Any good (video) tutorials that you can suggest about AS3?
Thanks again.

Hey Neo...
No probs, glad to help..Good to hear that you're getting on well with Flashdevelop! ;)

I've done quite a bit of FLV/video related stuff in the past using AS2, but I've not done anything with video and AS3 yet, so I'm afraid I can't help you there!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

OK, I've downloaded the file and my initial impression is AAARGH!

In my previous job in the elearning sector, I used to hate having to edit badly put together .fla's like this....It's a nightmarish mess of layers and code and badly named library objects (Although..not the worst I've seen by a long shot!)...I second Peters motion to slap whoever originally came up with this! heh heh ;)

I haven't had time to look at the file in any depth yet, but I'll post again when I finally get time to go through it properly!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

I think the problem is lines 18 and 33:

void fillTree(const bintree<int> &treeRoot);

By passing treeRoot into fillTree as a constant reference, what you're telling the compiler is that your function will not modify the contents of treeRoot....

As you are modifying the values held, this is the reason your compiler is complaining. If you declare the function passing an ordinary reference instead I.E.:

void fillTree(bintree<int> &treeRoot);

I think the error should go away!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hey guy and m.
OK, I think I can help with the escape key thing, but I'm not sure on the video scaling problem.

From what you've said, I'm assuming that you're listening for the escape key in your AS and then firing off some code to navigate away from the video page...If that's the case then the thing to bear in mind is that in flash player, the escape key is bound as a hot-key to exit the full-screen mode.

So, if you've put some code into your movies actionscript to pick up presses of the escape key, then unfortunately flash player will intercept the escape keypress before your .swf does and will interpret that you want to exit fullscreen mode. So the functionality in your swf which you've bound to the escape key will not get called.

Likewise, if you were to try binding some functionality in your movie to the F5 key, so the user presses F5 and your movie does something...In a standalone instance of flashplayer your movie would work fine and would properly pick up and process presses of the F5 button and your bound functionality would be executed....However in most web browsers, F5 is bound to the 'refresh page' functionality. So if you were running your .swf in a browser, your browser would intercept and proceses presses of F5 before your .swf. In other words your browser will refresh the web-page causing your .swf to be reloaded.

If you …

JasonHippy 739 Practically a Master Poster

>it's probably because you aren't freeing the block
>of memory you're allocating in your call to malloc
No, it's probably not. Even if the process doesn't release allocated memory when it terminates, all you're likely to get is leaked memory, not a segmentation fault.

>memcpy(&pData, &t, sizeof(t));
>memcpy(&a, &pData, sizeof(t));
pData is already a pointer. Remove the address-of operator and watch it magically begin working:

memcpy(pData, &t, sizeof(t));
memcpy(&a, pData, sizeof(t));

Doh, good point....I stand corrected madam... {hangs head in shame}
I didn't spot the unnecessary usage of &..Although now you mention it, it's glaringly obvious! {kicking self}

He he, ne'er mind....Can't win 'em all...Unless your names Narue that is! heh heh ;)

JasonHippy 739 Practically a Master Poster

Hello to everyone,

I am having this problem with the following code:

typedef struct test
{
	int  i;
	char c[50];
} testStruct;

int main()
{
	char *pData;
	testStruct t;

	t.i = 5;
	strcpy_s(t.c, 50*sizeof(char), "hello");

	pData = (char *)malloc(sizeof(t));
	memcpy(&pData, &t, sizeof(t));
	
	testStruct a;
	memcpy(&a, &pData, sizeof(t));

	cout << a.i << ' ' << a.c << endl;

	system("PAUSE");
	return (0);
}

The problem occurs with the variable "pData", the moment the program returns.

Could someone, please, indicate to me what the problem to the above source code is?

Thanks a lot,
Erroneous Seth

If the problem is occurring when the program exits, it's probably because you aren't freeing the block of memory you're allocating in your call to malloc......It's one of the golden rules of C and C++ that you should free any resources that get allocated, either by using free() (if using the old C style allocations methods, like malloc ) or delete (if using the 'new' keyword to allocate memory).

So at some point before you return, try putting the following line in:

free(pData);

That should hopefully solve the problem!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

My last post wasn't entirely successful. But using Flashdevelop and the latest version of the flex 3 SDK (both of which are FREE downloads, so google 'em and download 'em....Highly recommended!) I've knocked something together in AS3 which works pretty much as you wanted it to.....

First I knocked a little AS3 class together draw an arrow shape (derived from Sprite, a new AS3 class which is basically a MovieClip without a timeline...All animation is done through adding and removing event listeners....)
Anyway, without further ado here's Arrow.as:

/**
* Draws an arrow shape
* @author Jason Trunks
* @version 0.1
*/

package 
{
	import flash.display.Sprite;
	
	[SWF(backgroundColor="0xffffff", width="800", height="600", frameRate="25")]
	public class Arrow extends Sprite  
	{
		public function Arrow()
		{
			init();
		}
		
		public function init():void
		{
			graphics.lineStyle(1,0,1);
			graphics.beginFill(0xffff00);
			graphics.moveTo(-50,-25);
			graphics.lineTo(0,-25);
			graphics.lineTo(0,-50);
			graphics.lineTo(50,0);
			graphics.lineTo(0,50);
			graphics.lineTo(0,25);
			graphics.lineTo(-50,25);
			graphics.lineTo(-50,-25);
			graphics.endFill();
		}
	}
	
}

Then I knocked this little class together, which draws and animates 10 instances of the Arrow class and animates them in a circular um... well in a circle....so this isCircularArrow.as:

package 
{
	import flash.display.Sprite;
	import Arrow;
	import flash.events.Event;
	/**
	 * Draws a number of arrows onto the stage, arranged in a circle and animates them...
	 * @author Jason Trunks
	 */
	[SWF(backgroundColor="0xffffff", width="275", height="250", frameRate="25")]
	public class CircularArrows extends Sprite 
	{
		private var arrows:Array = new Array();
		private var angles:Array = new Array();
		
		private const numArrows:Number = 10;
		private var angleDifference:Number = (2 * Math.PI) / numArrows;
		
		private const radX:Number = 100;
		private const radY:Number = 70; …
NeoKyrgyz commented: Really Helped +1
JasonHippy 739 Practically a Master Poster

OK, I've not had time to look into this too far, and it's been a while since I've done any AS2...But here goes.

To be able to dynamically use movieclips in your actionscript you first need to ensure that the clip has the appropriate linkage settings.
After creating your GFX/movieclip, locate it in the library, right click on it and select "linkage..." ensure that the "export for actionscript" and "Export in first frame" items are checked.
In the identifier field of the dialog, put in the name you want to use to refer to your clip in your actionscript (by default it will have the same name as the asset in the library)

For this example, I created a simple graphic of an arrow on the stage, converted it into a movieclip called mArrow (which automatically bungs it into the library) and then deleted the movieclip from the stage (but keeping it in the library!).

Then in the linkage dialog, I've checked the relevant boxes and left it's name as the default (mArrow). So any time I want to add an instance of the arrow to the stage I can do so using attachMovie(mArrow, "instance_name_mc", getNextHighestDepth()); .

Ok, so that's the first part out of the way, now we have an asset which we can dynamically add to the stage, now for the code part of it.

In the first frame of the main movieclip I've put the following actionscript which should create …

JasonHippy 739 Practically a Master Poster

Aha, yes sorry...I was in a bit of a rush on Saturday....I'd started replying to the thread and then my other half started harassing me 'cause she wanted me to drive her into town...In my haste, I misread the original post..Yes I see now..
I guess I should've cancelled my reply and waited until I had time to look at it properly!

Yes, the OP either needed to do this:

a* aa = new a();

aa->GetAttribute() = Id;

or as you've posted:

a aa;

aa.GetAttribute() = Id;

I stand corrected!

J.

JasonHippy 739 Practically a Master Poster

The line:

aa.getAttribute() = Id;

Is where you're going wrong here....
The assignment operator assigns the left hand operand the value of the right operand.

So you are trying to assign the value of id to the value of the getAttribute function....Which is nonsense.

What you really want is this:

Id = aa->getAttribute();

What this does is assign the value returned by aa.getAttribute() to Id.

That should solve your problem..

Jas.

JasonHippy 739 Practically a Master Poster

Hello!

I want to find the position of objects on my sensor field. I have uploaded the diagram of sensor field attached

In the figure S1-S8 are the laser sensor pointing into the field. While red and yellow are the balls



Case 1:

if there is only one ball, say red, sensor S3 and S5 will buzz. Hence we can locate the ball position on the field.


Case 2:

Now problem comes when there are two balls on the field. In this case they can be at 4 positions in the field and hence solution fails.

Is there any algorithm that can be used to remove the 2 redundant positions and find the actual position

Thanks

Wow this problem takes me back to my old college days here in the UK, when I was on an electronics and computing course....ahh I remember the old traffic lights model we had to control using a bbc micro and machine code and all of the miniaturised industrial machinery and sensors we used to mess around with....Anyways, enough nostalgia...

Looks like you're in a bit of a catch 22 there. There's no obvious solution that I can see.... As you've said, when there are two balls on there, as far as the system is concerned there could potentially be four balls there.

In fact if you put four balls in the marked positions, the sensor array would be in exactly the same state as with …

JasonHippy 739 Practically a Master Poster

Nice post sky, well explained...
But I noticed a very very minor mistake here....

void result(int v, int& x)//v=26;x=30 
	{
		x =  ( 3  *  v  +  5  -  x );//x=((3*26)+5-30)
	//x=76+5-30;
	//x=81-30=51.
return;
	}//result

3*26=78, not 76.
So the final value of x is:
x = 78+5-30
x= 83 - 30 = 53 (as reported by the OP!)

Sky Diploma commented: Gotta develop my math +3
JasonHippy 739 Practically a Master Poster

Hey all,
I've been registered here for a little while now. Figured it's about time to introduce myself to the wider community here.

I'm Jason, I'm thirtysomething (I forget!). My friends call me Hippy 'cause I used to have long hair and a huge goatee beard......I've long since lost the hair, but kept the beard.....And the nickname seems to have stuck, it would appear!

In my spare time I enjoy hanging out with my wife, kids and cats; all aspects of computing (games, programming, 3D modelling with Blender, surfing the web etc. etc.); listening to all kinds of music (mainly the many rock/metal subgenres...but not always!); playing the drums in my band and teaching people to play drums at our guitarists studio.

Professionally, I'm a (more or less) self-taught programmer*, with 5 years commercial programming experience in (mainly) C++.
(* I have a professional qualification in ANSI 'C', everything else I learnt myself...Usually the hard way!)

My first 3 or 4 years were spent working for a small UK based e-learning company, developing and maintaining their C++ based multimedia engine and its associated e-learning software.

In my time there I also got the chance to work on several learner management systems and student gateways/portals using ASP.NET, C#, SQL server and HTML/Javascript. Plus Scorm compliant, flash-based e-learning content using flash/AS1/AS2 and AS3.

I now work as a C++ analyst/programmer for a UK based company who provide market leading 3D CAD/CAM software to the …

JasonHippy 739 Practically a Master Poster

How to show image in place of swf if flash player is not installed in browser !
plz help !

The standard approach would be to use some javascript to check whether the users browser has flash-player installed and if not display an image instead...Do a quick google and you should find several examples of code to do this.

Unfortunately this approach can cause problems if you want your site to work properly with several different browsers, so you'll have to be careful what code/tags you're using in your javascript and HTML.

However, there is a very good platform/browser independent javascript available for embedding flash movies into web-pages called swfobject...try googling "swfobject.js" and you'll find it...I can't remember offhand, but that may offer a solution to your problem...I think you might be able to specify an alternate image to use if there is no flash-player installed...But I haven't looked at it or used it for a while, so I could be wrong!

Having said that, there is another far simpler way you could go about it which doesn't use javascript at all which might also do the trick! Steps are listed below:

1. Embed the flash movie in a div on your page (using the <object> tag, don't use <embed> as it is deprecated!).

2. In the css for your page, set the background image property for the div to the image you want to use if there is no flash player.

JasonHippy 739 Practically a Master Poster

Thanks Jas, But I have the knowledge of that graphic linestyles and know how to draw line and curves in flash. but when coming to built a application it becomes complicated. do you have any tool which was completed?

Hey Raja.
No, I don't have a fully featured paint-clone, but I do have a very very simple little post-it note application; as described in my original post.

You've already said you know your way around the drawing API, so there is nothing to stop you from creating a simple tool like my post-it note app and extending it to include more and more advanced functionality... As long as you have a good object oriented design methodology you should be able to put something together in no time!

As previously mentioned, the only REAL difficulty is going to be if you want users to be able to save or print their pictures from flash...Then it's a completely different ball-game!

I've never had to do anything with regard to printing anything from flash, so I don't know much about it. But I do know that to export image data from flash, the bitmap data (in text format) would have to be passed/streamed to a php script (or perhaps a javascript!).

The script then needs to convert the passed text data into a .bmp or .png image on the server, which your script would finally allow the user to download and save.... I'd assume that similar steps would …

JasonHippy 739 Practically a Master Poster

Hi everyone,

Say I have a MovieClip that has nested MovieClips for example

person_mc
   > body_mc
               > toe_mc
                        > toe_nail_mc
   > leg_mc
   > hand_mc

Then, I want to export this person_mc and use AS3 to move the body parts _mc around. How do I reference the body parts? Ideally, I am thinking there might be such thing as:

public class ToeNail {}
public class Toe {
   public var toeNail:ToeNail;
}
// ... and Leg and Hand class
public class Body {
   public var toe:Toe;
}
public class Person {
   public var body:Body;
   public var leg:Leg;
   public var hand:Hand;
}

is there such a thing? otherwise how to reference?

furthermore, what happens if the nested _mc is on some frames and not on some other frames?

I'm not sure if it's the same in CS3/CS4, but in flash 8, with nested clips on the timeline you used that nasty _parent.{movieclipname}.{sub-movieclip name}.gotoAndPlay("waveArm") stuff to access the items that are on different levels of the stage....yuk, nasty!
If that's still available, then it's a quick and dirty option....

But you can do it without the timeline..Simply create classes for each of your body parts and derive them from Sprite (i.e. public class arm extends Sprite) and then create your person class, including instances of the body parts in your person class (also derived from Sprite).

You probably know this already but the Sprite class is basically a movieclip without a timeline..For animation, you add and remove eventlisteners and handlers for the ENTER_FRAME …

JasonHippy 739 Practically a Master Poster

My previous post was a little messy...so apologies for that....

Below is a tidied up version of your code....This is how I would've tackled the problem...

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int largest_prime_factor(int const &a);  
int squared_digit_length(int const &a);

int main()
{
	// store forename and surname in std::strings...Safer than using char arrays!
	string forename, surname;
	int n1,n2,n3,n4,n5;
	cout << "Enter your forename and surname : ";
	cin >> forename >> surname;

	// TODO: do you need to perform any range checking on the users input?

	// assuming no range checking required....just use the int values of the first characters stored in
	// the strings 
	n1 = (int)forename[0];
	n2 = (int)surname[0];
	cout << endl << "Integer value for 1st letter of forename (" << forename[0] << ") = " << n1 << endl;
	cout << "Integer value for 1st letter of surname (" << surname[0] << ") = " << n2 << endl;

	// calculate and output the digit lengths...
	n3 = squared_digit_length(n1);
	n4 = squared_digit_length(n2);
	cout << "squared digit length of " << n1 << " is " << n3 << endl;
	cout << "squared digit length of " << n2 << " is " << n4 << endl;

	// calculate and output the largest prime factor.
	n5=largest_prime_factor(n3+n4);
	cout << "The largest prime factor is: " << n5 << endl;
	
	return 0;
}

// Calculate squared digit length of passed-in value.
// NOTE: passing a constant reference to an int...Probably overkill for a …
JasonHippy 739 Practically a Master Poster

Wow, that post was a nightmare to read!
Can you use code tags in future please?!

The maths in this looked terrible at first glance too...How does 82 + 52 = 89??
It took me a while to work out that you meant, but I got there in the end!
85 becomes (8*8) + (5*5) = 89! Now I see!

Anyways, I've posted some comments in your code:

#include <iostream>
#include <cmath>

using namespace std;

// shouldn't this be returning an int??
bool largest_prime_factor(int b);  

int squared_digit_length(int a);

// This bit looks ok at a brief glance....
int main()
{
	char ch1, ch2;
	int n1, n2, n3, n4, n5; // used for the 5 steps of the task

	cout << "Enter your first name and surname: " << flush;
	cin >> ch1; // read the first letter of the first name
	cin.ignore(100, ' '); // ignore the rest characters in the first name
	cin >> ch2; // read the first letter of the surname

	n1 = (int)ch1;
	n2 = (int)ch2;
	n3 = squared_digit_length(n1);
	n4 = squared_digit_length(n2);
	n5 = n4 + n5;

	// until we get here...

	//  would it be worth adding "n1 = " and " n2= " to the cout below?
	cout << n1 << n2 << endl;
	//  do you also need to cout the squared digit lengths of n1 and n2? (values of n3 and n4)
	
	// Why are you calling squared_digit_length on n1 and n2 here?
	// you already …