Susurrus
asked on
intialising an axShockwaveFlashObject at runtime in c#
I am using an axShockwaveFlashObject to include a flash animation in my c# application. I can create a working AxShockwaveFlash object by draging it from the tool bar at design time, but if i try to create one through code at runtime I get the error:
Exception of type 'System.Windows.Forms.AxHo st+Invalid ActiveXSta teExceptio n' was thrown
I have included my code below:
Exception of type 'System.Windows.Forms.AxHo
I have included my code below:
try{
AxShockwaveFlash animFlashObject = new AxShockwaveFlash();
this.Controls.Add(animFlashObject);
currentFlashObject.Enabled = true;
currentFlashObject.Location = new Point(0, 0);
currentFlashObject.Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
currentFlashObject.LoadMovie(0, Application.StartupPath + @"/flash/gui.swf");
}catch(Exception x){
MessageBox.Show(x.Message);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
note, you may need to use this.Show in-between... it may handle your error (commented out above)
i can't have the same error that you are having. Maybe try using a different swf file just to check if there is a problem in your current swf file.
for your code to run..i just used a string variable for the filename before using it in the LoadMovie().
I dont have an explanation though, on why it cant run on putting the name of the file/path directly.
for your code to run..i just used a string variable for the filename before using it in the LoadMovie().
I dont have an explanation though, on why it cant run on putting the name of the file/path directly.
try{
string filename = Application.StartupPath + @"/flash/gui.swf";
AxShockwaveFlash animFlashObject = new AxShockwaveFlash();
this.Controls.Add(animFlashObject);
animFlashObject.Enabled = true;
animFlashObject.Location = new Point(0, 0);
animFlashObject.Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
animFlashObject.LoadMovie(0, filename);
}catch(Exception x){
MessageBox.Show(x.Message);
}
This question is answered: the user got an exception on an unitialized object, I showed the code how to initialize properly. Please accept comment http:#24200580 (abel)