?
Solved

Flash - convert string to object/symbol

Posted on 2011-03-22
2
Medium Priority
?
565 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
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.
Suggested Courses

764 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