dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: linkage?

  1. #1
    Senior Member
    Join Date
    Aug 2006
    Posts
    131

    linkage?

    if i place a button on my main timeline called "p1", and there is a mc called "clip1" with code on frame 1 that does a function when "p1" is pushed... what would the coding for it look like this to have the function happen? it does not seem to work no matter what i do... but if i put it within the mc and remove the _root it works fine. how can i have the button on the main timeline or rather "call it"

    i used this

    _root.p1.onRelease = function() {
    Last edited by ultrapyro; 04-25-2008 at 11:31 AM.

  2. #2
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi,

    If both are in the main timeline (_root) (or in the same location -mean have the same parent-) then it should work..

    For example Insert this AS in frame 1 of your _root timeline:

    Code:
    p1.onRelease=function() {
        clip1._alpha=50
    }
    Of course you have to name your button and clip accordingly (select an object and in the "Properties" tab inside Flash environment give the appropriate names eg. p1 for the button and clip1 for your movie clip)

    Kostas
    K. Zotos online portfolio: http://www.in3d.eu

  3. #3
    Senior Member
    Join Date
    Aug 2006
    Posts
    131
    kk thanks, but how about if the button is else where such as the main timeline, and the mc code is not on the timeline... but within the mc (which is on the main timeline)

  4. #4
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Just give the appropriate target path..

    Example:
    If "clip1" is inside a clip named "Container" (and "Container" is inside _root)
    then use:
    Code:
    p1.onRelease=function() {
        Container.clip1._alpha=50
    }
    If "clip1" is inside a movie clip named "clip2" which is inside "Container" then use:
    Code:
    p1.onRelease=function() {
        Container.clip2.clip1._alpha=50  //To access clip1
        Container.clip2._rotation=45  // To acess clip2
    }
    Of course you can have any clip path combination. Depends where are you:
    For example to access the "Container" clip from inside "clip1" in the previous example, may use:

    _parent._parent._rotation=30 // Acess "Container" clip from its child "clip1"
    Or the same is: _root.Container._rotation=30

    There is a parent-child relationschip (a clip inside another, is a child of this clip). When change a property in the parent, affects its children too..


    Also used the keyword "this" to refer the current object
    _level0 is synonym as _root etc..

    You can even communicate between movie clips from different levels
    like: _level1.Clip1._xscale=50 (you don't need the _level1 if you are inside _level1 -only if you access it from different levels)

    Maybe sounds a bit complicated but need to always have in mind where are you (in which hierarchy level or path and what you want to access) Then you have to supply the correct target path..

    If you become familiar with the basic idea then you see that is not so difficult.. hope
    Last edited by Kostas Zotos; 04-25-2008 at 01:51 PM.
    K. Zotos online portfolio: http://www.in3d.eu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center