Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > JSFL - Extending Flash

Reply
 
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
Old 02-24-2006, 10:23 PM   #1
katekate
Registered User
 
Join Date: Feb 2006
Posts: 14
Question Adding actionscript to a library item (movieclip) using JSFL

Hi again good people of actionscript.org,

If I create a movieclip in my library

Code:
itemexists = fl.getDocumentDOM().library.itemExists("Service1");
if (itemexists == false) {
	fl.getDocumentDOM().library.addNewItem("movieclip", "Service1");
}
And I want to then write some actionscript into the first frame of it, is it possible to do so? The idea is that the author would automatically have a MC in their library that they could use.

I couldn't find any documentation to suggest I could edit the item in such a way. I thought about adding it to the timeline temporarilily, editing it, and then removing it from the timeline, but I'm not sure I can do even that (?)

I guess what I really need to know is, how would I reference the above library item if I wanted to modify it (if it were on the timeline or if it weren't - either will work as long as I can get at it!)

Any help would be greatly appreciated. Thanks - hopefully I'll be able to help someone else someday once I get my mind around all this jsfl stuff

- Kate
katekate is offline   Reply With Quote
Old 02-25-2006, 04:06 PM   #2
hangalot
lala
 
hangalot's Avatar
 
Join Date: Feb 2002
Location: on the road
Posts: 2,858
Default

you can open a symbol for editing using the library.editItem( [ namePath ] )
then you can use it the same way you would edit any other element
__________________
oi poloi
http://www.memorphic.com/news/
hangalot is offline   Reply With Quote
Old 02-25-2006, 08:56 PM   #3
katekate
Registered User
 
Join Date: Feb 2006
Posts: 14
Smile

Thanks! In case any other beginners have the same question later on - what I failed to realize was how to access the timeline after I had chosen to edit the symbol. I learned it's referenced based on where you are - so when I edit the symbol I just needed to reference it as layers[0].frames[0] and I was fine, like so:

ActionScript Code:
// then let's put some actionscript in its first frame. // open up the symbol for editing. fl.getDocumentDOM().library.editItem("Service1"); // write the actionscript fl.getDocumentDOM().getTimeline().layers[0].frames[0].actionScript = 'stop();';
katekate is offline   Reply With Quote
Old 03-23-2006, 11:56 AM   #4
MacElfresh
Registered User
 
Join Date: Mar 2006
Posts: 1
Default

Well thank you katekate, i've got the exact same problem, and i hoped not spending the day looking for the solution.

Nice you've let the code

Bye
MacElfresh is offline   Reply With Quote
Old 03-23-2006, 05:23 PM   #5
androo_animator
Registered User
 
Join Date: Sep 2005
Posts: 32
Default

Theres no need to edit a symbol to add AS to it.

Code:
var itemexists = fl.getDocumentDOM().library.itemExists("Service1");
if (itemexists == false) {
	fl.getDocumentDOM().library.addNewItem("movieclip", "Service1");
	var myIndex = fl.getDocumentDOM().library.findItemIndex("Service1");
	fl.getDocumentDOM().library.items[myIndex].timeline.layers[0].frames[0].actionScript = "stop();";
}

Last edited by androo_animator; 03-23-2006 at 05:26 PM.
androo_animator is offline   Reply With Quote
Old 03-23-2006, 05:24 PM   #6
hangalot
lala
 
hangalot's Avatar
 
Join Date: Feb 2002
Location: on the road
Posts: 2,858
Default

nice.
__________________
oi poloi
http://www.memorphic.com/news/
hangalot is offline   Reply With Quote
Old 01-26-2009, 11:41 PM   #7
jeddy3
Registered User
 
Join Date: Jan 2009
Posts: 4
Default

how would you add multiple lines of actionscript, i'm having some trouble

thanks!
jeddy3 is offline   Reply With Quote
Old 01-28-2009, 07:14 AM   #8
hangalot
lala
 
hangalot's Avatar
 
Join Date: Feb 2002
Location: on the road
Posts: 2,858
Default

try using \n or \r
__________________
oi poloi
http://www.memorphic.com/news/
hangalot is offline   Reply With Quote
Old 01-28-2009, 09:54 AM   #9
jeddy3
Registered User
 
Join Date: Jan 2009
Posts: 4
Default

thank you
jeddy3 is offline   Reply With Quote
Old 03-19-2009, 03:27 PM   #10
theranch
Registered User
 
Join Date: Oct 2004
Posts: 0
Default

Does anyone have the proper way to escape characters so that I can add the following code to the timeline?
var win:String = "_blank";
clickBtn.onRelease = function(){trace(this._name+win);};
theranch is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MovieClip subclass onEnterFrame - attachMovie vs add from library burtreynolds ActionScript 2.0 4 11-14-2005 05:48 PM
Call a movieclip from the library? BagOfFun ActionScript 1.0 (and below) 3 09-17-2005 09:58 AM
Getting timeline of movieclip instance in the library mrand01 JSFL - Extending Flash 1 06-03-2004 09:01 AM
attachMovie from library of loaded movieClip! fileas ActionScript 1.0 (and below) 0 10-02-2003 06:26 AM
duplicating a movie clip or library item within a movie loaded with loadMovie() Six ActionScript 1.0 (and below) 0 07-19-2001 02:04 AM


All times are GMT. The time now is 07:30 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.