Solved

Flash - convert string to object/symbol

Posted on 2011-03-22
2
554 Views
Last Modified: 2012-08-14
I've converted a symbol name to a string, slicing the last three characters of of it. Now the problem comes, I want to be able to use it again as a symbol/object.

I've got this so far, but it "ofcourse" gives warning that a String doesn't have a currentFrame.
function btnOverFunction(e:MouseEvent) {
	var thisString = e.currentTarget.name.toString();
	var currentButton = thisString.slice(0, -3);
	if(currentButton.currentFrame < 2) {
		currentButton.gotoAndPlay(1);
	}
}

Open in new window


so how can I solve this problem?
0
Comment
Question by:ErnstJacobs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
deepanjandas earned 500 total points
ID: 35190541
try this(I guess the currentButton object is within the Button):
function btnOverFunction(e:MouseEvent) {
        var currentButtonName:String = e.currentTarget.name.toString();
        currentButtonName = currentButtonName.slice(0, -3);
        var currentButtonClip:* = ( e.currentTarget ).getChildByName( currentButtonName  );//the instance name is set as what comes at currentButtonName 
        if(currentButtonClip.currentFrame < 2) {
                currentButtonClip.gotoAndPlay(1);
        }
}

Open in new window


Warm Regards
Deepanjan Das
0
 
LVL 1

Expert Comment

by:smabudhahir
ID: 35190902
Try this..

function btnOverFunction(e:MouseEvent) {
        var currentButtonName:String = e.currentTarget.name.toString();
        currentButtonName = currentButtonName.slice(0, -3);

        var nTgt = this[currentButtonName]; //Replace 'this' with the correct reference of the symbol with name as received in 'currentButtonName'

        if(nTgt.currentFrame < 2) {
                nTgt.gotoAndPlay(1);
        }
}

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question