Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

square bracket concatenation syntax problem

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

I seem to be going round in circles trying to dynamically reference an MC.

I have the following instance
Code:
_root.rewindButton.rewindOverNew

I keep getting the following error when trying to dynamically reference it
**Error** Scene=Scene 1, layer=actions, frame=1:Line 657: Expected a field name after '.' operator.
_root[ but + "Button"].[but + buts[x]]._visible = false;

**Error** Scene=Scene 1, layer=actions, frame=1:Line 660: Expected a field name after '.' operator.
_root[ but + "Button"].[but + eff]._visible = true;

I've tried several different syntax but cannot get it right...this is what i am trying to do
Code:
function showButton(but:String,eff:String){
	var buts:Array = new Array("Up","UpNew","Over","OverNew","Down","DownNew","Release","ReleaseNew");

	for (x = 0; x<=7; x++){	
		_root[ but + "Button"].[but + buts[x]]._visible = false;
	}

_root[ but + "Button"].[but + eff]._visible = true;
}
the arguments i'm passing is
Code:
showButton("rewind","OverNew");

So the code should hide all instances for the rewind button and then show the one given by the argument.

What am I doing wrong?

Thanks,
1DMF.



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
yes, and no!

I've worked out the correct syntax, I needed to ensure I forced string converstion with
Code:
_root[ but + "Button"].[[b]String(but + buts[x])[/b]]._visible = false;

But i'm still going round in circles.

I have the following...
Code:
		rewindButton.onRollOut = function() {		
			showButton("rewind","Up");
		}
			rewindButton.onRollOver = function() {						
			showButton("rewind","Over");
		}

The initial button is shown fine, when I hover over the button the hover button is shown, but when I roll out the 'Up' button is no longer visible?



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Dynamic referencing can be a real pig to suss out.
I have always found it best to reference them 'long hand' first and then put them in a loop afterwards.
Another way is to work the commands one statement at a time.
What full statement performs the task you are looking for?

Keith
 
It was my dumb ass and a late night that was the problem.

somehow I had managed to delete the clip instance of the layer, hence it wasn't showing, the code worked fine once I put the clip back on the layer!

I really am pleased with my FLV Player (about to become a free download for all to use!), but I really do hate the Flash IDE.

I only tied flash coz I thought I was missing out on something, and although pleased with both the website and my new FLV player application, I don't think I will specialise in it.

needs far to much 'design' skill and a lot of patience finding your way around.

Flash is a double edged sword, great for what it can do, but a real pain getting it to do it!

Lucky i'm learning OOP , at least the concept of instances of objects isn't alien to me!



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Yup deleting the thing you want to show would do it.
The error reporting of Flash leaves a lot to be desired. I am thinking in particular of 'object not found' errors which appear to go unnoticed.

I agree about Flash being awkward to work with but it can also be fun. It took me ages to get my head round timing issues - repeating an action after a certain time etc. I have found that having a timing object running in the background is easier to control than using increment counters. This may not be the best way to do it but I have found it to be the most reliable.


Keith
 
I've actually found , due to my bad coding, that not moaning that you have tried to reference an object that doesn't exist to go in my favour.

I know using that 'feature' is bad practice, but as you say sometimes with writing applications, getting it to work out weighs doing it the right way!

I'm no animator or artist (well music not graphics), so Flash will never be my bread and butter, but yes I have enjoyed creating my flash player app and it has enabled me to acheive a specific goal, which I was unable to do with all the free FLV players I could find on the net!



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Hey Keith,

dunno if you would be interested, but I've finished my project and it is now available as a pre-official release download.


:)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Hi 1DMF
I don't really have a use for it but I have had a look at the demo and it looks good. I like the 'back to the start' button nice touch.
One thing to mention - the toggle state of the PLAY button is backwards.

Keith
 
Cheers Keith,

Hmm, perhaps, depends on your perspective, this was discussed with a few 'users' and they all said that when it's paused they expect to see a pause symbol, but I do understand what you say.

Hey as it is totaly configurable with your own images, you can always upload your play/pause images the opoosite way round ;-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top